From b3cc4267736a9de8768f77cdf98811d8982dd9dd Mon Sep 17 00:00:00 2001 From: Jordan Harband <ljharb@gmail.com> Date: Thu, 25 Nov 2021 13:02:37 -0800 Subject: [PATCH] [Tests] migrate to Github Actions --- .github/workflows/node-pretest.yml | 37 ++++++++++++++ .github/workflows/node.yml | 48 +++++++++++++++++++ .github/workflows/rebase.yml | 15 ++++++ .github/workflows/require-allow-edits.yml | 12 +++++ .nycrc | 6 +-- .travis.yml | 38 ++------------- css/storybook.scss | 2 +- package.json | 13 +---- .../DateRangePickerInputController_spec.jsx | 3 +- 9 files changed, 121 insertions(+), 53 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 diff --git a/.github/workflows/node-pretest.yml b/.github/workflows/node-pretest.yml new file mode 100644 index 00000000..981f03f4 --- /dev/null +++ b/.github/workflows/node-pretest.yml @@ -0,0 +1,37 @@ +name: 'Tests: pretest/posttest/build' + +on: [pull_request, push] + +jobs: + pretest: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install lts/* && npm install' + with: + node-version: 'lts/*' + - run: npm run pretest + + # posttest: + # runs-on: ubuntu-latest + + # steps: + # - uses: actions/checkout@v2 + # - uses: ljharb/actions/node/install@main + # name: 'nvm install lts/* && npm install' + # with: + # node-version: 'lts/*' + # - run: npm run posttest + + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: ljharb/actions/node/install@main + name: 'nvm install lts/* && npm install' + with: + node-version: 'lts/*' + - run: npm run build diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml new file mode 100644 index 00000000..64fd7789 --- /dev/null +++ b/.github/workflows/node.yml @@ -0,0 +1,48 @@ +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: + type: 'majors' + versionsAsRoot: true + preset: '>=6' + # to test in node < 6, we need to run the build in one stage, including the tests, and then run the tests in the desired node version later + + majors: + needs: [matrix] + name: 'latest minors' + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: ${{ fromJson(needs.matrix.outputs.latest) }} + react: + - 16 + - 15 + - 0.14 + + 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 }} + - run: npm run tests-only + - uses: codecov/codecov-action@v2 + + node: + name: 'node 6+' + needs: [majors] + 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 00000000..027aed07 --- /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 00000000..549d7b48 --- /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/.nycrc b/.nycrc index fb85ce72..90d79055 100644 --- a/.nycrc +++ b/.nycrc @@ -11,14 +11,10 @@ ], "reporter": [ "text", + "html", "lcov" ], "all": true, - "check-coverage": true, - "statements": 83, - "branches": 73, - "lines": 83, - "functions": 67.8, "sourceMap": false, "instrument": false } diff --git a/.travis.yml b/.travis.yml index f8c4163f..ea471eba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,43 +1,13 @@ language: node_js -node_js: - - 14 - - 12 - - 10 - - 8 - - 6 +node_js: lts/* before_install: - - 'nvm install-latest-npm' + - nvm install-latest-npm services: - xvfb -before_script: - - 'if [ -n "${KARMA-}" ]; then export DISPLAY=:99.0; fi' script: - - 'if [ -n "${LINT-}" ]; then npm run lint ; fi' - - 'if [ -n "${BUILD-}" ]; then npm run build ; fi' - - 'if [ "${TEST-}" = true ]; then npm run tests-only ; fi' - - 'if [ -n "${KARMA-}" ]; then npm run tests-karma ; fi' - - 'if [ -n "${COVERAGE-}" ] && [ "${TRAVIS_BRANCH-}" = "master" ]; then npm run cover; cat ./coverage/lcov.info | ./node_modules/.bin/coveralls ; fi' -install: - - 'if [ -n "${LINT-}" ]; then NPM_CONFIG_LEGACY_PEER_DEPS=true npm install --legacy-bundling ; else npm install ; fi' + - npm run tests-karma env: global: - - TEST=true - matrix: - - REACT=0.14 - - REACT=15 - REACT=16 + - DISPLAY=:99.0 sudo: false -matrix: - fast_finish: true - include: - - node_js: "lts/*" - env: LINT=true TEST=false - - node_js: "lts/*" - env: BUILD=true TEST=false - - node_js: "lts/*" - env: COVERAGE=true TEST=false - - node_js: "lts/*" - env: KARMA=true TEST=false - allow_failures: - - node_js: "10" - env: REACT=16 diff --git a/css/storybook.scss b/css/storybook.scss index c3043697..2e20e67c 100644 --- a/css/storybook.scss +++ b/css/storybook.scss @@ -21,4 +21,4 @@ a { .foo-bar { background: red !important; -} \ No newline at end of file +} diff --git a/package.json b/package.json index 5ebadfb7..9400cc49 100644 --- a/package.json +++ b/package.json @@ -11,15 +11,13 @@ "prebuild:css": "rimraf lib/css && mkdirp lib/css", "build:css": "node scripts/buildCSS.js", "clean": "rimraf lib esm", - "precover": "rimraf coverage && npm run react", - "cover": "cross-env NODE_ENV=test node --max-old-space-size=4096 $(which nyc) npm run mocha", "lint": "eslint --ext .js,.jsx src test", "mocha": "mocha ./test/_helpers", "storybook:uninstall": "npm uninstall --no-save @storybook/react && rimraf node_modules/@storybook node_modules/react-modal node_modules/react-dom-factories", "react": "NPM_CONFIG_LEGACY_PEER_DEPS=true enzyme-adapter-react-install 16", "pretest": "npm run --silent lint", "pretests-only": "npm run react", - "tests-only": "npm run mocha --silent", + "tests-only": "cross-env NODE_ENV=test nyc npm run mocha --silent", "pretests-karma": "npm run react", "tests-karma": "karma start", "test": "npm run build && npm run tests-only", @@ -73,7 +71,6 @@ "babel-preset-airbnb": "^4.5.0", "chai": "^4.2.0", "clean-css": "^4.2.3", - "coveralls": "^3.1.0", "cross-env": "^5.2.1", "enzyme": "^3.11.0", "enzyme-adapter-react-helper": "^1.3.9", @@ -98,7 +95,7 @@ "mocha-wrap": "^2.1.2", "moment": "^2.29.1", "moment-jalaali": "^0.7.4", - "nyc": "^14.1.1", + "nyc": "^10.3.2", "raw-loader": "^0.5.1", "react": "^0.14 || ^15.5.4 || ^16.1.1", "react-dom": "^0.14 || ^15.5.4 || ^16.1.1", @@ -138,12 +135,6 @@ "react-dom": "^0.14 || ^15.5.4 || ^16.1.1", "react-with-direction": "^1.3.1" }, - "greenkeeper": { - "ignore": [ - "mocha", - "webpack" - ] - }, "engines": { "node": ">=0.10" } diff --git a/test/components/DateRangePickerInputController_spec.jsx b/test/components/DateRangePickerInputController_spec.jsx index 91601231..b6112065 100644 --- a/test/components/DateRangePickerInputController_spec.jsx +++ b/test/components/DateRangePickerInputController_spec.jsx @@ -4,8 +4,7 @@ import moment from 'moment'; import sinon from 'sinon-sandbox'; import { shallow } from 'enzyme'; -import DateRangePickerInputController - from '../../src/components/DateRangePickerInputController'; +import DateRangePickerInputController from '../../src/components/DateRangePickerInputController'; import DateRangePickerInput from '../../src/components/DateRangePickerInput'; -- GitLab