Skip to content

Run unit tests conditionally (depending on game version specified) #88

Run unit tests conditionally (depending on game version specified)

Run unit tests conditionally (depending on game version specified) #88

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
run: cargo test --all --verbose --features bevy/x11,${{ matrix.feature }} -- --ignored
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"