Skip to content

Commit

Permalink
ci: github actions improvements (#288)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Belco90 authored Mar 16, 2021
1 parent 3c9f181 commit 0fbb7f6
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 115 deletions.
69 changes: 0 additions & 69 deletions .github/workflows/ci.yml

This file was deleted.

114 changes: 114 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -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
44 changes: 0 additions & 44 deletions .github/workflows/release.yml

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 0fbb7f6

Please sign in to comment.