Skip to content

Commit 044e042

Browse files
authored
Try to run extras and host-tests on self-hosted(mac-mini) and GH-ubuntu-latest runners (#4052)
1 parent 27c89c3 commit 044e042

File tree

2 files changed

+66
-5
lines changed

2 files changed

+66
-5
lines changed

.github/workflows/check_runner.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Check Runner
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
primary-runner:
7+
required: true
8+
type: string
9+
fallback-runner:
10+
required: true
11+
type: string
12+
13+
outputs:
14+
selected-runner:
15+
description: "The runner to use (primary if available, otherwise fallback)"
16+
value: ${{ jobs.detect-runner.outputs.selected-runner }}
17+
18+
jobs:
19+
detect-runner:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
selected-runner: ${{ steps.runner-check.outputs.runner }}
23+
steps:
24+
- id: runner-check
25+
name: Determine runner availability (org-level)
26+
env:
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
ORG_NAME: ${{ github.repository_owner }}
29+
PRIMARY_RUNNER: ${{ inputs.primary-runner }}
30+
FALLBACK_RUNNER: ${{ inputs.fallback-runner }}
31+
run: |
32+
response=$(curl -s -H "Authorization: Bearer $GH_TOKEN" \
33+
-H "Accept: application/vnd.github+json" \
34+
"https://api.github.com/orgs/$ORG_NAME/actions/runners")
35+
36+
AVAILABLE=$(echo "$response" | jq --arg name "$PRIMARY_RUNNER" \
37+
'.runners // [] | map(select(.name == $name and .status == "online" and .busy == false)) | length')
38+
39+
if [[ "$AVAILABLE" -gt 0 ]]; then
40+
echo "$PRIMARY_RUNNER is available"
41+
echo "runner=$PRIMARY_RUNNER" >> "$GITHUB_OUTPUT"
42+
else
43+
echo "Falling back to $FALLBACK_RUNNER"
44+
echo "runner=$FALLBACK_RUNNER" >> "$GITHUB_OUTPUT"
45+
fi

.github/workflows/ci.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,25 @@ jobs:
100100
# always invokes +esp internally
101101
run: cargo xcheck semver-check --chips ${{ matrix.device.soc }} check
102102

103-
extras:
104-
runs-on: macos-m1-self-hosted
103+
detect-extras-runner:
104+
uses: ./.github/workflows/check_runner.yml
105+
with:
106+
primary-runner: macos-m1-self-hosted
107+
fallback-runner: ubuntu-latest
105108

109+
extras:
110+
needs: detect-extras-runner
111+
runs-on: ${{ needs.detect-extras-runner.outputs.selected-runner }}
106112
steps:
107113
- uses: actions/checkout@v4
108114
- uses: dtolnay/rust-toolchain@v1
109115
with:
110116
toolchain: stable
111117

118+
# Install dependencies for building the extra crates on ubuntu
119+
- name: Install dependencies
120+
if: runner.os == 'Linux'
121+
run: sudo apt-get update && sudo apt-get -y install musl-tools libudev-dev pkg-config
112122
# Build the extra crates
113123
- name: Build the bench-server
114124
run: cd extras/bench-server && cargo build
@@ -150,9 +160,15 @@ jobs:
150160
# --------------------------------------------------------------------------
151161
# host tests
152162

163+
detect-host-tests-runner:
164+
uses: ./.github/workflows/check_runner.yml
165+
with:
166+
primary-runner: macos-m1-self-hosted
167+
fallback-runner: ubuntu-latest
168+
153169
host-tests:
154-
runs-on: macos-m1-self-hosted
155-
170+
needs: detect-host-tests-runner
171+
runs-on: ${{ needs.detect-host-tests-runner.outputs.selected-runner }}
156172
steps:
157173
- uses: actions/checkout@v4
158174
# Some of the configuration items in 'rustfmt.toml' require the 'nightly'
@@ -184,4 +200,4 @@ jobs:
184200

185201
# Miri tests in esp-storage
186202
- run: cd esp-storage && cargo +nightly miri test --features=emulation -- --test-threads=1
187-
- run: cd esp-storage && cargo +nightly miri test --features=emulation,bytewise-read -- --test-threads=1
203+
- run: cd esp-storage && cargo +nightly miri test --features=emulation,bytewise-read -- --test-threads=1

0 commit comments

Comments
 (0)