-
Notifications
You must be signed in to change notification settings - Fork 40
207 lines (198 loc) · 7.95 KB
/
sims.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: Sims
# Sims workflow runs multiple types of simulations (nondeterminism, import-export, after-import, multi-seed-short)
on:
pull_request:
push:
branches:
- main
env:
LD_LIBRARY_PATH: /usr/local/lib:/usr/local/lib/x86_64-linux-gnu
# Set concurrency for this workflow to cancel in-progress jobs if retriggered.
# The github.ref is only available when triggered by a PR so fall back to github.run_id for other cases.
# The github.run_id is unique for each run, giving each such invocation it's own unique concurrency group.
# Basically, if you push to a PR branch, jobs that are still running for that PR will be cancelled.
# But jobs started because of a merge to main or a release tag push are not cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
setup:
if: "!contains(github.event.head_commit.message, 'skip-sims')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: technote-space/get-diff-action@v6.1.2
with:
PATTERNS: |
**/**.go
go.mod
go.sum
.github/workflows/sims.yml
sims.mk
SET_ENV_NAME_INSERTIONS: 1
SET_ENV_NAME_LINES: 1
- name: Define Variables
id: def-vars
run: |
file_prefix="sim-test-${GITHUB_SHA:0:7}-${GITHUB_RUN_ATTEMPT}"
echo "Setting output: file-prefix=$file_prefix"
echo "file-prefix=$file_prefix" >> "$GITHUB_OUTPUT"
outputs:
should-run: ${{ env.GIT_DIFF }}
file-prefix: ${{ steps.def-vars.outputs.file-prefix }}
build-linux:
needs: setup
if: needs.setup.outputs.should-run
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Output setup
run: |
echo " should-run: [${{ needs.setup.outputs.should-run }}]"
echo "file-prefix: [${{ needs.setup.outputs.file-prefix }}]"
- name: Setup build environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install -y libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev wget curl build-essential cmake gcc sqlite3
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Update provwasm contract
run: make download-smart-contracts
- name: Build provenanced
run: make build
- name: Provenanced version
run: build/provenanced version --long
runsim:
# These tests are the ones that use the runsim program (see sims.mk).
needs: [setup, build-linux]
if: needs.setup.outputs.should-run
strategy:
fail-fast: false
matrix:
test: ["import-export", "multi-seed-short", "after-import"]
db-backend: ["goleveldb"]
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Define test-logs
id: test-logs
run: |
test_logs="${{ needs.setup.outputs.file-prefix }}-${{ matrix.test }}-${{ matrix.db-backend }}-${{ matrix.os }}"
echo "Setting output: test-logs=$test_logs"
echo "test-logs=$test_logs" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Update provwasm contract
run: make download-smart-contracts
- name: Test
run: |
set -x
ec=0
export DB_BACKEND=${{ matrix.db-backend }}
make test-sim-${{ matrix.test }} || ec="$?"
echo "Test exited with code $ec"
if [[ "$ec" -ne '0' ]] && ls -d /tmp/sim-logs-*; then
mkdir "${{ steps.test-logs.outputs.test-logs }}"
for logdir in $( ls -d /tmp/sim-logs-* ); do
cp -rv $logdir/* "${{ steps.test-logs.outputs.test-logs }}/" || :
done
bad_seed="$( grep -Eo 'Seed [[:digit:]]+: FAILED' "${{ steps.test-logs.outputs.test-logs }}"/runsim_log | sed -E 's/[^[:digit:]]+//g' )" || :
if [[ -n "$bad_seed" ]]; then
echo "::group::last 500 lines of seed $bad_seed stdout"
tail -n 500 "${{ steps.test-logs.outputs.test-logs }}"/*-seed-$bad_seed-*.stdout || :
echo "::endgroup::"
fi
fi
exit "$ec"
- uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ steps.test-logs.outputs.test-logs }}
path: ${{ steps.test-logs.outputs.test-logs }}
go-test-multi-db:
# These are tests that use go test to run (see sims.mk), and that we want to test using different database backends.
needs: [setup, build-linux]
if: needs.setup.outputs.should-run
strategy:
fail-fast: false
matrix:
# The test-sim-simple test is pretty quick and should be able to identify glaring problems.
# The test-sim-benchmark is handy to have for each db type.
test: ["simple", "benchmark"]
db-backend: ["goleveldb"]
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Define test-logs
id: test-logs
run: |
test_logs="${{ needs.setup.outputs.file-prefix }}-${{ matrix.test }}-${{ matrix.db-backend }}-${{ matrix.os }}"
echo "Setting output: test-logs=$test_logs"
echo "test-logs=$test_logs" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Update provwasm contract
run: make download-smart-contracts
- name: Test
run: |
set -x
export DB_BACKEND=${{ matrix.db-backend }}
make test-sim-${{ matrix.test }} | tee "${{ steps.test-logs.outputs.test-logs }}.txt"
exit "${PIPESTATUS[0]}"
- uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ steps.test-logs.outputs.test-logs }}
path: ${{ steps.test-logs.outputs.test-logs }}.txt
go-test-single-db:
# These are tests that use go test to run (see sims.mk), and that we don't care about testing using different database backends.
needs: [setup, build-linux]
if: needs.setup.outputs.should-run
strategy:
fail-fast: false
matrix:
# The test-sim-nondeterminism test hard-codes the db backend to use memdb.
# The test-sim-benchmark-invariants test can use different db backends, but to save resources, is down here.
test: ["nondeterminism", "benchmark-invariants"]
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Define test-logs
id: test-logs
run: |
test_logs="${{ needs.setup.outputs.file-prefix }}-${{ matrix.test }}-${{ matrix.os }}"
echo "Setting output: test-logs=$test_logs"
echo "test-logs=$test_logs" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Update provwasm contract
run: make download-smart-contracts
- name: Test
run: |
set -x
make test-sim-${{ matrix.test }} | tee "${{ steps.test-logs.outputs.test-logs }}.txt"
exit "${PIPESTATUS[0]}"
- uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ steps.test-logs.outputs.test-logs }}
path: ${{ steps.test-logs.outputs.test-logs }}.txt
# Sim tests that are not run in here:
# test-sim-multi-seed-long: runsim
# The short version does 50 blocks and takes 30-40 minutes. The long one does 500 blocks. Way too long.
# test-sim-custom-genesis-multi-seed: runsim
# This one requires a genesis file to be created, and I don't feel like doing that right now.
# test-sim-custom-genesis-fast:
# Same as test-sim-custom-genesis-multi-seed.
# test-sim-profile:
# This is the exact same thing as test-sim-benchmark except with a couple extra output files.
# Unless I add an upload for them, it's not worth doing it again.