From a647a2afc3f54e21e2ab5e2e56a78849bd8c553d Mon Sep 17 00:00:00 2001 From: Justyna Hudziak Date: Thu, 1 Aug 2024 12:42:55 +0200 Subject: [PATCH] Add CI & CD for Wasm --- .github/workflows/continuous_deployment.yml | 31 ++++++++++++++++++++ .github/workflows/continuous_integration.yml | 25 ++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/continuous_deployment.yml create mode 100644 .github/workflows/continuous_integration.yml diff --git a/.github/workflows/continuous_deployment.yml b/.github/workflows/continuous_deployment.yml new file mode 100644 index 0000000..caa4eb1 --- /dev/null +++ b/.github/workflows/continuous_deployment.yml @@ -0,0 +1,31 @@ +# based on: https://plippe.github.io/blog/2021/07/12/rust-wasm-github.html +name: Continuous deployment +on: + workflow_run: + branches: [main] + workflows: [Continuous integration] + types: [completed] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: wasm32-unknown-unknown + + - uses: jetli/wasm-pack-action@v0.4.0 + - uses: jetli/wasm-bindgen-action@v0.2.0 + + - uses: actions/checkout@v4 + + - run: wasm-pack build --target web --release + - run: mkdir ./wasm/pkg && cp ./pkg/rusty_weather_lib.js ./pkg/rusty_weather_lib_bg.wasm ./wasm/pkg + + - uses: seanmiddleditch/gha-publish-to-git@master + with: + branch: gh-pages + github_token: ${{ secrets.GITHUB_TOKEN }} + source_folder: ./wasm + diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml new file mode 100644 index 0000000..00b6fbd --- /dev/null +++ b/.github/workflows/continuous_integration.yml @@ -0,0 +1,25 @@ +# from: https://plippe.github.io/blog/2021/07/12/rust-wasm-github.html +name: Continuous integration +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - run: cargo test --all + + format: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - run: cargo fmt --all -- --check + + clippy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - run: cargo clippy --all -- -D warnings