Tests #258
This file contains 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: Tests | |
on: | |
workflow_dispatch: | |
inputs: | |
prNr: | |
description: A PR number to build | |
required: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Checkout | |
id: checkout | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh pr checkout "${{ github.event.inputs.prNr }}" | |
- name: Add dependencies | |
run: | | |
sudo apt-get install --no-install-recommends libudev-dev | |
- name: Set up cargo cache | |
uses: actions/cache@v3 | |
continue-on-error: true | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target_ci/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: ${{ runner.os }}-cargo- | |
- name: CI | |
run: | | |
./ci.sh | |
- name: Upload test binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: example-tests | |
path: tests | |
integration-tests: | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Checkout | |
id: checkout | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh pr checkout "${{ github.event.inputs.prNr }}" | |
echo "commit=$(git rev-parse --verify HEAD)" >> "$GITHUB_OUTPUT" | |
- name: Set pending | |
env: | |
COMMIT: ${{ steps.checkout.outputs.commit }} | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh api --method POST -H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/${COMMIT} \ | |
-f "state=pending" -f "description=Running integration tests" -f "context=integration-tests" | |
- name: Test | |
env: | |
RUST_LOG: trace | |
RUST_TEST_THREADS: 1 | |
run: | | |
cd host | |
cargo test --features log --test '*' -- --nocapture | |
- name: Update failed status | |
if: failure() | |
env: | |
COMMIT: ${{ steps.checkout.outputs.commit }} | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh api --method POST -H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/${COMMIT} \ | |
-f "state=failure" -f "description=The integration tests failed" -f "context=integration-tests" | |
- name: Update success status | |
if: success() | |
env: | |
COMMIT: ${{ steps.checkout.outputs.commit }} | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh api --method POST -H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/${COMMIT} \ | |
-f "state=success" -f "description=The integration tests succeeded!" -f "context=integration-tests" | |
example-tests: | |
runs-on: self-hosted | |
needs: [build, integration-tests] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Checkout | |
id: checkout | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh pr checkout "${{ github.event.inputs.prNr }}" | |
echo "commit=$(git rev-parse --verify HEAD)" >> "$GITHUB_OUTPUT" | |
- name: Set pending | |
env: | |
COMMIT: ${{ steps.checkout.outputs.commit }} | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh api --method POST -H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/${COMMIT} \ | |
-f "state=pending" -f "description=Running example tests" -f "context=example-tests" | |
- uses: actions/download-artifact@v4 | |
with: | |
name: example-tests | |
path: examples/tests/bins | |
- name: Test | |
env: | |
RUST_LOG: info | |
RUST_TEST_THREADS: 1 | |
run: | | |
cd examples/tests | |
find . | |
PROBE_CONFIG=$(cat ../../.ci/config.json) cargo test -- --nocapture | |
- name: Update failed status | |
if: failure() | |
env: | |
COMMIT: ${{ steps.checkout.outputs.commit }} | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh api --method POST -H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/${COMMIT} \ | |
-f "state=failure" -f "description=The example tests failed" -f "context=example-tests" | |
- name: Update success status | |
if: success() | |
env: | |
COMMIT: ${{ steps.checkout.outputs.commit }} | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh api --method POST -H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" /repos/embassy-rs/trouble/statuses/${COMMIT} \ | |
-f "state=success" -f "description=The example tests succeeded!" -f "context=example-tests" |