-
Notifications
You must be signed in to change notification settings - Fork 26
188 lines (155 loc) · 5.16 KB
/
on_pull_request.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
176
177
178
179
180
181
182
183
184
185
186
187
188
name: "Check PR is ready for merge"
on:
pull_request:
branches:
- main
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
rust:
- '.github/**'
- '**/*.rs'
- '**/Cargo.toml'
- '**/Cargo.lock'
- '**/rust-toolchain**'
- 'flake.nix'
- 'flake.lock'
- 'scripts/**'
- 'justfile'
go:
- '.github/**'
- 'crates/da-rpc-sys/build.rs'
- 'crates/da-rpc-sys/src/lib.rs'
- '**/*.go'
- '**/go.mod'
- '**/go.sum'
- '**/gopkg.lock'
- 'scripts/**'
- 'justfile'
eth:
- '.github/**'
- '**/*.sol'
- 'eth/foundry.toml'
- 'eth/justfile'
- 'eth/package.json'
- 'eth/package-lock.json'
- 'scripts/**'
- 'justfile'
outputs:
rust: ${{ steps.filter.outputs.rust }}
go: ${{ steps.filter.outputs.go }}
eth: ${{ steps.filter.outputs.eth }}
rust:
needs: changes
if: ${{ needs.changes.outputs.rust == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: "recursive"
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: Swatinem/rust-cache@v2
- name: "Install cargo-nextest"
uses: taiki-e/install-action@v2
with:
tool: nextest
- name: 📜 Lint code format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: "Build contracts"
run: make build-contracts
- name: "Ensure target dirs exist"
run: mkdir -p target/near/near_da_blob_store target/near/blob_registry
- name: "Run tests"
run: TEST_NEAR_ACCOUNT=${{ secrets.TEST_NEAR_ACCOUNT }} TEST_NEAR_SECRET=${{ secrets.TEST_NEAR_SECRET }} cargo nextest run --workspace --locked
# Nice to have, turned off for now
# - name: "Check for bloat"
# uses: orf/cargo-bloat-action@v1
# with:
# token: ${{ secrets.CEJAS_PERSONAL_ACCESS_TOKEN }}
go:
needs: changes
if: ${{ needs.changes.outputs.go == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: "recursive"
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: Swatinem/rust-cache@v2
- name: Login to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- uses: hoverkraft-tech/compose-action@v2.0.0
# - name: Enrich the test config
# run: |
# HTTP_API_TEST_SECRET_KEY=${{ secrets.HTTP_API_TEST_SECRET_KEY }} \
# HTTP_API_TEST_ACCOUNT_ID=${{ secrets.HTTP_API_TEST_ACCOUNT_ID }} \
# HTTP_API_TEST_NAMESPACE=${{ secrets.HTTP_API_TEST_NAMESPACE }} \
# scripts/enrich.sh
- name: "Ubuntu is missing libm :<"
run: sudo apt-get update && sudo apt-get install -y build-essential
- name: "Install FFI library"
run: make da-rpc-sys
- run: sudo cp ./gopkg/da-rpc/lib/* /usr/local/lib
- name: "Test gopkg"
working-directory: ./gopkg/da-rpc
run: go test -v
- name: "Test sidecar api"
working-directory: ./gopkg/sidecar
run: go test -v
eth-contracts:
needs: changes
if: ${{ needs.changes.outputs.eth == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./eth
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.GITHUB_TOKEN }}
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"
- name: "Install Bun"
uses: "oven-sh/setup-bun@v1"
- name: "Install the Node.js dependencies"
run: "bun install"
- name: "Lint the code"
run: "bun run lint"
- name: "Add lint summary"
run: |
echo "## Lint result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
- name: "Build the contracts and print their size"
run: "forge build --sizes"
- name: "Add build summary"
run: |
echo "## Build result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
- name: "Show the Foundry config"
run: "forge config"
- name: "Generate a fuzz seed that changes weekly to avoid burning through RPC allowance"
run: >
echo "FOUNDRY_FUZZ_SEED=$(
echo $(($EPOCHSECONDS - $EPOCHSECONDS % 604800))
)" >> $GITHUB_ENV
- name: "Run the tests"
run: "forge test --gas-report"
- name: "Add test summary"
run: |
echo "## Tests result" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY