Skip to content

feat: add linting job to CI workflow and simplify test script #158

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,25 @@ on:
pull_request:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'

- name: Install dependencies
run: npm install --ignore-scripts --include=dev

- name: Run lint
run: npm run lint
Comment on lines +12 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe we already run the linter via pretest

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, should the linter run after the tests using posttest? I've never agreed that the linter should run with the tests—it should be something separate and in a different job.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locally, everything should run with npm test.

The CI jobs should be configured so that the linter runs once, and the tests run on every supported node version (minor or major).

Thus, npm test runs everything, and CI workflows run more granular scripts.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the linter should live under the test command.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? That's how every project I've maintained or contributed to works.


test:
uses: pkgjs/action/.github/workflows/node-test.yaml@main
with:
upgrade-policy: all
secrets:
test-secrets: '{"GITHUB_TOKEN":"${{ secrets.GITHUB_TOKEN }}"}'
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
"action-wiby-test": "npm install --production && ./bin/wiby test",
"action-wiby-result": "npm install --production && ./bin/wiby result",
"lint": "standard",
"pretest": "[ \"$NODE_LTS_LATEST\" != \"\" ] && [ \"$MATRIX_NODE_VERSION\" != \"$NODE_LTS_LATEST\" ] && echo 'Skipping linting' || npm run lint",
"test": "npm run tests-only",
"tests-only": "tap",
"test": "tap",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm test should always run everything. you run npm run tests-only if you only want to run the tests.

"generate-docs": "./bin/generate-usage.js"
},
"repository": {
Expand Down
Loading