Skip to content

Commit 392109c

Browse files
committed
fix: improve automation
1 parent 346dad7 commit 392109c

File tree

15 files changed

+27525
-11926
lines changed

15 files changed

+27525
-11926
lines changed

.circleci/config.yml

-32
This file was deleted.

.github/workflows/ci.yml

+103-28
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,82 @@
1-
name: CI
1+
name: CI & Release
2+
3+
# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
4+
run-name: >-
5+
${{
6+
inputs.release && 'Publish to NPM' ||
7+
''
8+
}}
29
310
on:
411
push:
512
branches:
613
- main
714
pull_request:
8-
branches:
9-
- main
15+
workflow_dispatch:
16+
inputs:
17+
release:
18+
description: 'Publish new release'
19+
required: true
20+
default: false
21+
type: boolean
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
25+
cancel-in-progress: true
1026

1127
jobs:
1228
build:
1329
name: Lint and build
1430
runs-on: ubuntu-latest
1531
steps:
16-
- uses: actions/checkout@master
17-
- uses: actions/setup-node@master
18-
- name: Install dependencies
19-
run: npm ci
32+
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
33+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
34+
with:
35+
cache: npm
36+
node-version: lts/*
37+
- run: npm ci
38+
- run: npx ls-engines
39+
- run: npm run prepublishOnly
2040
- name: lint, prettier --check
2141
run: npm run lint
42+
- name: build:lib, test:integration
43+
run: |
44+
npm run build:lib
45+
npm run test:integration
46+
2247
test:
23-
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
24-
runs-on: ${{ matrix.os }}
2548
needs: [build]
49+
runs-on: ${{ matrix.os }}
2650
strategy:
51+
fail-fast: false
2752
matrix:
28-
node_version: [12, 14, 16, 17]
29-
# @TODO figure out why windows-latest is hanging so mcuh
30-
#os: [ubuntu-latest, windows-latest, macOS-latest]
31-
os: [ubuntu-latest, macOS-latest]
32-
53+
# Run the testing suite on each major OS with the latest LTS release of Node.js
54+
os: [macos-latest, ubuntu-latest, windows-latest]
55+
node: [lts/*]
56+
# It makes sense to also test the oldest, and latest, versions of Node.js, on ubuntu-only since it's the fastest CI runner
57+
include:
58+
- os: ubuntu-latest
59+
# Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
60+
node: lts/-2
61+
- os: ubuntu-latest
62+
# Also test the previous LTS release
63+
node: lts/-1
64+
- os: ubuntu-latest
65+
# Test the actively developed version that will become the latest LTS release next October
66+
node: current
67+
# The `build` job already runs the testing suite in ubuntu and lts/*
68+
exclude:
69+
- os: ubuntu-latest
70+
# Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
71+
node: lts/*
3372
steps:
34-
- uses: actions/checkout@master
35-
- name: Use Node.js ${{ matrix.node_version }}
36-
uses: actions/setup-node@master
73+
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
74+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
3775
with:
38-
node-version: ${{ matrix.node_version }}
39-
- name: Install dependencies
40-
run: npm ci
76+
cache: npm
77+
node-version: ${{ matrix.node }}
78+
- run: npm install
79+
- run: npx ls-engines
4180
- name: build:lib, test:integration
4281
run: |
4382
npm run build:lib
@@ -48,10 +87,12 @@ jobs:
4887
runs-on: ubuntu-latest
4988
needs: [build]
5089
steps:
51-
- uses: actions/checkout@master
52-
- uses: actions/setup-node@master
53-
- name: Install dependencies
54-
run: npm ci
90+
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
91+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
92+
with:
93+
cache: npm
94+
node-version: lts/*
95+
- run: npm ci
5596
- name: build:browser.js, test:browser.js
5697
run: |
5798
npm run build:browser.js
@@ -72,9 +113,43 @@ jobs:
72113
ports:
73114
- 6379:6379
74115
steps:
75-
- uses: actions/checkout@master
76-
- uses: actions/setup-node@master
77-
- name: Install dependencies
78-
run: npm ci
116+
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
117+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
118+
with:
119+
cache: npm
120+
node-version: lts/*
121+
- run: npm ci
79122
- name: test:e2e
80123
run: npm run test:e2e -- --detectOpenHandles
124+
125+
release:
126+
needs: [build, test, browser, e2e]
127+
# only run if opt-in during workflow_dispatch
128+
if: github.event.inputs.release == 'true'
129+
runs-on: ubuntu-latest
130+
steps:
131+
- uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
132+
with:
133+
# Need to fetch entire commit history to
134+
# analyze every commit since last release
135+
fetch-depth: 0
136+
- uses: actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
137+
with:
138+
node-version: lts/*
139+
cache: npm
140+
- run: npm ci --ignore-scripts
141+
# Branches that will release new versions are defined in .releaserc.json
142+
- run: npx semantic-release
143+
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
144+
# e.g. git tags were pushed but it exited before `npm publish`
145+
if: always()
146+
env:
147+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
149+
# Re-run semantic release with rich logs if it failed to publish for easier debugging
150+
- run: npx semantic-release --dry-run --debug
151+
if: failure()
152+
env:
153+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
154+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
155+

.github/workflows/coveralls.yml

+3-8
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ on:
33
branches:
44
- main
55
pull_request:
6-
branches:
7-
- main
86

97
name: Test Coveralls
108

@@ -14,17 +12,14 @@ jobs:
1412
runs-on: ubuntu-latest
1513
steps:
1614
- uses: actions/checkout@v3
17-
18-
- name: Use Node.js 12.x
19-
uses: actions/setup-node@v3
15+
- uses: actions/setup-node@v3
2016
with:
21-
node-version: 12.x
22-
17+
cache: npm
18+
node-version: lts/*
2319
- name: npm install, make test-coverage
2420
run: |
2521
npm ci
2622
npm run coverage
27-
2823
- name: Coveralls
2924
uses: coverallsapp/github-action@master
3025
with:

.github/workflows/prettier.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: Prettier
3+
4+
on:
5+
push:
6+
branches: [main]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
run:
14+
name: Can the code be prettier? 🤔
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-node@v3
19+
with:
20+
cache: npm
21+
node-version: lts/*
22+
- run: npm ci --ignore-scripts --only-dev
23+
- uses: actions/cache@v3
24+
with:
25+
path: node_modules/.cache/prettier/.prettier-cache
26+
key: prettier-${{ hashFiles('package-lock.json') }}-${{ hashFiles('.gitignore') }}
27+
- run: npx prettier --ignore-path .gitignore --cache --write .
28+
- run: git restore .github/workflows
29+
- uses: EndBug/add-and-commit@v9
30+
with:
31+
default_author: github_actions
32+
commit: --no-verify
33+
message: 'chore(prettier): 🤖 ✨'

.github/workflows/updatecompat.yml

+14-24
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,26 @@
11
name: Update compat.md
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
4+
push:
5+
branches: [main]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}
9+
cancel-in-progress: true
710

811
jobs:
912
format:
10-
if: github.repository == 'stipsan/ioredis-mock'
13+
name: Should compat.md be updated? 🤔
1114
runs-on: ubuntu-latest
12-
1315
steps:
1416
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
1518
with:
16-
repository: ${{ github.event.pull_request.head.repo.full_name }}
17-
ref: ${{github.head_ref}}
18-
- name: use node.js 16
19-
uses: actions/setup-node@v3
20-
with:
21-
node-version: 16
22-
- run: npm ci
19+
cache: npm
20+
node-version: lts/*
2321
- run: node scripts/update-compat
24-
- name: commit changes
25-
run: |
26-
git config --local user.email "[email protected]"
27-
git config --local user.name "GitHub Action"
28-
git add compat.md
29-
git commit -m "docs: update feature compat table"
30-
continue-on-error: true
31-
- name: push changes
32-
uses: ad-m/github-push-action@master
22+
- uses: EndBug/add-and-commit@v9
3323
with:
34-
branch: ${{github.head_ref}}
35-
repository: ${{ github.event.pull_request.head.repo.full_name }}
36-
github_token: ${{ secrets.GITHUB_TOKEN }}
24+
default_author: github_actions
25+
commit: --no-verify
26+
message: 'docs(compat.md): 🤖 ✨'

.releaserc.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "@sanity/semantic-release-preset",
3+
"branches": ["main"]
4+
}

data/command-docs.json

+1-1
Large diffs are not rendered by default.

data/command-info.json

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)