From cb68096b068a8671962d2cd881c044d7f8cc1eb4 Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Fri, 10 Jun 2022 22:38:06 -0400 Subject: [PATCH] ci: migrate to GitHub Actions w/ matrix (#84) backport of 514dec0f642d65ea1447618063b06def178aa4df - plus some `package.json#scripts` - and remove the typechecking from the CI workflow since the v1.0.x line is pre-TS * ci: migrate to GitHub Actions w/ matrix - Travis CI is only _pseudo_-free after the .org -> .com merge - c.f. https://travis-ci.community/t/org-com-migration-unexpectedly-comes-with-a-plan-change-for-oss-what-exactly-is-the-new-deal/10567 - and honestly, has glitches occasionally where my builds don't run or I can't manually re-run either - GH Actions are _actually_ free for OSS / public repos - and also offer a decent level of composability that's resulted in a huge surge in reusable community Actions (vs. CircleCI orbs etc haven't had nearly as much adoption) - and I've had a mostly great experience on them so far as well - also add a matrix for all Node LTS and all OSes - and upgrade to the Codecov GH Action, since the bash uploader was deprecated (https://about.codecov.io/blog/introducing-codecovs-new-uploader/) - this is basically a mix of the Actions I helped set-up in rpt2's repo and the TSDX templates: - https://github.com/ezolenko/rollup-plugin-typescript2/blob/03cfb048adcf39de56bd4566dc9a7300534a3cc1/.github/workflows/nodejs.yml - https://github.com/jaredpalmer/tsdx/blob/2d7981b00b2bf7363a3eeff44ff5ff698ba58c8c/templates/basic/.github/workflows/main.yml - plus upgrades to all the Actions, for instance, newer `setup-node` now has caching built-in * fix(ci): remove Node 18 due to node-canvas installation issues - per the in-line comment, there are some upstream issues in node-canvas that is causing installation to fail on Node 18 - made a TODO to add Node 18 back to the matrix once it's properly supported upstream * env: reorganize `package.json#scripts` - need `test:coverage` for the CI workflow - add other scripts from `main` branch - and reorder scripts to be the same as `main` as well --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++++ .travis.yml | 10 ---------- package.json | 8 ++++++-- 3 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5199773 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI +on: [push] +jobs: + ci: + name: CI - Node ${{ matrix.node-version }}, ${{ matrix.os }} + + runs-on: ${{ matrix.os }} + strategy: + matrix: + # TODO: add back Node 18 once node-canvas is properly supported: https://github.com/Automattic/node-canvas/issues/2025 + node-version: [14.x, 16.x] # LTS Node: https://nodejs.org/en/about/releases/ + os: [ubuntu-latest, windows-latest, macOS-latest] + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - name: Install + run: npm ci + + - name: Lint + run: npm run lint + - name: Build + run: npm run build + + - name: Test w/ coverage report + run: npm run test:coverage + - name: Upload coverage report to Codecov + uses: codecov/codecov-action@v2 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f8934a7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: node_js -# default is the very old 0.10.48; match local version instead -node_js: '10.16.0' - -before_script: npm run lint -script: npm test -- --coverage -after_script: - # upload coverage reports to CodeCov - - bash <(curl -s https://codecov.io/bash) - - npm run test:pub diff --git a/package.json b/package.json index a27e632..9a9c2d5 100644 --- a/package.json +++ b/package.json @@ -35,11 +35,15 @@ "react-signature-pad" ], "scripts": { - "lint": "standard --parser babel-eslint", - "lint:fix": "standard --parser babel-eslint --fix", "start": "webpack-dev-server -d --inline --hot", + "clean": "rm -rf dist/ && rm -f *.tgz", + "clean:build": "npm run clean && npm run build", "build": "webpack -p --config webpack.production.config.js", + "lint": "standard --parser babel-eslint", + "lint:fix": "standard --parser babel-eslint --fix", "test": "jest", + "test:coverage": "jest --coverage", + "test:watch": "jest --watch", "test:pub": "npm run build && npm pack", "pub": "npm run build && npm publish", "changelog": "changelog-maker"