Skip to content

Commit

Permalink
First pass at github ci (#60)
Browse files Browse the repository at this point in the history
compile to mac+windows+wasm+linux for every PR into main
  • Loading branch information
varoonp123 committed Aug 2, 2023
1 parent 2880ff6 commit 7709df6
Show file tree
Hide file tree
Showing 2 changed files with 172 additions and 0 deletions.
171 changes: 171 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
name: CI

on:
pull_request:
push:
branches:
- main

jobs:
ci-pass:
name: CI is green
runs-on: ubuntu-latest
needs:
- style
- test
- wasm
- docs
steps:
- run: exit 0

style:
name: Check Style

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache deps
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install rust
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt

- name: cargo fmt -- --check
run: cargo fmt -- --check

- name: temporary workaround - fmt all files under src
# Workaround for rust-lang/cargo#7732
run: cargo fmt -- --check $(find . -name '*.rs' -print)

test:
name: ${{ matrix.name }}
needs: [style]

runs-on: ${{ matrix.os || 'ubuntu-latest' }}
strategy:
matrix:
name:
- linux / nightly
- macOS / nightly
- windows / nightly

include:
- name: linux / nightly
rust: nightly
os: ubuntu-latest
- name: macOS / nightly
os: macOS-latest
rust: nightly
- name: windows / nightly
os: windows-latest
rust: nightly
target: x86_64-pc-windows-msvc

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install bevy deps
if: matrix.os == 'ubuntu-latest'
run: |
set -euxo pipefail
sudo apt install -y lld g++ pkg-config libx11-dev libasound2-dev libudev-dev
shell: bash
- name: Cache deps
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install rust
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: ${{ matrix.rust || 'stable' }}
targets: ${{ matrix.target }}

- name: Create Cargo.lock
run: cargo update

- name: Run tests
run: |
set -euxo pipefail
cargo check
cargo check --features arcade
shell: bash

docs:
name: Docs
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Cache deps
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}


- name: Install Rust
uses: dtolnay/rust-toolchain@nightly

- name: Install bevy deps
run: |
set -euxo pipefail
sudo apt install -y lld g++ pkg-config libx11-dev libasound2-dev libudev-dev
shell: bash

- name: Check documentation
run: cargo doc --no-deps --document-private-items --all-features

wasm:
name: WASM
needs: [style]

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Cache deps
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Install rust
uses: dtolnay/rust-toolchain@nightly
with:
targets: wasm32-unknown-unknown

- name: Build wasm assets
run: ./build_wasm.sh
1 change: 1 addition & 0 deletions build_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ rm -rf ./out/
mkdir ./out
rustup target add wasm32-unknown-unknown
cargo build --release --target wasm32-unknown-unknown
cargo install wasm-bindgen-cli
wasm-bindgen --out-dir ./out/ --target web ./target/wasm32-unknown-unknown/release/thetawave.wasm
cp -R ./wasm-page-template/* ./out/
cp -R ./assets ./out/

0 comments on commit 7709df6

Please sign in to comment.