Skip to content

Generated a badge from the output of specification tests #93

Generated a badge from the output of specification tests

Generated a badge from the output of specification tests #93

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:
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
id: cargo_test
run: cargo test -p pixlib_parser --verbose --features ${{ matrix.feature }} -- --ignored
continue-on-error: true
- name: Check test output
id: cargo_test_checked
run: |
echo "${{ steps.cargo_test.outputs.data }}" | grep -E '^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$'
- name: Process test output
id: cargo_test_processed
run: |
echo "${{ steps.cargo_test_checked.outputs.data }}" | 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$/scale=2 ; \1 \/ (\1 + \2)/' | bc | awk '{ print $1"%"; }'
- name: Generate passing percentage badge
uses: RubbaBoy/BYOB@v1.3.0
with:
NAME: passing_percent_${{ matrix.feature }}
LABEL: 'Passing percentage'
STATUS: ${{ steps.cargo_test_processed.outputs.data }}
COLOR: 00EEFF
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"