From 06bc24a13992bc79bf21cb8b17936b8f39494248 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 21 Jan 2022 15:03:35 -0800 Subject: [PATCH] [Tests] migrate tests to Github Actions per https://github.com/ljharb/object.assign/pull/81 See also: https://github.com/inspect-js/is-arguments/pull/38 --- .github/workflows/node-pretest.yml | 7 ++ .github/workflows/node.yml | 108 ++++++++++++++++++++++ .github/workflows/rebase.yml | 15 +++ .github/workflows/require-allow-edits.yml | 12 +++ .travis.yml | 26 ------ package.json | 5 +- 6 files changed, 146 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/node-pretest.yml create mode 100644 .github/workflows/node.yml create mode 100644 .github/workflows/rebase.yml create mode 100644 .github/workflows/require-allow-edits.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/node-pretest.yml b/.github/workflows/node-pretest.yml new file mode 100644 index 0000000..765edf7 --- /dev/null +++ b/.github/workflows/node-pretest.yml @@ -0,0 +1,7 @@ +name: 'Tests: pretest/posttest' + +on: [pull_request, push] + +jobs: + tests: + uses: ljharb/actions/.github/workflows/pretest.yml@main diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml new file mode 100644 index 0000000..d7d2748 --- /dev/null +++ b/.github/workflows/node.yml @@ -0,0 +1,108 @@ +name: 'Tests: node.js' + +on: [pull_request, push] + +jobs: + matrix: + runs-on: ubuntu-latest + outputs: + latest: ${{ steps.set-matrix.outputs.requireds }} + minors: ${{ steps.set-matrix.outputs.optionals }} + steps: + - uses: ljharb/actions/node/matrix@main + id: set-matrix + with: + versionsAsRoot: true + type: majors + preset: '>=4' # mocha 5 requires node 4 + + latest: + needs: [matrix] + name: 'latest majors' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: ${{ fromJson(needs.matrix.outputs.latest) }} + eslint: + - 8 + - 7 + - 6 + - 5 + - 4 + - 4.14 # last version without messageId + - 3 + exclude: + - node-version: 5 + - node-version: 5 + - node-version: 4 + - node-version: 4 + - node-version: 15 + eslint: 8 + - node-version: 13 + eslint: 8 + - node-version: 11 + eslint: 8 + - node-version: 11 + eslint: 7 + - node-version: 10 + eslint: 8 + - node-version: 9 + eslint: 8 + - node-version: 9 + eslint: 7 + - node-version: 8 + eslint: 8 + - node-version: 8 + eslint: 7 + - node-version: 7 + eslint: 8 + - node-version: 7 + eslint: 7 + - node-version: 7 + eslint: 6 + - node-version: 6 + eslint: 8 + - node-version: 6 + eslint: 7 + - node-version: 6 + eslint: 6 + - node-version: 5 + eslint: 8 + - node-version: 5 + eslint: 7 + - node-version: 5 + eslint: 6 + - node-version: 5 + eslint: 5 + - node-version: 4 + eslint: 8 + - node-version: 4 + eslint: 7 + - node-version: 4 + eslint: 6 + - node-version: 4 + eslint: 5 + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install ${{ matrix.node-version }} && npm install' + with: + node-version: ${{ matrix.node-version }} + after_install: npm install --no-save "eslint@${{ matrix.eslint }}" + skip-ls-check: ${{ matrix.node-version < 10 && true || false }} + env: + NPM_CONFIG_LEGACY_PEER_DEPS: true + - run: npx ls-engines + if: ${{ matrix.node-version >= 12 }} + - run: npm run tests-only + - uses: codecov/codecov-action@v1 + + node: + name: 'node.js' + needs: [latest] + runs-on: ubuntu-latest + steps: + - run: 'echo tests completed' diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml new file mode 100644 index 0000000..5b6d04b --- /dev/null +++ b/.github/workflows/rebase.yml @@ -0,0 +1,15 @@ +name: Automatic Rebase + +on: [pull_request_target] + +jobs: + _: + name: "Automatic Rebase" + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/rebase@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/require-allow-edits.yml b/.github/workflows/require-allow-edits.yml new file mode 100644 index 0000000..7b842f8 --- /dev/null +++ b/.github/workflows/require-allow-edits.yml @@ -0,0 +1,12 @@ +name: Require “Allow Edits” + +on: [pull_request_target] + +jobs: + _: + name: "Require “Allow Edits”" + + runs-on: ubuntu-latest + + steps: + - uses: ljharb/require-allow-edits@main diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c6697e1..0000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: node_js -os: - - linux -node_js: - - "12" - - "10" - - "8" - - "6" - -before_install: - - 'nvm install-latest-npm' -install: - - 'npm install' - - 'if [ "${TRAVIS_NODE_VERSION}" = "6" ]; then npm install --no-save eslint@5 ; fi' - - 'npm ls > /dev/null' -script: - - 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi' - - 'if [ -n "${TEST-}" ]; then npm run tests-only; fi' -sudo: false -env: - - TEST=true -matrix: - fast_finish: true - include: - - node_js: "lts/*" - env: PRETEST=true diff --git a/package.json b/package.json index 1a5f102..14fbeb9 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,14 @@ "lint": "eslint .", "mocha": "mocha --recursive", "postversion": "git commit package.json CHANGELOG.md -m \"Version $npm_package_version\" && npm run tag && git push && git push --tags && npm publish", - "prepublish": "in-publish && safe-publish-latest || not-in-publish", + "prepublishOnly": "safe-publish-latest", + "prepublish": "not-in-publish || safe-publish-latest", "pretest": "npm run --silent lint", "preversion": "npm run test && npm run check-changelog && npm run check-only-changelog-changed", "tag": "git tag v$npm_package_version", "test": "npm run tests-only", "tests-only": "npm run mocha --silent tests", + "posttest": "aud --production", "version:major": "npm --no-git-tag-version version major", "version:minor": "npm --no-git-tag-version version minor", "version:patch": "npm --no-git-tag-version version patch" @@ -44,6 +46,7 @@ "eslint": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" }, "devDependencies": { + "aud": "^2.0.0", "chai": "^4.2.0", "eslint": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0", "eslint-config-airbnb-base": "^14.0.0",