-
Notifications
You must be signed in to change notification settings - Fork 122
161 lines (129 loc) · 4.87 KB
/
tests-sync.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
name: Tests - Sync
on:
workflow_dispatch:
inputs:
block_ranges:
description: 'Optionally restrict to specific block ranges. Should be
formatted as multiple start block, such as "350000 50000 750000".
Defaults to all block ranges'
required: false
name:
description: 'Workflow run custom name'
required: false
pull_request:
branches:
- master
types: [labeled, opened, reopened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
run-name: ${{ inputs.name || github.event.pull_request.title || github.ref_name }}
jobs:
build:
if: contains(github.event.pull_request.labels.*.name, 'ci/sync') || github.event_name == 'workflow_dispatch'
runs-on: [self-hosted, linux, x64, builder]
steps:
- uses: actions/checkout@v3
- name: Populate environment
run: ./make.sh ci-export-vars
- name: Setup dependencies
run: sudo ./make.sh ci-setup-deps
- name: Setup dependencies for target
run: ./make.sh ci-setup-deps-target
- name: Install dependencies for test
run: sudo ./make.sh ci-setup-deps-test
# TODO: Switch this to a docker build later and this builds on the native
# VM toolchain and loses disparity with the CI release builds
- name: Build binaries
run: ./make.sh build
- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: defibins
path: |
build/src/defid
build/src/defi-cli
- name: Upload shell commands
uses: actions/upload-artifact@v3
with:
name: sync
path: ci/sync/main.sh
generate-matrix:
if: contains(github.event.pull_request.labels.*.name, 'ci/sync') || github.event_name == 'workflow_dispatch'
runs-on: [self-hosted, linux, x64]
# Add "id-token" with the intended permissions.
permissions:
contents: 'read'
id-token: 'write'
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v0'
with:
workload_identity_provider: 'projects/965426322273/locations/global/workloadIdentityPools/br-blockchains-pool/providers/br-blockchains-provider'
service_account: 'blockchain-dev-service@br-blockchains-dev.iam.gserviceaccount.com'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v0'
- id: set-matrix
name: 'Set matrix output'
run: |
if [ -n "${{ inputs.block_ranges }}" ]; then
BLOCKS=$(echo ${{ inputs.block_ranges }} | tr ' ' '\n')
else
SNAPSHOTS=$(gsutil ls gs://team-drop/master-datadir)
BLOCKS=$(echo "$SNAPSHOTS" | sed -e 's/.*\-\(.*\)\.tar.*/\1/' | grep -v gs | sort -n | head -n -1)
fi
MATRIX_JSON=$(jq -n -c -M --arg blocks "$BLOCKS" '{blocks: ($blocks | split("\n") | .[] |= tonumber | to_entries | map({start: .value , stop: (.value + 50000)}))}')
echo "MATRIX=$MATRIX_JSON" >> $GITHUB_OUTPUT
sync:
runs-on: [self-hosted, linux, x64]
needs: [build, generate-matrix]
strategy:
matrix: ${{fromJson(needs.generate-matrix.outputs.matrix)}}
continue-on-error: true
env:
DATADIR : datadir-${{matrix.blocks.start}}
STOP_BLOCK: ${{matrix.blocks.stop}}
START_BLOCK: ${{matrix.blocks.start}}
DEFID_BIN: ./defid
DEFI_CLI_BIN: ./defi-cli
REF_LOG_DIR: master-datadir/log
BASE_REF: master
timeout-minutes: 4320
steps:
- uses: actions/checkout@v3
- name: Download Snapshot
run: aria2c -x16 -s16 https://storage.googleapis.com/team-drop/master-datadir/datadir-${{matrix.blocks.start}}.tar.gz
- name: Create datadir
run: mkdir $DATADIR && tar -C $DATADIR -xvf datadir-${{matrix.blocks.start}}.tar.gz
- name: Download Binaries
uses: actions/download-artifact@v3
with:
name: defibins
- name: Download Shell Commands
uses: actions/download-artifact@v3
with:
name: sync
- name: Rename Artifact
run: mv main.sh sync.sh
- name: Set Permissions
run: |
chmod 777 defid
chmod 777 defi-cli
chmod 777 sync.sh
- name: Sync
run: ./sync.sh
- name: Diff log
run: diff debug-${{matrix.blocks.stop}}.log debug-tmp-${{matrix.blocks.stop}}.log
- name: Diff rollback log
run: diff debug-pre-rollback.log debug-post-rollback.log
if: ${{ failure() || success() }}
- name: Show debug.log
run: cat $DATADIR/debug.log
if: ${{ failure() || success() }}
- name: Show log file
run: cat debug-tmp-$STOP_BLOCK.log
if: ${{ failure() || success() }}