chore(cbind): nim-ffi migration [7/9] — service discovery + extended peer records #573
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 nat_libs | |
| - 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' |