-
-
Notifications
You must be signed in to change notification settings - Fork 58
188 lines (160 loc) · 5.7 KB
/
ci-tests.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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: CI
on:
push:
branches:
- master
- 4.0.x
tags: # for automatic releases
# normal versions
- "v[0-9]+.[0-9]+.[0-9]+"
# pre-releases
- "v[0-9]+.[0-9]+.[0-9]+-**"
pull_request:
schedule:
- cron: '0 0 * * 0' # weekly
# Cancel previous PR/branch runs when a new commit is pushed
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Eslint
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: NPM install
run: npm i --ignore-scripts # install typescript and @types do not `setup first`
- name: Eslint
run: npm run lint
ci:
name: ${{ matrix.os }} on node v${{ matrix.node }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-20.04, macos-latest]
node: [18, 20]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Prepare installation (Linux)
if: ${{ matrix.os == 'ubuntu-20.04' }}
uses: ./.github/actions/install-redis-linux
- name: Prepare installation (MacOS)
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew update
# temporary ignore brew problems
brew install redis
brew services start redis
- name: Prepare installation (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
choco install redis-64 --version 3.0.503
powershell "Start-Process redis-server.exe -PassThru"
- name: NPM version
run: npm -v
- name: Install dependencies
run: npm ci --ignore-scripts # install typescript and @types do not `setup first`
- name: Build TS files
run: npm run build
- name: Run scripts
run: npm run preinstall && npm run install
- name: Execute Type Tests
run: npm run test-types
- name: Execute Standard Tests
run: npm test
- name: Execute Jsonl Tests
run: npm run test-jsonl
- name: Redis Socket/Sentinel Tests (Linux)
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: |
sudo chmod ogu+x packages/controller/test/redis-socket/setup-socket.sh
sudo chmod ogu+x packages/controller/test/redis-sentinel/*.sh
packages/controller/test/redis-socket/setup-socket.sh
cd packages/controller/test/redis-sentinel
./test-sentinel.sh
auto-merge:
if: |
always() &&
github.event_name == 'pull_request'
needs: [ ci ]
runs-on: ubuntu-latest
steps:
- id: automerge
name: automerge
uses: "pascalgn/[email protected]"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
MERGE_LABELS: "automated pr"
MERGE_FILTER_AUTHOR: "foxriver76"
MERGE_FORKS: "false"
MERGE_DELETE_BRANCH: "false"
UPDATE_LABELS: "automated pr"
MERGE_METHOD: "squash"
- name: Checkout repository
if: steps.automerge.outputs.mergeResult == 'merged'
uses: actions/checkout@v4
- name: Use Node.js 18
if: steps.automerge.outputs.mergeResult == 'merged'
uses: actions/setup-node@v4
with:
node-version: 18
- name: Determine version
if: steps.automerge.outputs.mergeResult == 'merged'
id: version
uses: actions/github-script@v7
with:
result-encoding: string
script: |
return require(`${process.env.GITHUB_WORKSPACE}/lerna.json`).version;
- name: Install dependencies
if: steps.automerge.outputs.mergeResult == 'merged'
run: npm ci --ignore-scripts # install typescript and @types do not `setup first`
- name: Build TS files
if: steps.automerge.outputs.mergeResult == 'merged'
run: npm run build
- name: Publish npm
if: steps.automerge.outputs.mergeResult == 'merged'
env:
PRERELEASE: ${{ contains(steps.version.outputs.result, '-') }}
run: |
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
npm whoami
if [[ "$PRERELEASE" == "true" ]]; then
npx lerna publish from-package --yes --dist-tag dev
else
npx lerna publish from-package --yes
fi
- name: Create Github Release
if: steps.automerge.outputs.mergeResult == 'merged'
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: v${{ steps.version.outputs.result }}
name: Release v${{ steps.version.outputs.result }}
draft: false
prerelease: ${{ contains(steps.version.outputs.result, '-') }}
body: "${{ contains(steps.version.outputs.result, '-') && 'nightly release' || 'official release' }}"
- name: Notify Sentry.io about the release
if: steps.automerge.outputs.mergeResult == 'merged'
env:
VERSION: ${{ steps.version.outputs.result }}
run: |
npm i -g @sentry/cli
export SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
export SENTRY_URL=https://sentry.iobroker.net
export SENTRY_ORG=iobroker
export SENTRY_PROJECT=iobroker-js-controller
export SENTRY_VERSION=iobroker.js-controller@${VERSION}
sentry-cli releases new $SENTRY_VERSION
sentry-cli releases set-commits $SENTRY_VERSION --auto
sentry-cli releases finalize $SENTRY_VERSION