Skip to content

Generated a badge from the output of specification tests #100

Generated a badge from the output of specification tests

Generated a badge from the output of specification tests #100

Workflow file for this run

name: Rust
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install g++ pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --all --verbose --features bevy/x11
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install g++ pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: cargo test --all --verbose --features bevy/x11
test-game-specific:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
feature: ["test_risp8", "test_riu8", "test_ric", "test_riwc", "test_rikn", "test_rikwa"]
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install g++ pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: cargo test -p pixlib_parser --verbose --features ${{ matrix.feature }} -- --ignored > test_results.txt
continue-on-error: true
- name: Check test output
run: |
sed -i -nE '/^test result: [A-Z]+. [0-9]+ passed; [0-9]+ failed; [0-9]+ ignored; [0-9]+ measured; [0-9]+ filtered out; finished in [0-9]+\.[0-9]+s$/p' test_results.txt
grep -E '^test result: ' test_results.txt
- name: Process test output
id: process_test_output
run: |
sed -E 's/^test result: [A-Z]+. ([0-9]+) passed; ([0-9]+) failed; [0-9]+ ignored; [0-9]+ measured; [0-9]+ filtered out; finished in [0-9]+\.[0-9]+s$/\1 \2/' test_results.txt | awk '{ printf "percentage=%.1f\n", 100 * $1 / ($1 + $2); }' >> "$GITHUB_OUTPUT"
- name: Calculate color value
id: calculate_color_value
run: |
if awk 'BEGIN { exit !('"${{ steps.process_test_output.outputs.percentage }}"' > 99); }'; then
echo "color=0AF" >> "$GITHUB_OUTPUT"
elif awk 'BEGIN { exit !('"${{ steps.process_test_output.outputs.percentage }}"' > 66); }'; then
echo "color=0C0" >> "$GITHUB_OUTPUT"
elif awk 'BEGIN { exit !('"${{ steps.process_test_output.outputs.percentage }}"' > 33); }'; then
echo "color=CA0" >> "$GITHUB_OUTPUT"
else
echo "color=B00" >> "$GITHUB_OUTPUT"
fi
- name: Generate passing percentage badge
uses: RubbaBoy/BYOB@v1.3.0
with:
NAME: passing_percent_${{ matrix.feature }}
LABEL: Passing percentage
STATUS: ${{ steps.process_test_output.outputs.percentage }}%
COLOR: ${{ steps.calculate_color_value.outputs.color }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install g++ pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check formatting
run: cargo fmt --all --check
- name: Check code quality
run: cargo clippy --all --features bevy/x11 -- -Dwarnings
web:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./repo
steps:
- uses: actions/checkout@v4
with:
path: ./repo
fetch-depth: 0
- name: Install dependencies
run: |
sudo apt-get install g++ pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0
cargo install wasm-bindgen-cli
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
workspaces: "repo -> target"
- name: Build debug
run: cargo build --target wasm32-unknown-unknown --all --verbose -Zbuild-std=std,panic_abort
- name: Generate files for debug
run: |
mkdir -p ../out/debug
wasm-bindgen --no-typescript --target web --out-dir ../out/debug/ --out-name "pixlib" ./target/wasm32-unknown-unknown/debug/pixlib.wasm
- name: Build release
run: cargo build --profile release-small --target wasm32-unknown-unknown --all --verbose -Zbuild-std=std,panic_abort
- name: Generate files for release
run: |
mkdir -p ../out/release
wasm-bindgen --no-typescript --target web --out-dir ../out/release/ --out-name "pixlib" ./target/wasm32-unknown-unknown/release-small/pixlib.wasm
- name: Update gh-pages and push changes
run: |
git config user.email "github-actions@github.com"
git config user.name "github-actions"
git clean -xdf
git checkout gh-pages
git pull
cp -R ../out/* .
test ! -d ./target
git add .
git commit -m "Update files" && git push || echo "No changes to commit"