-
Notifications
You must be signed in to change notification settings - Fork 125
164 lines (155 loc) · 4.94 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
name: CI & Release
# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
run-name: >-
${{
inputs.release && 'Publish to NPM' ||
''
}}
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
release:
description: 'Publish new release'
required: true
default: false
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read # for checkout
jobs:
build:
name: Lint and build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
node-version: lts/*
- run: npm ci
- run: npx ls-engines
- run: npm run prepublishOnly
- name: lint, prettier --check
run: npm run lint
- name: build:lib, test:integration
run: |
npm run build:lib
npm run test:integration
test:
needs: [build]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Run the testing suite on each major OS with the latest LTS release of Node.js
os: [macos-latest, ubuntu-latest, windows-latest]
node: [lts/*]
# It makes sense to also test the oldest, and latest, versions of Node.js, on ubuntu-only since it's the fastest CI runner
include:
- os: ubuntu-latest
# Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
node: lts/-2
- os: ubuntu-latest
# Also test the previous LTS release
node: lts/-1
- os: ubuntu-latest
# Test the actively developed version that will become the latest LTS release next October
node: current
# The `build` job already runs the testing suite in ubuntu and lts/*
exclude:
- os: ubuntu-latest
# Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
node: lts/*
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
node-version: ${{ matrix.node }}
- run: npm install
- run: npx ls-engines
- name: build:lib, test:integration
run: |
npm run build:lib
npm run test:integration
browser:
name: Test browser.js
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
node-version: lts/*
- run: npm ci
- name: build:browser.js, test:browser.js
run: |
npm run build:browser.js
npm run test:browser.js
e2e:
name: Run integration tests on real redis
runs-on: ubuntu-latest
services:
redis:
image: redis:7.2.0
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
node-version: lts/*
- run: npm ci
- name: test:e2e
run: npm run test:e2e -- --forceExit
# run: npm run test:e2e -- --openHandlesTimeout=60000
# timeout-minutes: 2
# - name: Find open handles
# if: failure()
# run: |
# npm run test:e2e -- --detectOpenHandles --forceExit
#env:
# DEBUG: ioredis:*
release:
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
needs: [build, test, browser, e2e]
# only run if opt-in during workflow_dispatch
if: github.event.inputs.release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Need to fetch entire commit history to
# analyze every commit since last release
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm
- run: npm ci --ignore-scripts
- run: npm audit signatures
# Branches that will release new versions are defined in .releaserc.json
- run: npx semantic-release
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
# e.g. git tags were pushed but it exited before `npm publish`
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}