-
Notifications
You must be signed in to change notification settings - Fork 41
feat(ci): add ci/cd #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | ||
| with: | ||
| node-version: lts/* | ||
| cache: "npm" | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Lint & Format | ||
| run: npm run lint && npm run format:check | ||
|
|
||
| docs-check: | ||
| if: github.event_name == 'pull_request' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Read HEAD_COMMIT | ||
| id: webpack-ref | ||
| run: echo "ref=$(cat HEAD_COMMIT)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Checkout webpack | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| repository: webpack/webpack | ||
| ref: ${{ steps.webpack-ref.outputs.ref }} | ||
| path: webpack | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | ||
| with: | ||
| node-version: lts/* | ||
| cache: "npm" | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Regenerate docs | ||
| run: npm run generate-docs | ||
|
|
||
| - name: Check docs freshness | ||
| run: | | ||
| if ! git diff --quiet pages/; then | ||
| echo "::error::The pages/ directory is out of date. Run 'npm run generate-docs' and commit the changes." | ||
| git diff --stat pages/ | ||
| exit 1 | ||
| fi | ||
| echo "pages/ is up to date." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| name: Sync Webpack | ||
|
|
||
| on: | ||
| schedule: | ||
| # Run every 24 hours at 04:00 UTC | ||
| - cron: "0 4 * * *" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| sync: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - name: Get latest webpack commit | ||
| id: latest | ||
| run: | | ||
| LATEST=$(git ls-remote https://github.com/webpack/webpack.git refs/heads/main | cut -f1) | ||
| CURRENT=$(cat HEAD_COMMIT) | ||
| echo "latest=$LATEST" >> "$GITHUB_OUTPUT" | ||
| echo "current=$CURRENT" >> "$GITHUB_OUTPUT" | ||
| echo "Latest webpack commit: $LATEST" | ||
| echo "Current pinned commit: $CURRENT" | ||
|
|
||
| - name: Check for changes | ||
| id: check | ||
| run: | | ||
| if [ "${{ steps.latest.outputs.latest }}" = "${{ steps.latest.outputs.current }}" ]; then | ||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||
| echo "No changes detected, skipping sync." | ||
| else | ||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| echo "New webpack commit detected, syncing." | ||
| fi | ||
|
|
||
| - name: Checkout webpack | ||
| if: steps.check.outputs.changed == 'true' | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| repository: webpack/webpack | ||
| ref: ${{ steps.latest.outputs.latest }} | ||
| path: webpack | ||
|
|
||
| - name: Setup Node.js | ||
| if: steps.check.outputs.changed == 'true' | ||
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | ||
| with: | ||
| node-version: lts/* | ||
| cache: "npm" | ||
|
|
||
| - name: Install dependencies | ||
| if: steps.check.outputs.changed == 'true' | ||
| run: npm ci | ||
|
|
||
| - name: Update HEAD_COMMIT | ||
| if: steps.check.outputs.changed == 'true' | ||
| run: echo "${{ steps.latest.outputs.latest }}" > HEAD_COMMIT | ||
|
|
||
| - name: Regenerate docs | ||
| if: steps.check.outputs.changed == 'true' | ||
| run: npm run generate-docs | ||
|
|
||
| - name: Commit and push | ||
| if: steps.check.outputs.changed == 'true' | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| git add HEAD_COMMIT pages/ | ||
| git commit -m "chore: sync webpack docs to $(echo ${{ steps.latest.outputs.latest }} | cut -c1-7)" | ||
| git push |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| node_modules | ||
| out | ||
| generated-* | ||
| webpack | ||
| *.generated.* | ||
| /webpack |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| npx lint-staged | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "**/*.{js,mjs,ts,tsx,md,mdx,json.yml}": [ | ||
| "eslint --fix", | ||
| "prettier --check --write" | ||
avivkeller marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| node_modules | ||
| out | ||
| *.generated.* | ||
| /webpack | ||
| pages | ||
| .husky |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 214f361891d8f51f41bafb2e760cb3240d6014be |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # webpack-doc-kit | ||
|
|
||
| Automated TypeScript API documentation generator for [webpack](https://github.com/webpack/webpack). Extracts type definitions from webpack's `types.d.ts` and produces Markdown and HTML documentation, deployed to GitHub Pages. | ||
|
|
||
| ## How It Works | ||
|
|
||
| 1. **TypeDoc** reads webpack's TypeScript type definitions | ||
| 2. Custom plugins process the output (namespace merging, type mapping, themed rendering) | ||
| 3. **@node-core/doc-kit** converts Markdown to HTML | ||
| 4. GitHub Actions deploys the result to GitHub Pages | ||
|
|
||
| ### Webpack Version Tracking | ||
|
|
||
| The `HEAD_COMMIT` file pins the exact webpack/webpack commit used for doc generation. A scheduled GitHub Action runs every 24 hours to: | ||
|
|
||
| 1. Fetch the latest webpack `main` branch HEAD | ||
| 2. Update `HEAD_COMMIT` | ||
| 3. Regenerate documentation | ||
| 4. Push the changes to this repository | ||
|
|
||
| This ensures documentation stays in sync with upstream webpack without manual intervention. | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| ├── generate-md.mjs # TypeDoc entry point | ||
| ├── plugins/ | ||
| │ ├── processor.mjs # Namespace merging + type-map generation | ||
| │ └── theme/ # Custom doc-kit theme | ||
| ├── HEAD_COMMIT # Pinned webpack commit SHA | ||
| ├── .github/workflows/ | ||
| │ ├── ci.yml # Lint + doc generation check | ||
| │ ├── deploy.yml # Build HTML + deploy to GitHub Pages | ||
| │ └── sync.yml # Daily webpack sync | ||
| └── package.json | ||
| ``` | ||
|
|
||
| ## Scripts | ||
|
|
||
| | Script | Description | | ||
| | ----------------------- | ------------------------------------ | | ||
| | `npm run generate-docs` | Generate Markdown from webpack types | | ||
| | `npm run build-html` | Convert Markdown to HTML | | ||
| | `npm run build` | Generate docs + build HTML | | ||
| | `npm run lint` | Run ESLint | | ||
| | `npm run format:check` | Check Prettier formatting | | ||
|
|
||
| ## Contributing | ||
|
|
||
| When making changes to documentation generation (plugins, `generate-md.mjs`, `tsconfig.json`), ensure the docs can still be generated successfully. CI will verify this on every pull request. | ||
|
|
||
| ## License | ||
|
|
||
| See the [webpack project](https://github.com/webpack/webpack) for license details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import js from "@eslint/js"; | ||
| import globals from "globals"; | ||
|
|
||
| export default [ | ||
| js.configs.recommended, | ||
| { | ||
| languageOptions: { | ||
| ecmaVersion: "latest", | ||
| sourceType: "module", | ||
| globals: globals.node, | ||
| }, | ||
| }, | ||
| { | ||
| ignores: ["node_modules/", "out/", "webpack/"], | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.