Skip to content

Commit

Permalink
chore: replace nps with npm scripts (#5128)
Browse files Browse the repository at this point in the history
* chore: WIP - replace `nps` with npm scripts

Fixes #5126
  • Loading branch information
voxpelli authored Aug 5, 2024
1 parent 1883c41 commit c44653a
Show file tree
Hide file tree
Showing 11 changed files with 470 additions and 2,007 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Then:
- **Do not modify** the root `mocha.js` file directly; it is automatically generated.
- Keep your PR focused.
Don't fix two things at once; don't upgrade dependencies unless necessary.
1. Before committing, run `npm start test`.
1. Before committing, run `npm test`.
- This will run both Node.js-based and browser-based tests.
- Ultimately, your pull request will be built on our continuous integration servers ([GitHub Actions](https://github.com/mochajs/mocha/actions?query=workflow%3A%22Tests%22)).
The first step to ensuring these checks pass is to test on your own machine.
Expand Down
2 changes: 0 additions & 2 deletions .github/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ If you are having trouble, don't be afraid to [ask for help](./CONTRIBUTING.md#
- Do not use `yarn install` or `pnpm install`.
- Some optional dependencies may fail; you can safely ignore these unless you are trying to build the documentation.
- If you're sick of seeing the failures, run `npm install --ignore-scripts`.

> PRO TIP: After `npm install`, run `npm start` to see a list of commands which can be run with `npm start <command>` (powered by [nps](https://npm.im/nps)).
58 changes: 50 additions & 8 deletions .github/workflows/mocha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,67 @@ jobs:
smoke:
uses: ./.github/workflows/npm-script.yml
with:
os: 'ubuntu-latest,windows-2019'
node-versions: '14,16,18,20,22'
npm-script: test:smoke
node-versions: '14,22,lts/*'
npm-script: test-smoke

test-node:
test-node-lts:
# TODO: Restore "mocha-github-actions-reporter" style reporting without relying on third party module
uses: ./.github/workflows/npm-script.yml
needs: smoke
strategy:
fail-fast: false
matrix:
test-part:
- interfaces
- unit
- integration
- jsapi
- requires
- reporters
- only
with:
npm-script: test-node:${{ matrix.test-part }}

test-node-all:
name: Test ${{ matrix.test-part }} in all environments
# TODO: Restore "mocha-github-actions-reporter" style reporting without relying on third party module
uses: ./.github/workflows/npm-script.yml
needs: test-node-lts
strategy:
fail-fast: false
matrix:
coverage: [true]
test-part:
- interfaces
- unit
- integration
- requires
- reporters
- only
include:
- test-part: jsapi
coverage: false
with:
os: 'ubuntu-latest,windows-2019'
node-versions: '14,16,18,20,22'
npm-script: test:node
coverage: true
npm-script: test-node:${{ matrix.test-part }}
coverage: ${{ matrix.coverage }}

test-node-upload-coverage:
needs: test-node-all
if: always()
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true

test-browser-local:
uses: ./.github/workflows/npm-script.yml
with:
browsers: ChromeHeadless
npm-script: test:browser
npm-script: test-browser

# test-browser-saucelabs:
# # Don't run forked 'pull_request' without saucelabs token
Expand All @@ -53,4 +95,4 @@ jobs:
# secrets: inherit
# with:
# browsers: 'firefox@latest,chrome@latest,MicrosoftEdge@latest,safari@latest'
# npm-script: test:browser
# npm-script: test-browser
14 changes: 2 additions & 12 deletions .github/workflows/npm-script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,10 @@ jobs:
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
- name: Generate coverage report
if: always() && inputs.coverage
run: npm start coverage-report-lcov
run: npm run test-coverage-generate
- name: Coveralls Parallel
if: always() && inputs.coverage
uses: coverallsapp/github-action@v2
with:
flag-name: run-${{ join(matrix.*, '-') }}
flag-name: run-${{ inputs.npm-script }}-${{ join(matrix.*, '-') }}
parallel: true

upload-coverage:
needs: script
if: always() && inputs.coverage
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
5 changes: 2 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ _So you wanna build the site?_
## Development

1. Run `npm install` from working copy root to get Node.js deps.
1. To serve the site and rebuild as changes are made, execute `npm start docs.watch`.
1. To rebuild the site _once_, execute `npm start docs`.
1. To serve the site and rebuild as changes are made, execute `npm run docs-watch`.
1. To rebuild the site _once_, execute `npm run docs`.

### Notes

- The content lives in `docs/index.md`; everything else is markup, scripts, assets, etc.
- This file (`docs/README.md`) should _not_ be included in the build.
- `docs/_site_` is where the deployed site lives. This directories are _not_ under version control.
- See `package-scripts.js` for details on what the builds are actually doing.

## License

Expand Down
2 changes: 2 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ module.exports = [
'docs/{_dist,_site,api,example}/**',
'out/**',
'test/integration/fixtures/**',
'.karma/**',
'mocha.js'
],
}
];
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports = config => {
let cfg = {...baseConfig};

// TO RUN AGAINST SAUCELABS LOCALLY, execute:
// `CI=1 SAUCE_USERNAME=<user> SAUCE_ACCESS_KEY=<key> npm start test.browser`
// `CI=1 SAUCE_USERNAME=<user> SAUCE_ACCESS_KEY=<key> npm run test-browser`
let sauceConfig;

// configuration for CI mode
Expand Down
4 changes: 2 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
# that is where we will look for package.json/.nvmrc/etc not repo root!

[build]
command = "npm run docs"
publish = "docs/_site/"
command = "npm start docs.production"

[build.environment]
DEBUG = "mocha:docs*"
NODE_VERSION = "16"
RUBY_VERSION = "2.7.2"

[context.deploy-preview]
command = "npm start docs"
command = "npm run docs"
publish = "docs/_site/"
Loading

0 comments on commit c44653a

Please sign in to comment.