From 3c9f181045f9ce5cd55b1529b4c708999d31b030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Mon, 15 Mar 2021 18:13:55 +0100 Subject: [PATCH 1/5] ci: migrate to GitHub Actions (#286) * ci: schedule github actions updates * ci: add github actions release workflow * ci: remove config related to travis * ci: split workflows * ci: use action for installing dependencies * ci: remove lint max warnings * ci: improve scripts * ci: remove format check * ci: install dependencies with npm * ci: revert - install dependencies with npm * ci: install dependencies manually on test step * ci: set ci env var on install step * ci: install peer deps in legacy mode * ci: revert manual deps install * ci: remove node 15 * ci: update badge in README.md Closes #275 --- .github/dependabot.yml | 7 ++++ .github/workflows/ci.yml | 69 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 44 ++++++++++++++++++++++ .travis.yml | 34 ----------------- README.md | 4 +- package.json | 6 +-- 6 files changed, 124 insertions(+), 40 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .travis.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..c54be545 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + # Set update schedule for GitHub Actions + - package-ecosystem: 'github-actions' + directory: '/' + schedule: + interval: 'daily' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..199da601 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,69 @@ +name: CI + +on: + push: + branches: + # semantic-release valid branches + - '+([0-9])?(.{+([0-9]),x}).x' + - 'main' + - 'next' + - 'next-major' + - 'beta' + - 'alpha' + pull_request: + types: [opened, synchronize] + +jobs: + code_validation: + name: Code Validation + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Use Node + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Install dependencies + uses: bahmutov/npm-install@v1 + with: + useLockFile: false + + - name: Lint code + run: npm run lint + + # TODO: reenable on v4 +# - name: Check format +# run: npm run format:check + + test: + name: Tests (Node v${{ matrix.node }} - ESLint v${{ matrix.eslint }}) + runs-on: ubuntu-latest + + strategy: + matrix: + node: ['10.12', '10', '12.0', '12', '14'] + eslint: [5, 6, 7] + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Use Node + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + + - name: Install dependencies + uses: bahmutov/npm-install@v1 + with: + useLockFile: false + + - name: Install ESLint v${{ matrix.eslint }} + run: npm install --no-save eslint@${{ matrix.eslint }} + + - name: Run tests + run: npm run test:ci diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..4128186b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,44 @@ +name: Release + +on: + workflow_run: + workflows: ['CI'] + types: + - completed + push: + branches: + # semantic-release valid branches + - '+([0-9])?(.{+([0-9]),x}).x' + - 'main' + - 'next' + - 'next-major' + - 'beta' + - 'alpha' + +jobs: + main: + name: NPM Release + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Use Node + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Install dependencies + uses: bahmutov/npm-install@v1 + with: + useLockFile: false + + - name: Build package + run: npm run build + + - name: Release new version to NPM + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx semantic-release diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index eee7f934..00000000 --- a/.travis.yml +++ /dev/null @@ -1,34 +0,0 @@ -language: node_js - -env: - global: - - FORCE_COLOR=true - matrix: - - ESLINT=5 - - ESLINT=6 - - ESLINT=7 - -node_js: - - 10.12 - - 10 - - 12.0 - - 12 - - 14 - -before_script: - - 'if [ -n "${ESLINT-}" ]; then npm install --no-save "eslint@${ESLINT}" ; fi' - -jobs: - include: - - stage: release - if: branch = main AND type != pull_request AND fork = false - node_js: 14 - env: ESLINT=7 - script: npm run build - deploy: - provider: script - skip_cleanup: true - on: - branch: main - script: - - npx semantic-release diff --git a/README.md b/README.md index e7e46d09..03f7f89d 100644 --- a/README.md +++ b/README.md @@ -153,8 +153,8 @@ To enable this configuration use the `extends` property in your | [prefer-screen-queries](docs/rules/prefer-screen-queries.md) | Suggest using screen while using queries | | | | [prefer-wait-for](docs/rules/prefer-wait-for.md) | Use `waitFor` instead of deprecated wait methods | | ![fixable-badge][] | -[build-badge]: https://img.shields.io/travis/testing-library/eslint-plugin-testing-library?style=flat-square -[build-url]: https://travis-ci.org/testing-library/eslint-plugin-testing-library +[build-badge]: https://github.com/testing-library/eslint-plugin-testing-library/actions/workflows/ci.yml/badge.svg +[build-url]: https://github.com/testing-library/eslint-plugin-testing-library/actions/workflows/ci.yml [version-badge]: https://img.shields.io/npm/v/eslint-plugin-testing-library?style=flat-square [version-url]: https://www.npmjs.com/package/eslint-plugin-testing-library [license-badge]: https://img.shields.io/npm/l/eslint-plugin-testing-library?style=flat-square diff --git a/package.json b/package.json index afd0dde4..4faa5a78 100644 --- a/package.json +++ b/package.json @@ -44,11 +44,10 @@ "lint": "eslint . --ext .js,.ts", "lint:fix": "npm run lint -- --fix", "format": "prettier --write README.md {lib,docs,tests}/**/*.{js,md}", - "test:local": "jest", - "test:ci": "jest --coverage", + "test": "jest", + "test:ci": "jest --ci --coverage", "test:update": "npm run test:local -- --u", "test:watch": "npm run test:local -- --watch", - "test": "is-ci test:ci test:local", "semantic-release": "semantic-release" }, "dependencies": { @@ -72,7 +71,6 @@ "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.1", "husky": "^4.3.0", - "is-ci-cli": "^2.1.2", "jest": "^25.5.4", "lint-staged": "^9.5.0", "prettier": "1.19.1", From 0fbb7f63c4e1ad62ef0b5e36f8bf87a0cbb74438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Tue, 16 Mar 2021 09:14:39 +0100 Subject: [PATCH 2/5] ci: github actions improvements (#288) * chore: fix scripts related to testing * ci: bump checkout action to v2 * ci: merge workflows files into single one * ci: add a step for canceling previous runs * ci: remove workflow run conditions * ci: rename workflow --- .github/workflows/ci.yml | 69 -------------------- .github/workflows/pipeline.yml | 114 +++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 44 ------------- package.json | 4 +- 4 files changed, 116 insertions(+), 115 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/pipeline.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 199da601..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: CI - -on: - push: - branches: - # semantic-release valid branches - - '+([0-9])?(.{+([0-9]),x}).x' - - 'main' - - 'next' - - 'next-major' - - 'beta' - - 'alpha' - pull_request: - types: [opened, synchronize] - -jobs: - code_validation: - name: Code Validation - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v1 - - - name: Use Node - uses: actions/setup-node@v2 - with: - node-version: '14' - - - name: Install dependencies - uses: bahmutov/npm-install@v1 - with: - useLockFile: false - - - name: Lint code - run: npm run lint - - # TODO: reenable on v4 -# - name: Check format -# run: npm run format:check - - test: - name: Tests (Node v${{ matrix.node }} - ESLint v${{ matrix.eslint }}) - runs-on: ubuntu-latest - - strategy: - matrix: - node: ['10.12', '10', '12.0', '12', '14'] - eslint: [5, 6, 7] - - steps: - - name: Checkout - uses: actions/checkout@v1 - - - name: Use Node - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node }} - - - name: Install dependencies - uses: bahmutov/npm-install@v1 - with: - useLockFile: false - - - name: Install ESLint v${{ matrix.eslint }} - run: npm install --no-save eslint@${{ matrix.eslint }} - - - name: Run tests - run: npm run test:ci diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml new file mode 100644 index 00000000..7a91b8b4 --- /dev/null +++ b/.github/workflows/pipeline.yml @@ -0,0 +1,114 @@ +name: Pipeline + +on: + push: + branches: + # semantic-release valid branches, excluding all-contributors + - '+([0-9])?(.{+([0-9]),x}).x' + - 'main' + - 'next' + - 'next-major' + - 'beta' + - 'alpha' + - '!all-contributors/**' + pull_request: + types: [ opened, synchronize ] + +jobs: + code_validation: + name: Code Validation + runs-on: ubuntu-latest + + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.6.0 + with: + access_token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout + uses: actions/checkout@v2 + + - name: Use Node + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Install dependencies + uses: bahmutov/npm-install@v1 + with: + useLockFile: false + + - name: Lint code + run: npm run lint + + # TODO: reenable on v4 + run tsc + # - name: Check format + # run: npm run format:check + + tests: + name: Tests (Node v${{ matrix.node }} - ESLint v${{ matrix.eslint }}) + runs-on: ubuntu-latest + + strategy: + matrix: + node: [ '10.12', '10', '12.0', '12', '14' ] + eslint: [ '5', '6', '7' ] + + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.6.0 + with: + access_token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout + uses: actions/checkout@v2 + + - name: Use Node + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + + - name: Install dependencies + uses: bahmutov/npm-install@v1 + with: + useLockFile: false + + - name: Install ESLint v${{ matrix.eslint }} + run: npm install --no-save eslint@${{ matrix.eslint }} + + - name: Run tests + run: npm run test:ci + + release: + name: NPM Release + needs: [code_validation, tests] + runs-on: ubuntu-latest + if: + ${{ github.repository == 'testing-library/eslint-plugin-testing-library' && + contains('refs/heads/main,refs/heads/beta,refs/heads/next,refs/heads/alpha', + github.ref) && github.event_name == 'push' }} + + steps: + - name: Cancel Previous Runs + uses: styfle/cancel-workflow-action@0.6.0 + with: + access_token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout + uses: actions/checkout@v2 + + - name: Use Node + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Install dependencies + uses: bahmutov/npm-install@v1 + with: + useLockFile: false + + - name: Build package + run: npm run build + + - name: Release new version to NPM + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx semantic-release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 4128186b..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Release - -on: - workflow_run: - workflows: ['CI'] - types: - - completed - push: - branches: - # semantic-release valid branches - - '+([0-9])?(.{+([0-9]),x}).x' - - 'main' - - 'next' - - 'next-major' - - 'beta' - - 'alpha' - -jobs: - main: - name: NPM Release - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v1 - - - name: Use Node - uses: actions/setup-node@v2 - with: - node-version: '14' - - - name: Install dependencies - uses: bahmutov/npm-install@v1 - with: - useLockFile: false - - - name: Build package - run: npm run build - - - name: Release new version to NPM - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npx semantic-release diff --git a/package.json b/package.json index 4faa5a78..ab457434 100644 --- a/package.json +++ b/package.json @@ -46,8 +46,8 @@ "format": "prettier --write README.md {lib,docs,tests}/**/*.{js,md}", "test": "jest", "test:ci": "jest --ci --coverage", - "test:update": "npm run test:local -- --u", - "test:watch": "npm run test:local -- --watch", + "test:update": "npm run test -- --u", + "test:watch": "npm run test -- --watch", "semantic-release": "semantic-release" }, "dependencies": { From 114159824acf4fa227f77681ffdc66ffbe831a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Tue, 16 Mar 2021 12:30:00 +0100 Subject: [PATCH 3/5] ci: update github actions with v4 CI changes --- .github/workflows/pipeline.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 7a91b8b4..ff3e46f0 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -24,6 +24,7 @@ jobs: uses: styfle/cancel-workflow-action@0.6.0 with: access_token: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout uses: actions/checkout@v2 @@ -37,12 +38,14 @@ jobs: with: useLockFile: false + - name: Check Types + run: npm run type-check + - name: Lint code run: npm run lint - # TODO: reenable on v4 + run tsc - # - name: Check format - # run: npm run format:check + - name: Check format + run: npm run format:check -- --max-warnings 0 tests: name: Tests (Node v${{ matrix.node }} - ESLint v${{ matrix.eslint }}) @@ -50,8 +53,8 @@ jobs: strategy: matrix: - node: [ '10.12', '10', '12.0', '12', '14' ] - eslint: [ '5', '6', '7' ] + node: [ '10.22.1', '10', '12', '14' ] + eslint: [ '7.5', '7', ] steps: - name: Cancel Previous Runs From 184ece8677682b2c1118e2506199f9f4ec2ef306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Tue, 16 Mar 2021 18:15:10 +0100 Subject: [PATCH 4/5] chore: bump dependencies to last minor --- package.json | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 9614d062..c862594d 100644 --- a/package.json +++ b/package.json @@ -53,35 +53,35 @@ "semantic-release": "semantic-release" }, "dependencies": { - "@typescript-eslint/experimental-utils": "^4.1.1" + "@typescript-eslint/experimental-utils": "^4.18.0" }, "devDependencies": { "@commitlint/cli": "^11.0.0", "@commitlint/config-conventional": "^11.0.0", - "@types/jest": "^26.0.14", - "@typescript-eslint/eslint-plugin": "^4.1.1", - "@typescript-eslint/parser": "^4.1.1", + "@types/jest": "^25.2.3", + "@typescript-eslint/eslint-plugin": "^4.18.0", + "@typescript-eslint/parser": "^4.18.0", "cpy-cli": "^3.1.1", "eslint": "^7.9.0", - "eslint-config-prettier": "^6.11.0", + "eslint-config-prettier": "^6.15.0", "eslint-config-standard": "^14.1.1", - "eslint-plugin-import": "^2.22.0", - "eslint-plugin-jest": "^24.0.2", - "eslint-plugin-jest-formatting": "^2.0.0", + "eslint-plugin-import": "^2.22.1", + "eslint-plugin-jest": "^24.3.1", + "eslint-plugin-jest-formatting": "^2.0.1", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-prettier": "^3.1.4", - "eslint-plugin-promise": "^4.2.1", - "eslint-plugin-standard": "^4.0.1", - "husky": "^4.3.0", - "jest": "^26.4.2", - "lint-staged": "^10.4.0", - "prettier": "2.1.2", - "semantic-release": "^17.1.2", - "ts-jest": "^26.4.0", - "typescript": "^4.0.3" + "eslint-plugin-prettier": "^3.3.1", + "eslint-plugin-promise": "^4.3.1", + "eslint-plugin-standard": "^4.1.0", + "husky": "^4.3.8", + "jest": "26.6.3", + "lint-staged": "^10.5.4", + "prettier": "2.2.1", + "semantic-release": "^17.4.2", + "ts-jest": "^26.5.3", + "typescript": "^4.2.3" }, "peerDependencies": { - "eslint": "^7.5.0" + "eslint": "^7.22.0" }, "engines": { "node": "^10.22.1 || >=12.0.0", From 9fa71471a3c73d9b518cc4bef9df5747f1adf131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Tue, 16 Mar 2021 18:33:59 +0100 Subject: [PATCH 5/5] chore: setting test environment to jest-environment-jsdom v25 I had to downgrade jsdom because of some errors jsdom v16 was causing when running tests in node v10. Apparently, jsdom v16 is compatible with node v10, so I'm not sure why is causing an issue. This can be removed when dropping support for node v10. --- jest.config.js | 3 ++- package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/jest.config.js b/jest.config.js index 17be2091..2385b99d 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,4 +1,5 @@ module.exports = { + testEnvironment: 'jest-environment-jsdom', testMatch: ['**/tests/**/*.test.ts'], transform: { '^.+\\.tsx?$': 'ts-jest', @@ -10,7 +11,7 @@ module.exports = { lines: 100, statements: 100, }, - // TODO drop this custom threshold in v4 + // TODO drop this custom threshold after v4 './lib/node-utils.ts': { branches: 85, functions: 90, diff --git a/package.json b/package.json index c862594d..50a8dac9 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "eslint-plugin-standard": "^4.1.0", "husky": "^4.3.8", "jest": "26.6.3", + "jest-environment-jsdom": "25", "lint-staged": "^10.5.4", "prettier": "2.2.1", "semantic-release": "^17.4.2",