-
Notifications
You must be signed in to change notification settings - Fork 73
166 lines (148 loc) · 6.85 KB
/
Copy pathtest_multiformat_exts.yml
File metadata and controls
166 lines (148 loc) · 6.85 KB
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
name: Test Multiformat Extensions
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
pick-platform:
runs-on: ubuntu-latest
outputs:
os: ${{ steps.pick.outputs.os }}
cpu: ${{ steps.pick.outputs.cpu }}
cc: ${{ steps.pick.outputs.cc }}
builder: ${{ steps.pick.outputs.builder }}
shell: ${{ steps.pick.outputs.shell }}
nim_ref: ${{ steps.pick.outputs.nim_ref }}
nim_mm: ${{ steps.pick.outputs.nim_mm }}
steps:
- name: Pick random platform
id: pick
run: |
declare -a OSS=("linux" "linux" "linux-gcc-14" "macos-15" "windows" "windows")
declare -a CPUS=("amd64" "i386" "amd64" "arm64" "amd64" "amd64")
declare -a CCS=("gcc" "gcc" "gcc" "clang" "clang" "gcc")
declare -a BUILDERS=("ubuntu-22.04" "ubuntu-22.04" "ubuntu-24.04" "macos-15" "windows-2022" "windows-2022")
declare -a SHELLS=("bash" "bash" "bash" "bash" "bash" "msys2 {0}")
PLATFORM_INDEX=$((RANDOM % 6))
echo "os=${OSS[$PLATFORM_INDEX]}" >> $GITHUB_OUTPUT
echo "cpu=${CPUS[$PLATFORM_INDEX]}" >> $GITHUB_OUTPUT
echo "cc=${CCS[$PLATFORM_INDEX]}" >> $GITHUB_OUTPUT
echo "builder=${BUILDERS[$PLATFORM_INDEX]}" >> $GITHUB_OUTPUT
echo "shell=${SHELLS[$PLATFORM_INDEX]}" >> $GITHUB_OUTPUT
declare -a NIM_REFS=("v2.2.4" "v2.2.10" "v2.2.10")
declare -a NIM_MMS=("refc" "refc" "orc")
NIM_INDEX=$((RANDOM % 3))
echo "nim_ref=${NIM_REFS[$NIM_INDEX]}" >> $GITHUB_OUTPUT
echo "nim_mm=${NIM_MMS[$NIM_INDEX]}" >> $GITHUB_OUTPUT
test:
needs: pick-platform
env:
NIMBLE_COMMIT: 42ef70c2102a942c46f13eb76872326edd525cec # v0.22.3
timeout-minutes: 55
runs-on: ${{ needs.pick-platform.outputs.builder }}
name: "test_multiformat_exts (${{ needs.pick-platform.outputs.os }}-${{ needs.pick-platform.outputs.cpu }} / ${{ needs.pick-platform.outputs.cc }} / Nim ${{ needs.pick-platform.outputs.nim_ref }} / ${{ needs.pick-platform.outputs.nim_mm }})"
defaults:
run:
shell: ${{ needs.pick-platform.outputs.shell }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: true
- name: Setup Nim
uses: "./.github/actions/install_nim"
with:
os: ${{ needs.pick-platform.outputs.os }}
cpu: ${{ needs.pick-platform.outputs.cpu }}
shell: ${{ needs.pick-platform.outputs.shell }}
nim_ref: ${{ needs.pick-platform.outputs.nim_ref }}
- name: Restore dependencies from cache
id: deps-cache
uses: actions/cache@v5
with:
path: |
nimbledeps
tests/nimbledeps
key: nimbledeps-${{ needs.pick-platform.outputs.os }}-${{ needs.pick-platform.outputs.cpu }}-${{ needs.pick-platform.outputs.cc }}-${{ hashFiles('.pinned', 'tests/.pinned') }}
- name: Restore llvm-mingw (Windows) from cache
if: runner.os == 'Windows' && needs.pick-platform.outputs.cc == 'clang'
id: windows-mingw-cache
uses: actions/cache@v5
with:
path: external/mingw-${{ needs.pick-platform.outputs.cpu }}
key: 'mingw-llvm-17-${{ needs.pick-platform.outputs.cpu }}'
- name: Install llvm-mingw dependency (Windows)
if: >
steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows' &&
needs.pick-platform.outputs.cc == 'clang'
run: |
mkdir -p external
MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/20230905"
MINGW_URL="$MINGW_BASE/llvm-mingw-20230905-ucrt-x86_64.zip"
curl -L "$MINGW_URL" -o "external/mingw-${{ needs.pick-platform.outputs.cpu }}.zip"
7z x -y "external/mingw-${{ needs.pick-platform.outputs.cpu }}.zip" -oexternal/mingw-${{ needs.pick-platform.outputs.cpu }}/
mv external/mingw-${{ needs.pick-platform.outputs.cpu }}/**/* ./external/mingw-${{ needs.pick-platform.outputs.cpu }}
- name: Use gcc 14
if: needs.pick-platform.outputs.os == 'linux-gcc-14'
run: |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 14
sudo update-alternatives --set gcc /usr/bin/gcc-14
- name: Path to cached dependencies (Windows)
if: >
runner.os == 'Windows' &&
needs.pick-platform.outputs.cc == 'clang'
run: |
echo '${{ github.workspace }}'"/external/mingw-${{ needs.pick-platform.outputs.cpu }}/bin" >> $GITHUB_PATH
echo "." >> $GITHUB_PATH
- name: Install nasm (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
choco install nasm --no-progress -y
"C:\Program Files\NASM" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
- name: Install deps
if: ${{ steps.deps-cache.outputs.cache-hit != 'true' }}
run: |
nimble install_pinned
cd tests && nimble install_pinned
- name: Build prerequisites
run: make nimble.paths tests/nimble.paths
- name: Build test_multiformat_exts
id: build-test
run: |
NIMFLAGS="--mm:${{ needs.pick-platform.outputs.nim_mm }} --opt:speed --styleCheck:usages --styleCheck:error --parallelBuild:0 --threads:on --skipUserCfg"
NIMFLAGS="$NIMFLAGS -d:libp2p_multicodec_exts=../tests/libp2p/multiformat_exts/multicodec_exts.nim"
NIMFLAGS="$NIMFLAGS -d:libp2p_multiaddress_exts=../tests/libp2p/multiformat_exts/multiaddress_exts.nim"
NIMFLAGS="$NIMFLAGS -d:libp2p_multihash_exts=../tests/libp2p/multiformat_exts/multihash_exts.nim"
NIMFLAGS="$NIMFLAGS -d:libp2p_multibase_exts=../tests/libp2p/multiformat_exts/multibase_exts.nim"
NIMFLAGS="$NIMFLAGS -d:libp2p_contentids_exts=../tests/libp2p/multiformat_exts/contentids_exts.nim"
NIMFLAGS="$NIMFLAGS -d:path=multiformat_exts"
if [[ '${{ needs.pick-platform.outputs.cc }}' == 'clang' ]]; then
NIMFLAGS="$NIMFLAGS --cc:clang"
fi
nim c $NIMFLAGS ./tests/test_all
- name: Run tests
id: run-tests
run: |
./tests/test_all --output-level=VERBOSE --console --xml:tests/results_test_multiformat_exts.xml
- name: Fix xml newlines
if: ${{ !cancelled() && steps.run-tests.outcome == 'failure' }}
run: |
nim c -r tools/fix_xml_newlines.nim
- name: Test Report
uses: dorny/test-reporter@v2
if: ${{ !cancelled() && steps.run-tests.outcome == 'failure' }}
with:
name: Test Report
path: tests/results_*.xml
reporter: jest-junit
list-suites: 'failed'
list-tests: 'failed'
fail-on-error: 'false'