mirror of
https://github.com/Magnus167/rustframe.git
synced 2025-08-20 07:09:59 +00:00
Implement runner fallback mechanism for docs and unit test workflows
This commit is contained in:
parent
d15aaf437f
commit
6076e0c8e3
49
.github/workflows/docs-and-testcov.yml
vendored
49
.github/workflows/docs-and-testcov.yml
vendored
@ -17,10 +17,21 @@ permissions:
|
|||||||
pages: write
|
pages: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docs-and-testcov:
|
pick-runner:
|
||||||
# runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
runs-on: [self-hosted, ubuntu-latest]
|
outputs:
|
||||||
|
runner: ${{ steps.choose.outputs.use-runner }}
|
||||||
|
steps:
|
||||||
|
- id: choose
|
||||||
|
uses: ./.github/actions/runner-fallback@v1 # or your-org/runner-fallback@v1
|
||||||
|
with:
|
||||||
|
primary-runner: "self-hosted,ubuntu-latest"
|
||||||
|
fallback-runner: "ubuntu-latest"
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
docs-and-testcov:
|
||||||
|
needs: pick-runner
|
||||||
|
runs-on: ${{ fromJson(needs.pick-runner.outputs.runner) }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@ -30,10 +41,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
override: true
|
override: true
|
||||||
|
|
||||||
- name: Build documentation
|
- name: Build documentation
|
||||||
run: cargo doc --no-deps --release
|
run: cargo doc --no-deps --release
|
||||||
|
|
||||||
- name: Prepare documentation for Pages
|
- name: Prepare documentation for Pages
|
||||||
run: |
|
run: |
|
||||||
|
|
||||||
@ -47,28 +58,26 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir -p testcov
|
mkdir -p testcov
|
||||||
cargo tarpaulin --engine llvm --out Html --out Json
|
cargo tarpaulin --engine llvm --out Html --out Json
|
||||||
|
|
||||||
- name: Check for tarpaulin-report.html
|
- name: Check for tarpaulin-report.html
|
||||||
run: |
|
run: |
|
||||||
if [ ! -f tarpaulin-report.html ]; then
|
if [ ! -f tarpaulin-report.html ]; then
|
||||||
echo "tarpaulin-report.html not found!"
|
echo "tarpaulin-report.html not found!"
|
||||||
exit 1
|
exit 1
|
||||||
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)
|
formatted=$(printf "%.2f" "$coverage")
|
||||||
# round to 2 decimal places
|
jq --arg message "$formatted" \
|
||||||
formatted=$(printf "%.2f" "$coverage")
|
'{schemaVersion:1,
|
||||||
# build the badge JSON using the pre-formatted string
|
label:"tarpaulin-report",
|
||||||
jq --arg message "$formatted" \
|
message:$message,
|
||||||
'{schemaVersion:1,
|
color:"blue"}' \
|
||||||
label:"tarpaulin-report",
|
tarpaulin-report.json \
|
||||||
message:$message,
|
> tarpaulin-badge.json
|
||||||
color:"blue"}' \
|
|
||||||
tarpaulin-report.json \
|
|
||||||
> tarpaulin-badge.json
|
|
||||||
|
|
||||||
- name: Save last commit date JSON
|
- name: Save last commit date JSON
|
||||||
run: |
|
run: |
|
||||||
@ -80,7 +89,7 @@ jobs:
|
|||||||
color:"blue"}' \
|
color:"blue"}' \
|
||||||
<(echo '{}') \
|
<(echo '{}') \
|
||||||
> last-commit-date.json
|
> last-commit-date.json
|
||||||
|
|
||||||
- name: Copy files to output directory
|
- name: Copy files to output directory
|
||||||
run: |
|
run: |
|
||||||
mkdir output
|
mkdir output
|
||||||
|
16
.github/workflows/run-unit-tests.yml
vendored
16
.github/workflows/run-unit-tests.yml
vendored
@ -11,11 +11,23 @@ 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:
|
||||||
|
- id: choose
|
||||||
|
uses: ./.github/actions/runner-fallback@v1
|
||||||
|
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: ubuntu-latest
|
runs-on: ${{ fromJson(needs.pick-runner.outputs.runner) }}
|
||||||
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