-
Notifications
You must be signed in to change notification settings - Fork 20
175 lines (146 loc) · 6.6 KB
/
ci-code-review-ts.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
name: Code Review - TypeScript
on:
pull_request:
branches: ['main']
paths: ['client/ts/**', 'yarn.lock']
push:
branches: ['main']
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
SOLANA_VERSION: '1.18.22'
RUST_TOOLCHAIN: '1.78.0'
jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Format
run: yarn format
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Lint
run: yarn lint
depcheck:
name: Dependency check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'
- name: Duplicates check
run: npx yarn-deduplicate --list --fail
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Cache dependencies
uses: Swatinem/rust-cache@v2
- name: Set Rust version
run: rustup toolchain install ${{ env.RUST_TOOLCHAIN }}
- name: Install Solana
run: |
sh -c "$(curl -sSfL https://release.solana.com/v${{ env.SOLANA_VERSION }}/install)"
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
solana --version
echo "Generating keypair..."
solana-keygen new -o "$HOME/.config/solana/id.json" --no-passphrase --silent
- name: Start validator
run: |
solana-test-validator > /dev/null 2>&1 &
echo "Started test validator, sleeping for 15 seconds before starting"
sleep 15
echo "Updating hardcoded discriminant constants for the hardcoded deploy key"
sed -i 's/MNFSTqtC93rEfYHB6hF82sKdZpUDFWkViLByLd1k1Ms/bitpRsDktxXjwcQvx11p3JZ4A8ucwM1AYBgjNfhr3yf/' programs/manifest/src/lib.rs
sed -i 's/4859840929024028656/15533312255830019719/' programs/manifest/src/validation/manifest_checker.rs
sed -i 's/\[33, 31, 11, 6, 133, 143, 39, 71\]/[228, 66, 25, 184, 68, 250, 83, 68]/' programs/manifest/src/logs.rs
sed -i 's/\[129, 77, 152, 210, 218, 144, 163, 56\]/[83, 80, 13, 195, 157, 15, 144, 87]/' programs/manifest/src/logs.rs
sed -i 's/\[23, 214, 24, 34, 52, 104, 109, 188\]/[67, 61, 36, 241, 56, 245, 238, 146]/' programs/manifest/src/logs.rs
sed -i 's/\[112, 218, 111, 63, 18, 95, 136, 35\]/[216, 76, 133, 25, 77, 4, 208, 169]/' programs/manifest/src/logs.rs
sed -i 's/\[58, 230, 242, 3, 75, 113, 4, 169\]/[52, 81, 147, 82, 119, 191, 72, 172]/' programs/manifest/src/logs.rs
sed -i 's/\[157, 118, 247, 213, 47, 19, 164, 120\]/[192, 6, 190, 126, 253, 107, 243, 124]/' programs/manifest/src/logs.rs
sed -i 's/\[22, 65, 71, 33, 244, 235, 255, 215\]/[203, 247, 55, 164, 199, 233, 155, 33]/' programs/manifest/src/logs.rs
mkdir -p target/deploy
echo "[151,8,48,152,68,30,226,198,60,77,31,58,178,181,32,89,229,203,74,21,125,127,220,171,148,2,58,248,111,112,218,58,8,229,29,213,101,63,98,202,13,39,74,3,188,95,195,65,60,246,83,247,221,124,176,114,136,100,191,104,177,76,52,70]" > target/deploy/manifest-keypair.json
cargo build-sbf
echo "Rebuilt program"
rm target/deploy/manifest-keypair.json
touch target/deploy/manifest-keypair.json
echo "[151,8,48,152,68,30,226,198,60,77,31,58,178,181,32,89,229,203,74,21,125,127,220,171,148,2,58,248,111,112,218,58,8,229,29,213,101,63,98,202,13,39,74,3,188,95,195,65,60,246,83,247,221,124,176,114,136,100,191,104,177,76,52,70]" > target/deploy/manifest-keypair.json
solana config set --url l
solana program deploy target/deploy/manifest.so > deploy.log
cat deploy.log
solana program deploy target/deploy/wrapper.so > deploy.log
cat deploy.log
sed -i 's/'$(awk -F\" '/declare_id!/ {print$2}' programs/wrapper/src/lib.rs)'/'$(awk '/Program Id:/ {print$3}' deploy.log)'/' client/ts/src/wrapper/index.ts
for f in $(ls client/ts/src/wrapper/instructions); do
sed -i 's/'$(awk -F\" '/declare_id!/ {print$2}' programs/wrapper/src/lib.rs)'/'$(awk '/Program Id:/ {print$3}' deploy.log)'/' client/ts/src/wrapper/instructions/$f
echo "Updated -> $f"
done
sed -i 's/'$(awk -F\" '/declare_id!/ {print$2}' programs/wrapper/src/lib.rs)'/'$(awk '/Program Id:/ {print$3}' deploy.log)'/' client/ts/src/wrapper/instructions/*
sed -i 's/'$(awk -F\" '/declare_id!/ {print$2}' programs/wrapper/src/lib.rs)'/'$(awk '/Program Id:/ {print$3}' deploy.log)'/' programs/wrapper/src/lib.rs
for f in $(ls client/ts/src/manifest/instructions); do
sed -i 's/MNFSTqtC93rEfYHB6hF82sKdZpUDFWkViLByLd1k1Ms/bitpRsDktxXjwcQvx11p3JZ4A8ucwM1AYBgjNfhr3yf/' client/ts/src/manifest/instructions/$f
echo "Updated -> $f"
done
sed -i 's/MNFSTqtC93rEfYHB6hF82sKdZpUDFWkViLByLd1k1Ms/bitpRsDktxXjwcQvx11p3JZ4A8ucwM1AYBgjNfhr3yf/' client/ts/src/manifest/index.ts
echo "Built and deployed"
cargo build-sbf
echo "Rebuilt and redeploying because program id is hardcoded"
solana program deploy target/deploy/manifest.so
solana program deploy target/deploy/wrapper.so
echo "Done redeploy"
yarn clean
yarn build
- name: Run test
run: |
yarn test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
verbose: true
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
ts-pass:
name: TS tests pass
needs: ['format', 'lint', 'test', 'depcheck']
runs-on: ubuntu-latest
steps:
- run: echo ok