Skip to content

Commit

Permalink
feat: deploy pages
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAlcibiades committed Dec 27, 2024
1 parent 496d642 commit a0bd5a9
Show file tree
Hide file tree
Showing 3 changed files with 481 additions and 1,910 deletions.
66 changes: 49 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
strategy:
fail-fast: false
matrix:
rust: [ "stable", "beta", "nightly", "1.80" ] # MSRV
rust: [ "stable", "beta", "nightly", "1.82" ] # MSRV
flags: [ "--no-default-features", "", "--all-features" ]
exclude:
# Skip because some features have highest MSRV.
- rust: "1.80" # MSRV
- rust: "1.82" # MSRV
flags: "--all-features"
steps:
- uses: actions/checkout@v4
Expand All @@ -37,10 +37,10 @@ jobs:
cache-on-failure: true
# Only run tests on the latest stable and above
- name: check
if: ${{ matrix.rust == '1.80' }} # MSRV
if: ${{ matrix.rust == '1.82' }} # MSRV
run: cargo check --workspace ${{ matrix.flags }}
- name: test
if: ${{ matrix.rust != '1.80' }} # MSRV
if: ${{ matrix.rust != '1.82' }} # MSRV
run: cargo test --workspace ${{ matrix.flags }}

coverage:
Expand All @@ -49,28 +49,20 @@ jobs:
env:
LLVMCOV_VERSION: 0.5.14
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
profile: minimal
components: clippy, rustfmt

- name: Cache rust dependencies
uses: Swatinem/rust-cache@v2
- uses: Swatinem/rust-cache@v2
with:
shared-key: rust-cache-hyper-server-coverage-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.LLVMCOV_VERSION }}

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:
Expand Down Expand Up @@ -122,4 +114,44 @@ jobs:
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --all --check
- run: cargo fmt --all --check

build-and-deploy:
name: Build and Deploy
needs: [test, coverage, feature-checks, clippy, docs, fmt]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
permissions:
contents: write
concurrency: ci-${{ github.ref }}
steps:
- uses: actions/checkout@v4

- name: Install wasm-pack
uses: jetli/[email protected]

- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown

- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true

- name: Build wasm
run: |
cargo build --release --target wasm32-unknown-unknown
wasm-bindgen --out-dir ./dist --target web target/wasm32-unknown-unknown/release/rusty_pong.wasm
- 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 # The folder the action should deploy
branch: gh-pages # The branch the action should deploy to
clean: true # Automatically remove deleted files from deploy branch
Loading

0 comments on commit a0bd5a9

Please sign in to comment.