From f740836f6a33706fd5caa4930b0632ee41984ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Tue, 16 Mar 2021 18:41:33 +0100 Subject: [PATCH] ci: update pipeline with v4 changes (#289) * 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 * 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 * ci: update github actions with v4 CI changes * chore: bump dependencies to last minor * 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. --- .github/dependabot.yml | 7 ++ .github/workflows/pipeline.yml | 117 +++++++++++++++++++++++++++++++++ .travis.yml | 39 ----------- README.md | 4 +- jest.config.js | 3 +- package.json | 49 +++++++------- 6 files changed, 152 insertions(+), 67 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/pipeline.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/pipeline.yml b/.github/workflows/pipeline.yml new file mode 100644 index 00000000..ff3e46f0 --- /dev/null +++ b/.github/workflows/pipeline.yml @@ -0,0 +1,117 @@ +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: Check Types + run: npm run type-check + + - name: Lint code + run: npm run lint + + - name: Check format + run: npm run format:check -- --max-warnings 0 + + tests: + name: Tests (Node v${{ matrix.node }} - ESLint v${{ matrix.eslint }}) + runs-on: ubuntu-latest + + strategy: + matrix: + node: [ '10.22.1', '10', '12', '14' ] + eslint: [ '7.5', '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/.travis.yml b/.travis.yml deleted file mode 100644 index 403b21a5..00000000 --- a/.travis.yml +++ /dev/null @@ -1,39 +0,0 @@ -language: node_js - -env: - global: - - FORCE_COLOR=true - matrix: - - ESLINT=7.5 - - ESLINT=7 - -node_js: - - 10.22.1 - - 10 - - 12.0 - - 12 - - 14 - -before_script: - - 'if [ -n "${ESLINT-}" ]; then npm install --no-save "eslint@${ESLINT}" ; fi' - -jobs: - include: - - stage: validation - node_js: 14 - env: ESLINT=7 - script: - - npm run format:check - - npm run lint -- --max-warnings 0 - - 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 58cb3d52..ed63fe72 100644 --- a/README.md +++ b/README.md @@ -153,8 +153,8 @@ To enable this configuration use the `extends` property in your | [prefer-wait-for](docs/rules/prefer-wait-for.md) | Use `waitFor` instead of deprecated wait methods | | ![fixable-badge][] | | [render-result-naming-convention](docs/rules/render-result-naming-convention.md) | Enforce a valid naming for return value from `render` | ![angular-badge][] ![react-badge][] ![vue-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/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 f35e4447..50a8dac9 100644 --- a/package.json +++ b/package.json @@ -45,45 +45,44 @@ "lint:fix": "npm run lint -- --fix", "format": "prettier --write README.md \"{lib,docs,tests}/**/*.{js,ts,md}\"", "format:check": "prettier --check README.md \"{lib,docs,tests}/**/*.{js,json,yml,ts,md}\"", - "test:local": "jest", - "test:ci": "jest --coverage", - "test:update": "npm run test:local -- --u", - "test:watch": "npm run test:local -- --watch", - "test": "is-ci test:ci test:local", + "test": "jest", + "test:ci": "jest --ci --coverage", + "test:update": "npm run test -- --u", + "test:watch": "npm run test -- --watch", "type-check": "tsc --noEmit", "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", - "is-ci-cli": "^2.1.2", - "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", + "jest-environment-jsdom": "25", + "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",