diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..000da5c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,152 @@ +# .github/workflows/ci.yml + +name: Rust CI + +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + schedule: + - cron: '0 0 * * 1' # Weekly Sunday midnight UTC + +env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: "-Dwarnings" + CARGO_TERM_COLOR: always + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1.17.0 + with: + target: thumbv6m-none-eabi + + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + with: + workspaces: "." + + - name: Run cargo check + run: cargo check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1.17.0 + with: + components: clippy + target: thumbv6m-none-eabi + + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + with: + workspaces: "." + + - name: Run clippy + run: cargo clippy -- -D warnings + + fmt: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1.17.0 + with: + components: rustfmt + target: thumbv6m-none-eabi + + - name: Check formatting + run: cargo fmt --all -- --check + + build: + name: Build + runs-on: ubuntu-latest + needs: [check, clippy, fmt] + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1.17.0 + with: + target: thumbv6m-none-eabi + + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + with: + workspaces: "." + + - name: Build debug + run: cargo build --verbose + + - name: Build release + run: cargo build --release --verbose + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts + path: target/ + retention-days: 7 + + docs: + name: Documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1.17.0 + with: + components: rust-docs + target: thumbv6m-none-eabi + + - name: Build documentation + run: cargo doc --no-deps --document-private-items + + - name: Upload documentation + uses: actions/upload-artifact@v4 + with: + name: documentation + path: target/thumbv6m-none-eabi/doc/ + retention-days: 7 + + pages: + name: Deploy Docs + runs-on: ubuntu-latest + needs: [docs] + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - uses: actions/checkout@v4 + + - name: Setup Pages + uses: actions/configure-pages@v3 + + - name: Build documentation + run: cargo doc --no-deps + + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + with: + path: target/doc/ + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2