|
| 1 | +name: "CI" |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: {} |
| 5 | + merge_group: {} |
| 6 | + |
| 7 | +env: |
| 8 | + CARGO_TERM_COLOR: always |
| 9 | + |
| 10 | +jobs: |
| 11 | + # Rust format check on GitHub runner |
| 12 | + rust-fmt: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: 📥 Clone and checkout repository |
| 16 | + uses: actions/checkout@v3 |
| 17 | + |
| 18 | + - name: 🚦 Check if CI can be skipped |
| 19 | + id: skip-check |
| 20 | + uses: cariad-tech/merge-queue-ci-skipper@main |
| 21 | + |
| 22 | + - name: 🦀 Install the latest Rust |
| 23 | + if: steps.skip-check.outputs.skip-check != 'true' |
| 24 | + uses: dtolnay/rust-toolchain@stable |
| 25 | + with: |
| 26 | + components: rustfmt |
| 27 | + |
| 28 | + - name: 🔬 Check Rust formatting |
| 29 | + if: steps.skip-check.outputs.skip-check != 'true' |
| 30 | + run: cargo fmt --all -- --check |
| 31 | + |
| 32 | + # License compatibility check on GitHub runner |
| 33 | + cargo-deny: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - name: 📥 Clone and checkout repository |
| 37 | + uses: actions/checkout@v3 |
| 38 | + |
| 39 | + - name: 📜 Check crate license compatibility for root workspace |
| 40 | + uses: EmbarkStudios/cargo-deny-action@v2 |
| 41 | + with: |
| 42 | + command: check bans licenses sources |
| 43 | + |
| 44 | + - name: 📜 Check crate license compatibility for /libraries/rawkit |
| 45 | + uses: EmbarkStudios/cargo-deny-action@v2 |
| 46 | + with: |
| 47 | + command: check bans licenses sources |
| 48 | + manifest-path: libraries/rawkit/Cargo.toml |
| 49 | + |
| 50 | + # Build the web app on the self-hosted wasm runner |
| 51 | + build: |
| 52 | + runs-on: [self-hosted, target/wasm] |
| 53 | + permissions: |
| 54 | + contents: write |
| 55 | + deployments: write |
| 56 | + pull-requests: write |
| 57 | + actions: write |
| 58 | + env: |
| 59 | + RUSTC_WRAPPER: /usr/bin/sccache |
| 60 | + CARGO_INCREMENTAL: 0 |
| 61 | + SCCACHE_DIR: /var/lib/github-actions/.cache |
| 62 | + |
| 63 | + steps: |
| 64 | + - name: 📥 Clone and checkout repository |
| 65 | + uses: actions/checkout@v3 |
| 66 | + |
| 67 | + - name: 🚦 Check if CI can be skipped |
| 68 | + id: skip-check |
| 69 | + uses: cariad-tech/merge-queue-ci-skipper@main |
| 70 | + |
| 71 | + - name: 🗑 Clear wasm-bindgen cache |
| 72 | + if: steps.skip-check.outputs.skip-check != 'true' |
| 73 | + run: rm -r ~/.cache/.wasm-pack || true |
| 74 | + |
| 75 | + - name: 🟢 Install the latest Node.js |
| 76 | + if: steps.skip-check.outputs.skip-check != 'true' |
| 77 | + uses: actions/setup-node@v4 |
| 78 | + with: |
| 79 | + node-version: "latest" |
| 80 | + |
| 81 | + - name: 🚧 Install build dependencies |
| 82 | + if: steps.skip-check.outputs.skip-check != 'true' |
| 83 | + run: | |
| 84 | + cd frontend |
| 85 | + npm run setup |
| 86 | +
|
| 87 | + - name: 🦀 Install the latest Rust |
| 88 | + if: steps.skip-check.outputs.skip-check != 'true' |
| 89 | + run: | |
| 90 | + rustup update stable |
| 91 | +
|
| 92 | + - name: 🦀 Fetch Rust dependencies |
| 93 | + if: steps.skip-check.outputs.skip-check != 'true' |
| 94 | + run: | |
| 95 | + cargo fetch --locked |
| 96 | +
|
| 97 | + - name: 🌐 Build Graphite web code |
| 98 | + if: steps.skip-check.outputs.skip-check != 'true' |
| 99 | + env: |
| 100 | + NODE_ENV: production |
| 101 | + run: mold -run cargo run build web |
| 102 | + |
| 103 | + - name: 📤 Publish to Cloudflare Pages |
| 104 | + if: steps.skip-check.outputs.skip-check != 'true' |
| 105 | + uses: cloudflare/pages-action@1 |
| 106 | + continue-on-error: true |
| 107 | + with: |
| 108 | + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
| 109 | + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
| 110 | + gitHubToken: ${{ secrets.GITHUB_TOKEN }} |
| 111 | + projectName: graphite-dev |
| 112 | + directory: frontend/dist |
| 113 | + |
| 114 | + - name: 👕 Lint Graphite web formatting |
| 115 | + if: steps.skip-check.outputs.skip-check != 'true' |
| 116 | + env: |
| 117 | + NODE_ENV: production |
| 118 | + run: | |
| 119 | + cd frontend |
| 120 | + npm run check |
| 121 | +
|
| 122 | + # Run the Rust tests on the self-hosted native runner |
| 123 | + test: |
| 124 | + runs-on: [self-hosted, target/native] |
| 125 | + env: |
| 126 | + RUSTC_WRAPPER: /usr/bin/sccache |
| 127 | + CARGO_INCREMENTAL: 0 |
| 128 | + SCCACHE_DIR: /var/lib/github-actions/.cache |
| 129 | + |
| 130 | + steps: |
| 131 | + - name: 📥 Clone and checkout repository |
| 132 | + uses: actions/checkout@v3 |
| 133 | + |
| 134 | + - name: 🚦 Check if CI can be skipped |
| 135 | + id: skip-check |
| 136 | + uses: cariad-tech/merge-queue-ci-skipper@main |
| 137 | + |
| 138 | + - name: 🦀 Install the latest Rust |
| 139 | + if: steps.skip-check.outputs.skip-check != 'true' |
| 140 | + run: | |
| 141 | + rustup update stable |
| 142 | +
|
| 143 | + - name: 🦀 Fetch Rust dependencies |
| 144 | + if: steps.skip-check.outputs.skip-check != 'true' |
| 145 | + run: | |
| 146 | + cargo fetch --locked |
| 147 | +
|
| 148 | + - name: 🧪 Run Rust tests |
| 149 | + if: steps.skip-check.outputs.skip-check != 'true' |
| 150 | + env: |
| 151 | + RUSTFLAGS: -Dwarnings |
| 152 | + run: | |
| 153 | + mold -run cargo test --all-features |
0 commit comments