|
| 1 | +name: Build |
| 2 | +on: [push, workflow_call] |
| 3 | + |
| 4 | +permissions: |
| 5 | + contents: write |
| 6 | + |
| 7 | +jobs: |
| 8 | + lint: |
| 9 | + runs-on: "windows-latest" |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + - name: install stable rust |
| 13 | + run: rustup install stable |
| 14 | + - uses: Swatinem/rust-cache@v2 |
| 15 | + - name: Format check |
| 16 | + run: cargo fmt --check |
| 17 | + - name: Clippy |
| 18 | + run: cargo clippy -- --deny warnings |
| 19 | + docs: |
| 20 | + runs-on: "windows-latest" |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + - name: install stable rust |
| 24 | + run: rustup install stable |
| 25 | + - uses: Swatinem/rust-cache@v2 |
| 26 | + - name: Build docs |
| 27 | + run: cargo doc --no-deps |
| 28 | + - name: Generate index.html |
| 29 | + shell: cmd |
| 30 | + # u wot? |
| 31 | + run: | |
| 32 | + echo|set /p="<meta http-equiv="refresh" content="0; url=ick/">" > target/doc/index.html |
| 33 | + exit /B 0 |
| 34 | + - name: Upload artifacts (docs) |
| 35 | + uses: actions/upload-artifact@v4 |
| 36 | + with: |
| 37 | + name: docs |
| 38 | + path: | |
| 39 | + target/doc |
| 40 | + if-no-files-found: error |
| 41 | + retention-days: 1 |
| 42 | + - name: Deploy docs |
| 43 | + uses: peaceiris/actions-gh-pages@v3 |
| 44 | + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/initial' }} |
| 45 | + with: |
| 46 | + publish_branch: gh-pages |
| 47 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + publish_dir: target/doc |
| 49 | + force_orphan: true |
| 50 | + tests: |
| 51 | + runs-on: ${{ matrix.os }} |
| 52 | + strategy: |
| 53 | + matrix: |
| 54 | + os: [ "ubuntu-latest", "windows-latest" ] |
| 55 | + fail-fast: false |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + - name: install stable rust |
| 59 | + run: rustup install stable |
| 60 | + - uses: Swatinem/rust-cache@v2 |
| 61 | + with: |
| 62 | + key: ${{ matrix.os }} |
| 63 | + - name: Unit tests |
| 64 | + run: cargo test |
| 65 | + - name: Unit tests (release mode) |
| 66 | + run: cargo test --release |
| 67 | + - name: Build (debug) |
| 68 | + run: cargo build |
| 69 | + - name: Build (release) |
| 70 | + run: cargo build --release |
| 71 | + - name: Upload artifacts (debug) |
| 72 | + uses: actions/upload-artifact@v4 |
| 73 | + with: |
| 74 | + name: ${{ format('debug-{0}', matrix.os) }} |
| 75 | + path: | |
| 76 | + target/debug/ick |
| 77 | + target/debug/ick.d |
| 78 | + target/debug/ick.exe |
| 79 | + target/debug/ick.pdb |
| 80 | + if-no-files-found: error |
| 81 | + retention-days: 1 |
| 82 | + - name: Upload artifacts (release) |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: ${{ format('release-{0}', matrix.os) }} |
| 86 | + path: | |
| 87 | + target/release/ick |
| 88 | + target/release/ick.d |
| 89 | + target/release/ick.exe |
| 90 | + target/release/ick.pdb |
| 91 | + if-no-files-found: error |
| 92 | + retention-days: 1 |
| 93 | + results: |
| 94 | + if: ${{ always() }} |
| 95 | + runs-on: ubuntu-latest |
| 96 | + name: Final Results |
| 97 | + needs: [tests, lint, docs] |
| 98 | + steps: |
| 99 | + - run: exit 1 |
| 100 | + # see https://stackoverflow.com/a/67532120/4907315 |
| 101 | + if: >- |
| 102 | + ${{ |
| 103 | + contains(needs.*.result, 'failure') |
| 104 | + || contains(needs.*.result, 'cancelled') |
| 105 | + }} |
0 commit comments