-
Notifications
You must be signed in to change notification settings - Fork 1
154 lines (133 loc) · 4.52 KB
/
contracts.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
name: contract tests
on:
push:
paths:
- package.json
- 'upa/**'
- .github/workflows/contracts.yml
concurrency:
cancel-in-progress: true
group: ${{github.workflow}}-${{github.ref}}
jobs:
start-runner:
name: Start EC2 runner
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.AWS_GITHUB_TOKEN }}
# This image is the base AL2023 AMI plus yarn and gcc, and
# with github.com added to `~/.ssh/known_hosts`.
ec2-image-id: ${{ vars.EC2_IMAGE_ID }}
ec2-instance-type: c7a.xlarge
subnet-id: ${{ vars.SUBNET_ID }}
security-group-id: ${{ vars.SECURITY_GROUP_ID }}
sdk-tests:
needs: start-runner # required to start the main job when the runner is ready.
runs-on: ${{ needs.start-runner.outputs.label }}
defaults:
run:
working-directory: upa
strategy:
fail-fast: true
matrix:
node-version: [20]
steps:
- name: Checkout
uses: actions/checkout@v3
# For EC2 runner
- name: Set HOME env variable
run: |
echo "HOME=/root" >> ${GITHUB_ENV}
# For EC2 runner
- name: Add pre-installed yarn executable to github path.
run: |
echo "$HOME/.nvm/versions/node/v20.11.0/bin" >> ${GITHUB_PATH}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
# Based on https://github.com/actions/cache/blob/main/examples.md#node---yarn-2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
.yarn
node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# If the cache is empty, fetch modules, else run immutable.
- if: steps.yarn-cache.outputs.cache-hit != 'true'
run: |
yarn
- if: steps.yarn-cache.outputs.cache-hit == 'true'
run: |
yarn install --immutable --immutable-cache
- name: code check
run: |
yarn lint
- name: format check
run: |
yarn run format
git diff --no-ext-diff --ignore-cr-at-eol -- **.ts > format.diff
echo "DIFF:" && cat format.diff
! [ -s format.diff ]
- name: run slither
run: |
yarn slither
- name: build
run: |
yarn build
- name: run contract and typescript tests
run: |
yarn test
- name: run test_upa
run: |
./scripts/test_upa
- name: run test_challenge
run: |
./scripts/test_challenge
- name: run test_dev_aggregator
run: |
./scripts/test_dev_aggregator
- name: run package test
run: |
./scripts/test_package
stop-runner:
name: Stop EC2 runner
needs:
- start-runner
- sdk-tests
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if an error happened in the previous jobs
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.AWS_GITHUB_TOKEN }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}