-
Notifications
You must be signed in to change notification settings - Fork 15
135 lines (125 loc) · 4.77 KB
/
Copy pathtests.yml
File metadata and controls
135 lines (125 loc) · 4.77 KB
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
# This is a basic workflow to help you get started with Actions
name: Server CI/CD v1
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- master
pull_request:
branches:
- master
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
setup:
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'] }}
wallet-chunk-id: ${{ steps['set-test-chunk-ids'].outputs['wallet-chunk-id'] }}
steps:
- uses: actions/checkout@v3
- id: set-test-chunks
name: Set Chunks
run: echo "test-chunks=$(find ./src -path \*/__tests__/*.js | sort | jq -R -s -c 'split("\n")[:-1] | map(select(contains("__util") == false))' | jq -cM '[_nwise(length / 5 | floor)]')" >> $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
echo "wallet-chunk-id=$(echo $CHUNKS | jq -cM 'to_entries | map(select(.value | .[] | index("blockchain"))) | map(.key) | unique')" >> $GITHUB_OUTPUT
env:
CHUNKS: ${{ steps['set-test-chunks'].outputs['test-chunks'] }}
test:
name: Unit Tests
needs:
- setup
strategy:
matrix:
chunk: ${{ fromJson(needs.setup.outputs['test-chunk-ids']) }}
if: "github.event_name != 'workflow_dispatch' && !contains(github.event.head_commit.message,'skip ci') && !contains(github.event.head_commit.message,'skip build')"
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
KMS_KEYS_TAG: 'Environment=Test'
ADMIN_PASS: test
JWT_PASS: test
TRAVIS: true
NETWORK: dapptest
MNEMONIC: 'test test test test test test test test test test test junk'
ADMIN_MNEMONIC: 'test test test test test test test test test test test junk'
ALCHEMY_API: ${{ secrets.ALCHEMY_API }}
AWS_SES_ACCESS_KEY: ${{ secrets.AWS_SES_ACCESS_KEY }}
AWS_SES_SECRET_ACCESS_KEY: ${{ secrets.AWS_SES_SECRET_ACCESS_KEY }}
CF_WORKER_VERIFY_JWT_SECRET: ${{ secrets.CF_WORKER_VERIFY_JWT_SECRET }}
MAUTIC_TOKEN: ${{ secrets.MAUTIC_TOKEN }}
MAUTIC_BASIC_TOKEN: ${{ secrets.MAUTIC_BASIC_TOKEN }}
CI: false
LOG_LEVEL: error
CHUNKS: ${{ needs.setup.outputs['test-chunks'] }}
BLOCKCHAIN_CHUNKS: ${{ needs.setup.outputs['wallet-chunk-id'] }}
MONGO_DB_URI: ${{ secrets.MONGO_DB_URI }}
runs-on: ubuntu-latest
steps:
- run: corepack enable
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- run: npm i -g patch-package
- name: Install npm dependencies
uses: bahmutov/npm-install@v1
- name: prepare blockchain for blockchain related tests
if: contains(fromJson(env.BLOCKCHAIN_CHUNKS),matrix.chunk)
env:
MNEMONIC: ${{ env.ADMIN_MNEMONIC }}
run: npm run test:setup
- name: prepare blockchain for generic tests
if: '!contains(fromJson(env.BLOCKCHAIN_CHUNKS) ,matrix.chunk)'
run: |
npx ganache-cli -p 8545 &
sleep 30
- name: run tests and code coverage
env:
MNEMONIC: ${{ env.ADMIN_MNEMONIC }}
run: |
echo "using mnemonic for admin: ${MNEMONIC}"
echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | @text' | xargs npm run coverage
# npm run test -- src/server/send/__tests__/sendAPI.js
# npm run coverage -- --silent
# npm run coveralls
pkill -f ganache || true
# - name: Coveralls
# uses: coverallsapp/github-action@master
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# parallel: true
# flag-name: run-${{ matrix.chunk }}
test-build:
needs: test
runs-on: ubuntu-latest
env:
# avoids using sentry in build
TRAVIS: true
steps:
- run: corepack enable
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- run: npm i -g patch-package
- name: Install npm dependencies
uses: bahmutov/npm-install@v1
- name: Build
run: npm run build
# coverage:
# needs: test
# runs-on: ubuntu-latest
# steps:
# - name: Coveralls Finished
# uses: coverallsapp/github-action@master
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# parallel-finished: true