Skip to content

fix: music handling #15

fix: music handling

fix: music handling #15

Workflow file for this run

# CI workflow for Rusty Pong
# Handles testing, code quality checks, and web deployment
name: CI
# Trigger on pushes to master branch, version tags, and PRs
on:
push:
branches:
- master
tags:
- "v*.*.*"
pull_request:
types: [opened, synchronize, reopened]
branches:
- master
env:
CARGO_TERM_COLOR: always
jobs:
# Check code formatting - fastest check
fmt:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libasound2-dev libudev-dev
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --all --check
# Run clippy lints for code quality - second fastest check
clippy:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libasound2-dev libudev-dev
- uses: dtolnay/rust-toolchain@clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo clippy --workspace --all-targets --all-features
# Run tests across multiple Rust toolchains and feature combinations
test:
needs: [clippy, fmt]
name: test ${{ matrix.rust }} ${{ matrix.flags }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
rust: ["stable", "beta", "nightly", "1.82"] # MSRV
flags: ["--no-default-features", "", "--all-features"]
exclude:
- rust: "1.82"
flags: "--all-features"
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libasound2-dev libudev-dev
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: check
if: ${{ matrix.rust == '1.82' }}
run: cargo check --workspace ${{ matrix.flags }}
- name: test
if: ${{ matrix.rust != '1.82' }}
run: cargo test --workspace ${{ matrix.flags }}
# Generate and upload code coverage information
coverage:
needs: [test]
name: Code Coverage
runs-on: ubuntu-latest
env:
LLVMCOV_VERSION: 0.5.14
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libasound2-dev libudev-dev
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
profile: minimal
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
with:
shared-key: rust-cache-coverage-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.LLVMCOV_VERSION }}
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov --version=${{ env.LLVMCOV_VERSION }} --locked
- name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: lcov.info
fail_ci_if_error: false
# Check all possible feature combinations work
feature-checks:
needs: [test]
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libasound2-dev libudev-dev
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: cargo hack
run: cargo hack check --feature-powerset --depth 2
# Generate and test documentation
docs:
needs: [test]
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libasound2-dev libudev-dev
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo doc --workspace --all-features --no-deps --document-private-items
env:
RUSTDOCFLAGS: "--cfg docsrs"
# Build WASM bundle and deploy to GitHub Pages
build-and-deploy:
name: Build and Deploy
needs: [test, coverage, feature-checks, docs]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
permissions:
contents: write
concurrency: ci-${{ github.ref }}
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libasound2-dev libudev-dev binaryen
- name: Install wasm-pack
uses: jetli/[email protected]
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Install Rust dependencies
run: |
rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Build and optimize wasm
run: |
cargo build --release --target wasm32-unknown-unknown
mkdir -p dist
wasm-bindgen --out-dir ./dist --target web target/wasm32-unknown-unknown/release/rusty_pong.wasm
find ./dist -name "*.wasm" -exec wasm-opt -Oz --zero-filled-memory --strip-producers -o {}.opt {} \; -exec mv {}.opt {} \;
- name: Prepare deployment
run: |
mkdir -p dist/assets
cp -r assets/* dist/assets/
cp web/index.html dist/
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: dist
branch: gh-pages
clean: true