-
Notifications
You must be signed in to change notification settings - Fork 261
160 lines (135 loc) · 5.11 KB
/
call.test-sdk-core.yml
File metadata and controls
160 lines (135 loc) · 5.11 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
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
name: Reusable Workflow | Test SDK Core
on:
workflow_call:
inputs:
subgraph-release:
required: true
type: string
subgraph-endpoint:
required: true
type: string
run-coverage-tests:
required: true
type: boolean
jobs:
# When this scrip is written, it is the only way to preparing conditional matrix:
# Ref: https://stackoverflow.com/questions/65384420/how-do-i-make-a-github-action-matrix-element-conditional
matrix-prep:
name: Preparing Conditional Strategy Matrix
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set matrix variable
id: set-matrix
run: |
if [ "${{ inputs.run-coverage-tests }}" == "true" ];then
echo "matrix={\"node-version\": [24]}" >> "$GITHUB_OUTPUT"
else
echo "matrix={\"node-version\": [20, 22, 24]}" >> "$GITHUB_OUTPUT"
fi
test-sdk-core:
name: Test SDK-Core
needs: [matrix-prep]
runs-on: ubuntu-22.04
strategy:
matrix: ${{ fromJson(needs.matrix-prep.outputs.matrix) }}
fail-fast: false
env:
DEV_SHELL_NAME: ci-node${{ matrix.node-version }}
ethereum-contracts-working-directory: ./packages/ethereum-contracts
subgraph-working-directory: ./packages/subgraph
sdk-core-working-directory: ./packages/sdk-core
defaults:
run:
shell: nix develop .#${{ env.DEV_SHELL_NAME }} -c bash -xe {0}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set cache key prefix
id: set-cache-key-prefix
run: |
if [ "${{ inputs.run-coverage-tests }}" == false ]; then
v=sdk-core-${{ env.DEV_SHELL_NAME }}-test-
else
v=sdk-core-${{ env.DEV_SHELL_NAME }}-coverage-
fi
echo "cache_key_prefix=$v" >> "$GITHUB_OUTPUT"
shell: bash
- name: Setup workflow base
id: base
uses: ./.github/actions/setup-workflow-base
with:
package-name: sdk-core
cache-key-prefix: ${{ steps.set-cache-key-prefix.outputs.cache_key_prefix }}
dev-shell-name: ${{ env.DEV_SHELL_NAME }}
- name: Install dependencies
if: steps.base.outputs.cache-hit != 'true'
run: |
yarn install --frozen-lockfile
npx tsc --version
npx hardhat --version
- name: Build contracts
if: steps.base.outputs.cache-hit != 'true'
run: |
yarn build
working-directory: ${{ env.ethereum-contracts-working-directory }}
- name: Build SDK Core
if: steps.base.outputs.cache-hit != 'true'
# build sdk-core because of auto linking to dependency
run: |
yarn lint
yarn build
working-directory: ${{ env.sdk-core-working-directory }}
- name: Start hardhat node
if: steps.base.outputs.cache-hit != 'true'
run: ./tasks/startHardhatNode.sh start
working-directory: ${{ env.sdk-core-working-directory }}
- name: Deploy framework and tokens
if: steps.base.outputs.cache-hit != 'true'
run: npx hardhat run dev-scripts/run-deploy-contracts-and-token.js --network localhost
working-directory: ${{ env.ethereum-contracts-working-directory }}
- name: Prepare files for local testing
if: steps.base.outputs.cache-hit != 'true'
run: yarn prepare-local
working-directory: ${{ env.subgraph-working-directory }}
- name: Setup graph node
if: steps.base.outputs.cache-hit != 'true'
run: |
./tasks/setup-graph-node.sh &
# wait for it to warm up
sleep 15
working-directory: ${{ env.subgraph-working-directory }}
- name: Build and deploy local subgraph
if: steps.base.outputs.cache-hit != 'true'
run: |
yarn build-and-deploy-local
# wait for it to sync
sleep 15
working-directory: ${{ env.subgraph-working-directory }}
- name: Run test suite
if: steps.base.outputs.cache-hit != 'true' && inputs.run-coverage-tests == false
run: |
yarn get-graphql-schema:${{ inputs.subgraph-release }}
./tasks/setupTestEnvironment.sh
npx hardhat test --network localhost
working-directory: ${{ env.sdk-core-working-directory }}
env:
SUBGRAPH_RELEASE_TAG: ${{ inputs.subgraph-release }}
SUBGRAPH_ENDPOINT: ${{ inputs.subgraph-endpoint }}
- name: Run coverage test
if: steps.base.outputs.cache-hit != 'true' && inputs.run-coverage-tests == true
run: |
yarn workspace @superfluid-finance/sdk-core test-coverage
working-directory: ${{ env.sdk-core-working-directory }}
env:
SUBGRAPH_RELEASE_TAG: ${{ inputs.subgraph-release }}
SUBGRAPH_ENDPOINT: ${{ inputs.subgraph-endpoint }}
- name: Create coverage artifact
if: inputs.run-coverage-tests == true
uses: actions/upload-artifact@v4
with:
name: sdk-core-coverage
path: |
packages/sdk-core/coverage/