-
Notifications
You must be signed in to change notification settings - Fork 0
Add comprehensive CI workflow #17
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
4 commits
Select commit
Hold shift + click to select a range
ba288e8
Add CI workflow with build, typecheck, tests, and CLI smoke tests
justin808 dd8de93
Add ESLint, Prettier, and EditorConfig with CI lint job
justin808 facb43c
Apply Prettier formatting to all project files
justin808 5255e9b
Fix smoke tests silently swallowing CLI crashes
justin808 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
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,12 @@ | ||
| root = true | ||
|
|
||
| [*] | ||
| indent_style = space | ||
| indent_size = 2 | ||
| end_of_line = lf | ||
| charset = utf-8 | ||
| trim_trailing_whitespace = true | ||
| insert_final_newline = true | ||
|
|
||
| [*.md] | ||
| trim_trailing_whitespace = false |
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,113 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: npm | ||
| - run: npm ci | ||
| - run: npm run build | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
| retention-days: 1 | ||
|
|
||
| lint: | ||
| name: Lint & Format | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: npm | ||
| - run: npm ci | ||
| - run: npx eslint . | ||
| - run: npx prettier --check . | ||
|
|
||
| typecheck: | ||
| name: Type Check | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: npm | ||
| - run: npm ci | ||
| - run: npx tsc --noEmit | ||
|
|
||
| test: | ||
| name: Test (Node ${{ matrix.node-version }}) | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| node-version: [18, 20, 22] | ||
|
justin808 marked this conversation as resolved.
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: npm | ||
| - run: npm ci | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
| - run: npm test | ||
|
justin808 marked this conversation as resolved.
|
||
|
|
||
| cli-smoke: | ||
|
justin808 marked this conversation as resolved.
|
||
| name: CLI Smoke Test | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: npm | ||
| - run: npm ci | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
|
justin808 marked this conversation as resolved.
|
||
| - name: Run CLI help | ||
| run: node bin/pack-config-diff --help | ||
| - name: Compare JS fixtures | ||
| run: | | ||
| rc=0 | ||
| node bin/pack-config-diff --left=fixtures/webpack.dev.js --right=fixtures/webpack.prod.js --format=summary > /tmp/smoke-js.txt 2>&1 || rc=$? | ||
| cat /tmp/smoke-js.txt | ||
|
justin808 marked this conversation as resolved.
|
||
| if [ "$rc" -gt 1 ]; then echo "::error::CLI crashed (exit code $rc)"; exit 1; fi | ||
| if [ ! -s /tmp/smoke-js.txt ]; then echo "::error::CLI produced no output"; exit 1; fi | ||
| - name: Compare YAML fixtures | ||
| run: | | ||
| rc=0 | ||
| node bin/pack-config-diff --left=fixtures/webpack-development-client.yaml --right=fixtures/webpack-production-client.yaml --format=json > /tmp/smoke-yaml.txt 2>&1 || rc=$? | ||
| cat /tmp/smoke-yaml.txt | ||
| if [ "$rc" -gt 1 ]; then echo "::error::CLI crashed (exit code $rc)"; exit 1; fi | ||
| if [ ! -s /tmp/smoke-yaml.txt ]; then echo "::error::CLI produced no output"; exit 1; fi | ||
| - name: Compare with markdown output | ||
| run: | | ||
| rc=0 | ||
| node bin/pack-config-diff --left=fixtures/webpack.dev.js --right=fixtures/webpack.prod.js --format=markdown > /tmp/smoke-md.txt 2>&1 || rc=$? | ||
| cat /tmp/smoke-md.txt | ||
| if [ "$rc" -gt 1 ]; then echo "::error::CLI crashed (exit code $rc)"; exit 1; fi | ||
| if [ ! -s /tmp/smoke-md.txt ]; then echo "::error::CLI produced no output"; exit 1; fi | ||
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,4 @@ | ||
| dist/ | ||
| coverage/ | ||
| node_modules/ | ||
| *.log |
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,7 @@ | ||
| { | ||
| "semi": true, | ||
| "singleQuote": false, | ||
| "trailingComma": "all", | ||
| "printWidth": 100, | ||
| "tabWidth": 2 | ||
| } |
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 |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| #!/usr/bin/env node | ||
| const { run } = require("pack-config-diff") | ||
| const { run } = require("pack-config-diff"); | ||
|
|
||
| try { | ||
| const exitCode = run(process.argv.slice(2)) | ||
| process.exit(exitCode) | ||
| const exitCode = run(process.argv.slice(2)); | ||
| process.exit(exitCode); | ||
| } catch (error) { | ||
| console.error(error.message) | ||
| process.exit(1) | ||
| console.error(error.message); | ||
| process.exit(1); | ||
| } |
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,53 @@ | ||
| import eslint from "@eslint/js"; | ||
| import tseslint from "typescript-eslint"; | ||
| import eslintConfigPrettier from "eslint-config-prettier"; | ||
|
|
||
| export default tseslint.config( | ||
| { | ||
| ignores: ["dist/", "coverage/", "fixtures/", "node_modules/"], | ||
| }, | ||
| eslint.configs.recommended, | ||
| ...tseslint.configs.recommended, | ||
| eslintConfigPrettier, | ||
| { | ||
| files: ["src/**/*.ts"], | ||
| rules: { | ||
| "@typescript-eslint/no-explicit-any": "warn", | ||
|
justin808 marked this conversation as resolved.
|
||
| }, | ||
| }, | ||
| { | ||
| files: ["**/*.js"], | ||
| rules: { | ||
| "@typescript-eslint/no-require-imports": "off", | ||
| }, | ||
| }, | ||
| { | ||
| files: ["jest.config.js"], | ||
| languageOptions: { | ||
| globals: { | ||
| module: "readonly", | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| files: ["test/**/*.js"], | ||
| languageOptions: { | ||
| globals: { | ||
| describe: "readonly", | ||
| test: "readonly", | ||
| expect: "readonly", | ||
| it: "readonly", | ||
| beforeEach: "readonly", | ||
| afterEach: "readonly", | ||
| beforeAll: "readonly", | ||
| afterAll: "readonly", | ||
| jest: "readonly", | ||
| require: "readonly", | ||
| module: "readonly", | ||
| __dirname: "readonly", | ||
| process: "readonly", | ||
| console: "readonly", | ||
| }, | ||
| }, | ||
| }, | ||
|
justin808 marked this conversation as resolved.
justin808 marked this conversation as 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 |
|---|---|---|
| @@ -1,18 +1,18 @@ | ||
| class DemoPlugin { | ||
| constructor(name) { | ||
| this.name = name | ||
| this.name = name; | ||
| } | ||
| } | ||
|
|
||
| module.exports = () => ({ | ||
| mode: "development", | ||
| output: { | ||
| filename: "bundle.js", | ||
| path: "/Users/alice/project/public/packs" | ||
| path: "/Users/alice/project/public/packs", | ||
| }, | ||
| optimization: { | ||
| minimize: false, | ||
| minimizer: [() => "terser"] | ||
| minimizer: [() => "terser"], | ||
| }, | ||
| plugins: [new DemoPlugin("demo")] | ||
| }) | ||
| plugins: [new DemoPlugin("demo")], | ||
| }); |
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,18 +1,18 @@ | ||
| class DemoPlugin { | ||
| constructor(name) { | ||
| this.name = name | ||
| this.name = name; | ||
| } | ||
| } | ||
|
|
||
| module.exports = () => ({ | ||
| mode: "production", | ||
| output: { | ||
| filename: "bundle-[contenthash].js", | ||
| path: "/home/bob/project/public/packs" | ||
| path: "/home/bob/project/public/packs", | ||
| }, | ||
| optimization: { | ||
| minimize: true, | ||
| minimizer: [() => "swc"] | ||
| minimizer: [() => "swc"], | ||
| }, | ||
| plugins: [new DemoPlugin("demo")] | ||
| }) | ||
| plugins: [new DemoPlugin("demo")], | ||
| }); |
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.
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.