-
Notifications
You must be signed in to change notification settings - Fork 31
129 lines (125 loc) · 4.29 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
name: Lint, build and test
on: [push]
jobs:
linting:
name: eslint, stylelint
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
# common steps
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
# job specific steps
- name: Run ESlint
run: npm run eslint
- name: Run Stylelint
run: npm run stylelint
- name: Hadolint for linting Dockerfile
uses: hadolint/[email protected]
with:
dockerfile: ./Dockerfile
config: ./.hadolint.yaml
jestSetup:
name: 'Set up jest chunks'
runs-on: ubuntu-latest
outputs:
test-chunks: ${{ steps['set-test-chunks'].outputs['test-chunks'] }}
test-chunk-ids: ${{ steps['set-test-chunk-ids'].outputs['test-chunk-ids'] }}
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm ci
- id: set-test-chunks
name: Set Chunks
run: echo "test-chunks=$(npx jest --listTests --json | jq -cM '[_nwise(length / 5 | ceil)]')" >> $GITHUB_OUTPUT
- id: set-test-chunk-ids
name: Set Chunk IDs
run: echo "test-chunk-ids=$(echo $CHUNKS | jq -cM 'to_entries | map(.key)')" >> $GITHUB_OUTPUT
env:
CHUNKS: ${{ steps['set-test-chunks'].outputs['test-chunks'] }}
jest:
name: Jest Tests (chunk ${{ matrix.chunk }})
runs-on: ubuntu-latest
needs:
- jestSetup
strategy:
fail-fast: false
matrix:
node-version: [18.x]
chunk: ${{ fromJson(needs.jestSetup.outputs['test-chunk-ids']) }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Start Streamr Docker Stack
uses: streamr-dev/[email protected]
with:
services-to-start: "cassandra mysql nginx entry-point broker-node-storage-1 broker-node-no-storage-1 broker-node-no-storage-2 dev-chain-fast postgres-fastchain"
- name: Run Jest Tests
run: echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | @text' | xargs npx jest --verbose --useStderr --forceExit --coverage=false --logHeapUsage --runInBand
env:
CHUNKS: ${{ needs.jestSetup.outputs['test-chunks'] }}
TEST_HOOKS: 1
cypress:
# It takes time and often fails. @todo make it more reliable, then re-enable.
if: ${{ false }}
name: Cypress Tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
# common steps
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
npm ci
- name: Cache node modules
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache Cypress binary
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: cypress-${{ runner.os }}-cypress-${{ hashFiles('package-lock.json') }}
restore-keys: |
cypress-${{ runner.os }}-cypress-
# job specific steps
- name: Build app
run: npm run build
- name: Start Streamr Docker Stack
uses: streamr-dev/[email protected]
with:
services-to-start: "mysql cassandra parity-node0 parity-sidechain-node0 broker-node-storage-1-brubeck nginx"
- name: Run Cypress tests
uses: cypress-io/github-action@v6
with:
browser: chrome
# Start serving 'dist' folder from previous build step
start: npx serve dist --listen 3333 --single
wait-on: "http://localhost"
wait-on-timeout: 120
- uses: actions/upload-artifact@master
with:
name: screenshots
path:
cypress/screenshots