Skip to content

Commit 0fbb7f6

Browse files
authored
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
1 parent 3c9f181 commit 0fbb7f6

File tree

4 files changed

+116
-115
lines changed

4 files changed

+116
-115
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 69 deletions
This file was deleted.

.github/workflows/pipeline.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
# semantic-release valid branches, excluding all-contributors
7+
- '+([0-9])?(.{+([0-9]),x}).x'
8+
- 'main'
9+
- 'next'
10+
- 'next-major'
11+
- 'beta'
12+
- 'alpha'
13+
- '!all-contributors/**'
14+
pull_request:
15+
types: [ opened, synchronize ]
16+
17+
jobs:
18+
code_validation:
19+
name: Code Validation
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Cancel Previous Runs
24+
uses: styfle/cancel-workflow-action@0.6.0
25+
with:
26+
access_token: ${{ secrets.GITHUB_TOKEN }}
27+
- name: Checkout
28+
uses: actions/checkout@v2
29+
30+
- name: Use Node
31+
uses: actions/setup-node@v2
32+
with:
33+
node-version: '14'
34+
35+
- name: Install dependencies
36+
uses: bahmutov/npm-install@v1
37+
with:
38+
useLockFile: false
39+
40+
- name: Lint code
41+
run: npm run lint
42+
43+
# TODO: reenable on v4 + run tsc
44+
# - name: Check format
45+
# run: npm run format:check
46+
47+
tests:
48+
name: Tests (Node v${{ matrix.node }} - ESLint v${{ matrix.eslint }})
49+
runs-on: ubuntu-latest
50+
51+
strategy:
52+
matrix:
53+
node: [ '10.12', '10', '12.0', '12', '14' ]
54+
eslint: [ '5', '6', '7' ]
55+
56+
steps:
57+
- name: Cancel Previous Runs
58+
uses: styfle/cancel-workflow-action@0.6.0
59+
with:
60+
access_token: ${{ secrets.GITHUB_TOKEN }}
61+
- name: Checkout
62+
uses: actions/checkout@v2
63+
64+
- name: Use Node
65+
uses: actions/setup-node@v2
66+
with:
67+
node-version: ${{ matrix.node }}
68+
69+
- name: Install dependencies
70+
uses: bahmutov/npm-install@v1
71+
with:
72+
useLockFile: false
73+
74+
- name: Install ESLint v${{ matrix.eslint }}
75+
run: npm install --no-save eslint@${{ matrix.eslint }}
76+
77+
- name: Run tests
78+
run: npm run test:ci
79+
80+
release:
81+
name: NPM Release
82+
needs: [code_validation, tests]
83+
runs-on: ubuntu-latest
84+
if:
85+
${{ github.repository == 'testing-library/eslint-plugin-testing-library' &&
86+
contains('refs/heads/main,refs/heads/beta,refs/heads/next,refs/heads/alpha',
87+
github.ref) && github.event_name == 'push' }}
88+
89+
steps:
90+
- name: Cancel Previous Runs
91+
uses: styfle/cancel-workflow-action@0.6.0
92+
with:
93+
access_token: ${{ secrets.GITHUB_TOKEN }}
94+
- name: Checkout
95+
uses: actions/checkout@v2
96+
97+
- name: Use Node
98+
uses: actions/setup-node@v2
99+
with:
100+
node-version: '14'
101+
102+
- name: Install dependencies
103+
uses: bahmutov/npm-install@v1
104+
with:
105+
useLockFile: false
106+
107+
- name: Build package
108+
run: npm run build
109+
110+
- name: Release new version to NPM
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
114+
run: npx semantic-release

.github/workflows/release.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
"format": "prettier --write README.md {lib,docs,tests}/**/*.{js,md}",
4747
"test": "jest",
4848
"test:ci": "jest --ci --coverage",
49-
"test:update": "npm run test:local -- --u",
50-
"test:watch": "npm run test:local -- --watch",
49+
"test:update": "npm run test -- --u",
50+
"test:watch": "npm run test -- --watch",
5151
"semantic-release": "semantic-release"
5252
},
5353
"dependencies": {

0 commit comments

Comments
 (0)