-
Notifications
You must be signed in to change notification settings - Fork 8
167 lines (138 loc) · 4.24 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '15 0 * * *'
permissions:
contents: read
defaults:
run:
shell: bash
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [14, 16, 18, 20, 22]
coverage: [true]
include:
- os: ubuntu-latest
node-version: 12
coverage: false
- os: windows-latest
node-version: 12
coverage: false
exclude:
# macos-latest is now ARM, so exclude Node 12/14
- os: macos-latest
node-version: 14
runs-on: ${{ matrix.os }}
env:
OS: ${{ matrix.os }}
NODE: ${{ matrix.node-version }}
name: Test on ${{ matrix.os }} with Node.js ${{ matrix.node-version }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '*'
- run: npm ci
if: ${{ github.event_name != 'schedule' }}
- shell: bash
run: |
npm install -g $(jq -r '.packageManager' < package.json)
rm package-lock.json
npm i
if: ${{ github.event_name == 'schedule' }}
- run: npm run build
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ matrix.node-version }}
check-latest: true
- run: npm run test
if: ${{ ! matrix.coverage }}
- run: npm run coverage
if: ${{ matrix.coverage }}
- uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5.1.2
if: ${{ matrix.coverage && github.event_name != 'schedule' }}
continue-on-error: true
timeout-minutes: 5
with:
token: ${{ secrets.CODECOV_TOKEN }}
env_vars: OS,NODE
files: ./coverage/codecov.json
eslint:
name: ESLint
runs-on: ubuntu-latest
if: ${{ github.event_name != 'schedule' }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '*'
- run: npm ci
- run: npx eslint .
dprint:
name: dprint
runs-on: ubuntu-latest
if: ${{ github.event_name != 'schedule' }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '*'
- run: npm ci
- run: npx dprint check
check-latest:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
name: Check latest on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: '*'
- run: npm ci
- run: npm pack
- run: npm install -g hereby
- run: |
set -exo pipefail
WORKSPACE=$PWD
cd $(mktemp -d)
npm init -y
npm install $WORKSPACE/*.tgz
cp $WORKSPACE/dist/__tests__/cli/__fixtures__/Herebyfile.mjs .
hereby --tasks
name: Verify that latest hereby can run local hereby
- run: |
set -exo pipefail
WORKSPACE=$PWD
cd $(mktemp -d)
npm init -y
npm install hereby
cp $WORKSPACE/dist/__tests__/cli/__fixtures__/Herebyfile.mjs .
node $WORKSPACE/bin/hereby.js --tasks
name: Verify that local hereby can run latest hereby
required:
runs-on: ubuntu-latest
if: ${{ always() }}
needs:
- test
- eslint
- dprint
- check-latest
steps:
- name: Check required jobs
env:
NEEDS: ${{ toJson(needs) }}
run: |
! echo $NEEDS | jq -e 'to_entries[] | { job: .key, result: .value.result } | select(.result == "success" or .result == "skipped" | not)'