diff --git a/.config/nextest.toml b/.config/nextest.toml new file mode 100644 index 0000000..4f0a061 --- /dev/null +++ b/.config/nextest.toml @@ -0,0 +1,10 @@ +[test-groups] +run-in-isolation = { max-threads = 32 } +# these are tests that must not run with other tests concurrently. All tests in +# this group can take up at most 32 threads among them, but each one requiring +# 16 threads also. The effect should be that tests run isolated. + +[[profile.ci.overrides]] +filter = 'test(::run_in_isolation::)' +test-group = 'run-in-isolation' +threads-required = 32 diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..be006de --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,13 @@ +# Keep GitHub Actions up to date with GitHub's Dependabot... +# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + groups: + github-actions: + patterns: + - "*" # Group all Actions updates into a single larger pull request + schedule: + interval: weekly diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..6cc5a1f --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,18 @@ +## Description + + + +## Breaking Changes + + + +## Notes & open questions + + + +## Change checklist + +- [ ] Self-review. +- [ ] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. +- [ ] Tests if relevant. +- [ ] All breaking changes documented. diff --git a/.github/workflows/beta.yaml b/.github/workflows/beta.yaml new file mode 100644 index 0000000..56bc5da --- /dev/null +++ b/.github/workflows/beta.yaml @@ -0,0 +1,43 @@ +# Run tests using the beta Rust compiler + +name: Beta Rust + +on: + schedule: + # 06:50 UTC every Monday + - cron: '50 6 * * 1' + workflow_dispatch: + +concurrency: + group: beta-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + IROH_FORCE_STAGING_RELAYS: "1" + +jobs: + tests: + uses: './.github/workflows/tests.yaml' + with: + rust-version: beta + notify: + needs: tests + if: ${{ always() }} + runs-on: ubuntu-latest + steps: + - name: Extract test results + run: | + printf '${{ toJSON(needs) }}\n' + result=$(echo '${{ toJSON(needs) }}' | jq -r .tests.result) + echo TESTS_RESULT=$result + echo "TESTS_RESULT=$result" >>"$GITHUB_ENV" + - name: Notify discord on failure + uses: n0-computer/discord-webhook-notify@v1 + if: ${{ env.TESTS_RESULT == 'failure' }} + with: + severity: error + details: | + Rustc beta tests failed in **${{ github.repository }}** + See https://github.com/n0-computer/${{ github.repository }}/actions/workflows/beta.yaml + webhookUrl: ${{ secrets.DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL }} + diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..2e19501 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,279 @@ +name: CI + +on: + pull_request: + types: [ 'labeled', 'unlabeled', 'opened', 'synchronize', 'reopened' ] + merge_group: + push: + branches: + - main + +concurrency: + group: ci-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + RUST_BACKTRACE: 1 + RUSTFLAGS: -Dwarnings + RUSTDOCFLAGS: -Dwarnings + MSRV: "1.76" + SCCACHE_CACHE_SIZE: "50G" + IROH_FORCE_STAGING_RELAYS: "1" + +jobs: + tests: + name: CI Test Suite + if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')" + uses: './.github/workflows/tests.yaml' + + cross_build: + name: Cross Build Only + if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')" + timeout-minutes: 30 + runs-on: [self-hosted, linux, X64] + strategy: + fail-fast: false + matrix: + target: + # cross tests are currently broken vor armv7 and aarch64 + # see https://github.com/cross-rs/cross/issues/1311 + # - armv7-linux-androideabi + # - aarch64-linux-android + # Freebsd execution fails in cross + # - i686-unknown-freebsd # Linking fails :/ + - x86_64-unknown-freebsd + # Netbsd execution fails to link in cross + # - x86_64-unknown-netbsd + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install rust stable + uses: dtolnay/rust-toolchain@stable + + - name: Cleanup Docker + continue-on-error: true + run: | + docker kill $(docker ps -q) + + # See https://github.com/cross-rs/cross/issues/1222 + - uses: taiki-e/install-action@cross + + - name: build + # cross tests are currently broken vor armv7 and aarch64 + # see https://github.com/cross-rs/cross/issues/1311. So on + # those platforms we only build but do not run tests. + run: cross build --all --target ${{ matrix.target }} + env: + RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}} + + android_build: + name: Android Build Only + if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')" + timeout-minutes: 30 + # runs-on: ubuntu-latest + runs-on: [self-hosted, linux, X64] + strategy: + fail-fast: false + matrix: + target: + - aarch64-linux-android + - armv7-linux-androideabi + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + with: + target: ${{ matrix.target }} + - name: Install rustup target + run: rustup target add ${{ matrix.target }} + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + + - name: Setup Android NDK + uses: arqu/setup-ndk@main + id: setup-ndk + with: + ndk-version: r23 + add-to-path: true + + - name: Build + env: + ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} + run: | + cargo install --version 3.5.4 cargo-ndk + cargo ndk --target ${{ matrix.target }} build + + cross_test: + name: Cross Test + if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')" + timeout-minutes: 30 + runs-on: [self-hosted, linux, X64] + strategy: + fail-fast: false + matrix: + target: + - i686-unknown-linux-gnu + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install rust stable + uses: dtolnay/rust-toolchain@stable + + - name: Cleanup Docker + continue-on-error: true + run: | + docker kill $(docker ps -q) + + # See https://github.com/cross-rs/cross/issues/1222 + - uses: taiki-e/install-action@cross + + - name: test + run: cross test --all --target ${{ matrix.target }} -- --test-threads=12 + env: + RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG' }} + + check_semver: + runs-on: ubuntu-latest + env: + RUSTC_WRAPPER: "sccache" + SCCACHE_GHA_ENABLED: "on" + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install sccache + uses: mozilla-actions/sccache-action@v0.0.6 + + - name: Setup Environment (PR) + if: ${{ github.event_name == 'pull_request' }} + shell: bash + run: | + echo "HEAD_COMMIT_SHA=$(git rev-parse origin/${{ github.base_ref }})" >> ${GITHUB_ENV} + - name: Setup Environment (Push) + if: ${{ github.event_name == 'push' || github.event_name == 'merge_group' }} + shell: bash + run: | + echo "HEAD_COMMIT_SHA=$(git rev-parse origin/main)" >> ${GITHUB_ENV} + - name: Check semver + # uses: obi1kenobi/cargo-semver-checks-action@v2 + uses: n0-computer/cargo-semver-checks-action@feat-baseline + with: + package: iroh-docs + baseline-rev: ${{ env.HEAD_COMMIT_SHA }} + use-cache: false + + check_fmt: + timeout-minutes: 30 + name: Checking fmt + runs-on: ubuntu-latest + env: + RUSTC_WRAPPER: "sccache" + SCCACHE_GHA_ENABLED: "on" + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - uses: mozilla-actions/sccache-action@v0.0.6 + - uses: taiki-e/install-action@cargo-make + - run: cargo make format-check + + check_docs: + timeout-minutes: 30 + name: Checking docs + runs-on: ubuntu-latest + env: + RUSTC_WRAPPER: "sccache" + SCCACHE_GHA_ENABLED: "on" + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly-2024-05-02 + - name: Install sccache + uses: mozilla-actions/sccache-action@v0.0.6 + + - name: Docs + run: cargo doc --workspace --all-features --no-deps --document-private-items + env: + RUSTDOCFLAGS: --cfg docsrs + + clippy_check: + timeout-minutes: 30 + runs-on: ubuntu-latest + env: + RUSTC_WRAPPER: "sccache" + SCCACHE_GHA_ENABLED: "on" + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - name: Install sccache + uses: mozilla-actions/sccache-action@v0.0.6 + + # TODO: We have a bunch of platform-dependent code so should + # probably run this job on the full platform matrix + - name: clippy check (all features) + run: cargo clippy --workspace --all-features --all-targets --bins --tests --benches + + - name: clippy check (no features) + run: cargo clippy --workspace --no-default-features --lib --bins --tests + + - name: clippy check (default features) + run: cargo clippy --workspace --all-targets + + msrv: + if: "github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'flaky-test')" + timeout-minutes: 30 + name: Minimal Supported Rust Version + runs-on: ubuntu-latest + env: + RUSTC_WRAPPER: "sccache" + SCCACHE_GHA_ENABLED: "on" + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.MSRV }} + - name: Install sccache + uses: mozilla-actions/sccache-action@v0.0.6 + + - name: Check MSRV all features + run: | + cargo +$MSRV check --workspace --all-targets + + cargo_deny: + timeout-minutes: 30 + name: cargo deny + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: EmbarkStudios/cargo-deny-action@v2 + with: + arguments: --workspace --all-features + command: check + command-arguments: "-Dwarnings" + + codespell: + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: pip install --user codespell[toml] + - run: codespell --ignore-words-list=ans,atmost,crate,inout,ratatui,ser,stayin,swarmin,worl --skip=CHANGELOG.md diff --git a/.github/workflows/cleanup.yaml b/.github/workflows/cleanup.yaml new file mode 100644 index 0000000..130d321 --- /dev/null +++ b/.github/workflows/cleanup.yaml @@ -0,0 +1,45 @@ +# Run tests using the beta Rust compiler + +name: Cleanup + +on: + schedule: + # 06:50 UTC every Monday + - cron: '50 6 * * 1' + workflow_dispatch: + +concurrency: + group: beta-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + IROH_FORCE_STAGING_RELAYS: "1" + +jobs: + clean_docs_branch: + permissions: + issues: write + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: generated-docs-preview + - name: Clean docs branch + run: | + cd pr/ + # keep the last 25 prs + dirs=$(ls -1d [0-9]* | sort -n) + total_dirs=$(echo "$dirs" | wc -l) + dirs_to_remove=$(echo "$dirs" | head -n $(($total_dirs - 25))) + if [ -n "$dirs_to_remove" ]; then + echo "$dirs_to_remove" | xargs rm -rf + fi + git add . + git commit -m "Cleanup old docs" + git push + + + + diff --git a/.github/workflows/commit.yaml b/.github/workflows/commit.yaml new file mode 100644 index 0000000..1b5c6d2 --- /dev/null +++ b/.github/workflows/commit.yaml @@ -0,0 +1,19 @@ +name: Commits + +on: + pull_request: + branches: [main] + types: [opened, edited, synchronize] + +env: + IROH_FORCE_STAGING_RELAYS: "1" + +jobs: + check-for-cc: + runs-on: ubuntu-latest + steps: + - name: check-for-cc + id: check-for-cc + uses: agenthunt/conventional-commit-checker-action@v2.0.0 + with: + pr-title-regex: "^(.+)(?:(([^)s]+)))?!?: (.+)" diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 0000000..6000704 --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,73 @@ +name: Docs Preview + +on: + pull_request: + workflow_dispatch: + inputs: + pr_number: + required: true + type: string + +# ensure job runs sequentially so pushing to the preview branch doesn't conflict +concurrency: + group: ci-docs-preview + +env: + IROH_FORCE_STAGING_RELAYS: "1" + +jobs: + preview_docs: + permissions: write-all + timeout-minutes: 30 + name: Docs preview + if: ${{ (github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' ) && !github.event.pull_request.head.repo.fork }} + runs-on: ubuntu-latest + env: + RUSTC_WRAPPER: "sccache" + SCCACHE_GHA_ENABLED: "on" + SCCACHE_CACHE_SIZE: "50G" + PREVIEW_PATH: pr/${{ github.event.pull_request.number || inputs.pr_number }}/docs + + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly-2024-05-02 + - name: Install sccache + uses: mozilla-actions/sccache-action@v0.0.6 + + - name: Generate Docs + run: cargo doc --workspace --all-features --no-deps + env: + RUSTDOCFLAGS: --cfg iroh_docsrs + + - name: Deploy Docs to Preview Branch + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./target/doc/ + destination_dir: ${{ env.PREVIEW_PATH }} + publish_branch: generated-docs-preview + + - name: Find Docs Comment + uses: peter-evans/find-comment@v3 + id: fc + with: + issue-number: ${{ github.event.pull_request.number || inputs.pr_number }} + comment-author: 'github-actions[bot]' + body-includes: Documentation for this PR has been generated + + - name: Get current timestamp + id: get_timestamp + run: echo "TIMESTAMP=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV + + - name: Create or Update Docs Comment + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number || inputs.pr_number }} + comment-id: ${{ steps.fc.outputs.comment-id }} + body: | + Documentation for this PR has been generated and is available at: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ env.PREVIEW_PATH }}/iroh_docs/ + + Last updated: ${{ env.TIMESTAMP }} + edit-mode: replace diff --git a/.github/workflows/flaky.yaml b/.github/workflows/flaky.yaml new file mode 100644 index 0000000..094f6b3 --- /dev/null +++ b/.github/workflows/flaky.yaml @@ -0,0 +1,99 @@ +# Run all tests, including flaky test. +# +# The default CI workflow ignores flaky tests. This workflow will run +# all tests, including ignored ones. +# +# To use this workflow you can either: +# +# - Label a PR with "flaky-test", the normal CI workflow will not run +# any jobs but the jobs here will be run. Note that to merge the PR +# you'll need to remove the label eventually because the normal CI +# jobs are required by branch protection. +# +# - Manually trigger the workflow, you may choose a branch for this to +# run on. +# +# Additionally this jobs runs once a day on a schedule. +# +# Currently doctests are not run by this workflow. + +name: Flaky CI + +on: + pull_request: + types: [ 'labeled', 'unlabeled', 'opened', 'synchronize', 'reopened' ] + schedule: + # 06:30 UTC every day + - cron: '30 6 * * *' + workflow_dispatch: + inputs: + branch: + description: 'Branch to run on, defaults to main' + required: true + default: 'main' + type: string + +concurrency: + group: flaky-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + IROH_FORCE_STAGING_RELAYS: "1" + +jobs: + tests: + if: "contains(github.event.pull_request.labels.*.name, 'flaky-test') || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'" + uses: './.github/workflows/tests.yaml' + with: + flaky: true + git-ref: ${{ inputs.branch }} + notify: + needs: tests + if: ${{ always() }} + runs-on: ubuntu-latest + steps: + - name: Extract test results + run: | + printf '${{ toJSON(needs) }}\n' + result=$(echo '${{ toJSON(needs) }}' | jq -r .tests.result) + echo TESTS_RESULT=$result + echo "TESTS_RESULT=$result" >>"$GITHUB_ENV" + - name: download nextest reports + uses: actions/download-artifact@v4 + with: + pattern: libtest_run_${{ github.run_number }}-${{ github.run_attempt }}-* + merge-multiple: true + path: nextest-results + - name: create summary report + id: make_summary + run: | + # prevent the glob expression in the loop to match on itself when the dir is empty + shopt -s nullglob + # to deal with multiline outputs it's recommended to use a random EOF, the syntax is based on + # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings + EOF=aP51VriWCxNJ1JjvmO9i + echo "summary<<$EOF" >> $GITHUB_OUTPUT + echo "Flaky tests failure:" >> $GITHUB_OUTPUT + echo " " >> $GITHUB_OUTPUT + for report in nextest-results/*.json; do + # remove the name prefix and extension, and split the parts + name=$(echo ${report:16:-5} | tr _ ' ') + echo $name + echo "- **$name**" >> $GITHUB_OUTPUT + # select the failed tests + # the tests have this format "crate::module$test_name", the sed expressions remove the quotes and replace $ for :: + failure=$(jq --slurp '.[] | select(.["type"] == "test" and .["event"] == "failed" ) | .["name"]' $report | sed -e 's/^"//g' -e 's/\$/::/' -e 's/"//') + echo "$failure" + echo "$failure" >> $GITHUB_OUTPUT + done + echo "" >> $GITHUB_OUTPUT + echo "See https://github.com/n0-computer/iroh/actions/workflows/flaky.yaml" >> $GITHUB_OUTPUT + echo "$EOF" >> $GITHUB_OUTPUT + - name: Notify discord on failure + uses: n0-computer/discord-webhook-notify@v1 + if: ${{ env.TESTS_RESULT == 'failure' || env.TESTS_RESULT == 'success' }} + with: + text: "Flaky tests in **${{ github.repository }}**:" + severity: ${{ env.TESTS_RESULT == 'failure' && 'warn' || 'info' }} + details: ${{ env.TESTS_RESULT == 'failure' && steps.make_summary.outputs.summary || 'No flaky failures!' }} + webhookUrl: ${{ secrets.DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL }} diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..dbc4c07 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,229 @@ +# Run all tests, with or without flaky tests. + +name: Tests + +on: + workflow_call: + inputs: + rust-version: + description: 'The version of the rust compiler to run' + type: string + default: 'stable' + flaky: + description: 'Whether to also run flaky tests' + type: boolean + default: false + git-ref: + description: 'Which git ref to checkout' + type: string + default: ${{ github.ref }} + +env: + RUST_BACKTRACE: 1 + RUSTFLAGS: -Dwarnings + RUSTDOCFLAGS: -Dwarnings + SCCACHE_CACHE_SIZE: "50G" + CRATES_LIST: "iroh-docs" + IROH_FORCE_STAGING_RELAYS: "1" + +jobs: + build_and_test_nix: + timeout-minutes: 30 + name: "Tests" + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + name: [ubuntu-latest, macOS-arm-latest] + rust: [ '${{ inputs.rust-version }}' ] + features: [all, none, default] + include: + - name: ubuntu-latest + os: ubuntu-latest + release-os: linux + release-arch: amd64 + runner: [self-hosted, linux, X64] + - name: macOS-arm-latest + os: macOS-latest + release-os: darwin + release-arch: aarch64 + runner: [self-hosted, macOS, ARM64] + env: + # Using self-hosted runners so use local cache for sccache and + # not SCCACHE_GHA_ENABLED. + RUSTC_WRAPPER: "sccache" + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.git-ref }} + + - name: Install ${{ matrix.rust }} rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} + + - name: Install cargo-nextest + uses: taiki-e/install-action@v2 + with: + tool: nextest + + - name: Install sccache + uses: mozilla-actions/sccache-action@v0.0.6 + + - name: Select features + run: | + case "${{ matrix.features }}" in + all) + echo "FEATURES=--all-features" >> "$GITHUB_ENV" + ;; + none) + echo "FEATURES=--no-default-features" >> "$GITHUB_ENV" + ;; + default) + echo "FEATURES=" >> "$GITHUB_ENV" + ;; + *) + exit 1 + esac + + - name: check features + if: ${{ ! inputs.flaky }} + run: | + for i in ${CRATES_LIST//,/ } + do + echo "Checking $i $FEATURES" + if [ $i = "iroh-cli" ]; then + targets="--bins" + else + targets="--lib --bins" + fi + echo cargo check -p $i $FEATURES $targets + cargo check -p $i $FEATURES $targets + done + env: + RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}} + + - name: build tests + run: | + cargo nextest run --workspace ${{ env.FEATURES }} --lib --bins --tests --no-run + + - name: list ignored tests + run: | + cargo nextest list --workspace ${{ env.FEATURES }} --lib --bins --tests --run-ignored ignored-only + + - name: run tests + run: | + mkdir -p output + cargo nextest run --workspace ${{ env.FEATURES }} --lib --bins --tests --profile ci --run-ignored ${{ inputs.flaky && 'all' || 'default' }} --no-fail-fast --message-format ${{ inputs.flaky && 'libtest-json' || 'human' }} > output/${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}.json + env: + RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}} + NEXTEST_EXPERIMENTAL_LIBTEST_JSON: 1 + + - name: upload results + if: ${{ failure() && inputs.flaky }} + uses: actions/upload-artifact@v4 + with: + name: libtest_run_${{ github.run_number }}-${{ github.run_attempt }}-${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}.json + path: output + retention-days: 45 + compression-level: 0 + + - name: doctests + if: ${{ (! inputs.flaky) && matrix.features == 'all' }} + run: | + if [ -n "${{ runner.debug }}" ]; then + export RUST_LOG=TRACE + else + export RUST_LOG=DEBUG + fi + cargo test --workspace --all-features --doc + + build_and_test_windows: + timeout-minutes: 30 + name: "Tests" + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + name: [windows-latest] + rust: [ '${{ inputs.rust-version}}' ] + features: [all, none, default] + target: + - x86_64-pc-windows-msvc + include: + - name: windows-latest + os: windows + runner: [self-hosted, windows, x64] + env: + # Using self-hosted runners so use local cache for sccache and + # not SCCACHE_GHA_ENABLED. + RUSTC_WRAPPER: "sccache" + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.git-ref }} + + - name: Install ${{ matrix.rust }} + run: | + rustup toolchain install ${{ matrix.rust }} + rustup toolchain default ${{ matrix.rust }} + rustup target add ${{ matrix.target }} + rustup set default-host ${{ matrix.target }} + + - name: Install cargo-nextest + shell: powershell + run: | + $tmp = New-TemporaryFile | Rename-Item -NewName { $_ -replace 'tmp$', 'zip' } -PassThru + Invoke-WebRequest -OutFile $tmp https://get.nexte.st/latest/windows + $outputDir = if ($Env:CARGO_HOME) { Join-Path $Env:CARGO_HOME "bin" } else { "~/.cargo/bin" } + $tmp | Expand-Archive -DestinationPath $outputDir -Force + $tmp | Remove-Item + + - name: Select features + run: | + switch ("${{ matrix.features }}") { + "all" { + echo "FEATURES=--all-features" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append + } + "none" { + echo "FEATURES=--no-default-features" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append + } + "default" { + echo "FEATURES=" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append + } + default { + Exit 1 + } + } + + - name: Install sccache + uses: mozilla-actions/sccache-action@v0.0.6 + + - uses: msys2/setup-msys2@v2 + + - name: build tests + run: | + cargo nextest run --workspace ${{ env.FEATURES }} --lib --bins --tests --target ${{ matrix.target }} --no-run + + - name: list ignored tests + run: | + cargo nextest list --workspace ${{ env.FEATURES }} --lib --bins --tests --target ${{ matrix.target }} --run-ignored ignored-only + + - name: tests + run: | + mkdir -p output + cargo nextest run --workspace ${{ env.FEATURES }} --lib --bins --tests --profile ci --target ${{ matrix.target }} --run-ignored ${{ inputs.flaky && 'all' || 'default' }} --no-fail-fast --message-format ${{ inputs.flaky && 'libtest-json' || 'human' }} > output/${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}.json + env: + RUST_LOG: ${{ runner.debug && 'TRACE' || 'DEBUG'}} + NEXTEST_EXPERIMENTAL_LIBTEST_JSON: 1 + + - name: upload results + if: ${{ failure() && inputs.flaky }} + uses: actions/upload-artifact@v4 + with: + name: libtest_run_${{ github.run_number }}-${{ github.run_attempt }}-${{ matrix.name }}_${{ matrix.features }}_${{ matrix.rust }}.json + path: output + retention-days: 1 + compression-level: 0