mirror of
https://github.com/Magnus167/rustframe.git
synced 2025-08-21 03:30:01 +00:00
Compare commits
No commits in common. "101ee8c1c799cb6ef277271e7b0c04aa120cdc7e" and "3b67d6e477f5cf2b2759f6543d510cd464650510" have entirely different histories.
101ee8c1c7
...
3b67d6e477
61
.github/actions/runner-fallback/action.yml
vendored
61
.github/actions/runner-fallback/action.yml
vendored
@ -1,61 +0,0 @@
|
|||||||
# actions/runner-fallback/action.yml
|
|
||||||
name: "Runner Fallback"
|
|
||||||
description: |
|
|
||||||
Chooses a self-hosted runner when one with the required labels is online,
|
|
||||||
otherwise returns a fallback GitHub-hosted label.
|
|
||||||
inputs:
|
|
||||||
primary-runner:
|
|
||||||
description: 'Comma-separated label list for the preferred self-hosted runner (e.g. "self-hosted,linux")'
|
|
||||||
required: true
|
|
||||||
fallback-runner:
|
|
||||||
description: 'Comma-separated label list or single label for the fallback (e.g. "ubuntu-latest")'
|
|
||||||
required: true
|
|
||||||
github-token:
|
|
||||||
description: "PAT or GITHUB_TOKEN with `repo` scope"
|
|
||||||
required: true
|
|
||||||
|
|
||||||
outputs:
|
|
||||||
use-runner:
|
|
||||||
description: "JSON array of labels you can feed straight into runs-on"
|
|
||||||
value: ${{ steps.pick.outputs.use-runner }}
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: "composite"
|
|
||||||
steps:
|
|
||||||
- name: Check self-hosted fleet
|
|
||||||
id: pick
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
TOKEN: ${{ inputs.github-token }}
|
|
||||||
PRIMARY: ${{ inputs.primary-runner }}
|
|
||||||
FALLBACK: ${{ inputs.fallback-runner }}
|
|
||||||
run: |
|
|
||||||
# -------- helper -----------
|
|
||||||
to_json_array () {
|
|
||||||
local list="$1"; IFS=',' read -ra L <<<"$list"
|
|
||||||
printf '['; printf '"%s",' "${L[@]}"; printf ']'
|
|
||||||
}
|
|
||||||
# -------- query API ---------
|
|
||||||
repo="${{ github.repository }}"
|
|
||||||
runners=$(curl -s -H "Authorization: Bearer $TOKEN" \
|
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
"https://api.github.com/repos/$repo/actions/runners?per_page=100")
|
|
||||||
# Split wanted labels
|
|
||||||
IFS=',' read -ra WANT <<<"$PRIMARY"
|
|
||||||
online_found=0
|
|
||||||
while read -r row; do
|
|
||||||
labels=$(jq -r '.labels[].name' <<<"$row")
|
|
||||||
ok=1
|
|
||||||
for w in "${WANT[@]}"; do
|
|
||||||
grep -Fxq "$w" <<<"$labels" || { ok=0; break; }
|
|
||||||
done
|
|
||||||
[ "$ok" -eq 1 ] && { online_found=1; break; }
|
|
||||||
done < <(jq -c '.runners[] | select(.status=="online")' <<<"$runners")
|
|
||||||
|
|
||||||
if [ "$online_found" -eq 1 ]; then
|
|
||||||
echo "✅ Self-hosted runner online."
|
|
||||||
echo "use-runner=$(to_json_array "$PRIMARY")" >>"$GITHUB_OUTPUT"
|
|
||||||
else
|
|
||||||
echo "❌ No matching self-hosted runner online - using fallback."
|
|
||||||
echo "use-runner=$(to_json_array "$FALLBACK")" >>"$GITHUB_OUTPUT"
|
|
||||||
fi
|
|
23
.github/workflows/docs-and-testcov.yml
vendored
23
.github/workflows/docs-and-testcov.yml
vendored
@ -17,23 +17,10 @@ permissions:
|
|||||||
pages: write
|
pages: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pick-runner:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
runner: ${{ steps.choose.outputs.use-runner }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- id: choose
|
|
||||||
uses: ./.github/actions/runner-fallback
|
|
||||||
with:
|
|
||||||
primary-runner: "self-hosted,ubuntu-latest"
|
|
||||||
fallback-runner: "ubuntu-latest"
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
docs-and-testcov:
|
docs-and-testcov:
|
||||||
needs: pick-runner
|
# runs-on: ubuntu-latest
|
||||||
runs-on: ${{ fromJson(needs.pick-runner.outputs.runner) }}
|
runs-on: [self-hosted, ubuntu-latest]
|
||||||
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -69,10 +56,12 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Export tarpaulin coverage badge JSON
|
- name: Export tarpaulin coverage badge JSON
|
||||||
# extract raw coverage and round to 2 decimal places
|
|
||||||
run: |
|
run: |
|
||||||
|
# extract raw coverage
|
||||||
coverage=$(jq '.coverage' tarpaulin-report.json)
|
coverage=$(jq '.coverage' tarpaulin-report.json)
|
||||||
|
# round to 2 decimal places
|
||||||
formatted=$(printf "%.2f" "$coverage")
|
formatted=$(printf "%.2f" "$coverage")
|
||||||
|
# build the badge JSON using the pre-formatted string
|
||||||
jq --arg message "$formatted" \
|
jq --arg message "$formatted" \
|
||||||
'{schemaVersion:1,
|
'{schemaVersion:1,
|
||||||
label:"tarpaulin-report",
|
label:"tarpaulin-report",
|
||||||
|
17
.github/workflows/run-unit-tests.yml
vendored
17
.github/workflows/run-unit-tests.yml
vendored
@ -11,24 +11,11 @@ concurrency:
|
|||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pick-runner:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
runner: ${{ steps.choose.outputs.use-runner }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- id: choose
|
|
||||||
uses: ./.github/actions/runner-fallback
|
|
||||||
with:
|
|
||||||
primary-runner: "self-hosted,ubuntu-latest"
|
|
||||||
fallback-runner: "ubuntu-latest"
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
run-unit-tests:
|
run-unit-tests:
|
||||||
needs: pick-runner
|
|
||||||
if: github.event.pull_request.draft == false
|
if: github.event.pull_request.draft == false
|
||||||
name: run-unit-tests
|
name: run-unit-tests
|
||||||
runs-on: ${{ fromJson(needs.pick-runner.outputs.runner) }}
|
# runs-on: ubuntu-latest
|
||||||
|
runs-on: [self-hosted, ubuntu-latest]
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user