Open
ci: add PR quality gate workflow #1092
luojiyinAdd on Sep 16
ci: add PR quality gate workflow #1092
Open
Total: 1 files changed+95-0
| @@ -0,0 +1,95 @@ | |||
| 1 | +name: ci | ||
| 2 | + | ||
| 3 | +on: | ||
| 4 | + pull_request: | ||
| 5 | + push: | ||
| 6 | + branches: [main] | ||
| 7 | + | ||
| 8 | +permissions: | ||
| 9 | + contents: read | ||
| 10 | + | ||
| 11 | +concurrency: | ||
| 12 | + group: ci-${{ github.ref }} | ||
| 13 | + cancel-in-progress: true | ||
| 14 | + | ||
| 15 | +env: | ||
| 16 | + CARGO_TERM_COLOR: always | ||
| 17 | + | ||
| 18 | +jobs: | ||
| 19 | + rust-fmt: | ||
| 20 | + name: fmt | ||
| 21 | + runs-on: ubuntu-latest | ||
| 22 | + steps: | ||
| 23 | + - uses: actions/checkout@v7 | ||
| 24 | + with: | ||
| 25 | + fetch-depth: 0 | ||
| 26 | + - uses: dtolnay/rust-toolchain@stable | ||
| 27 | + with: | ||
| 28 | + components: rustfmt | ||
| 29 | + - name: Check changed Rust files | ||
| 30 | + shell: bash | ||
| 31 | + run: | | ||
| 32 | + set -euo pipefail | ||
| 33 | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
| 34 | + base="${{ github.event.pull_request.base.sha }}" | ||
| 35 | + else | ||
| 36 | + base="${{ github.event.before }}" | ||
| 37 | + fi | ||
| 38 | + mapfile -t files < <(git diff --name-only "$base" "$GITHUB_SHA" -- '*.rs') | ||
| 39 | + for file in "${files[@]}"; do | ||
| 40 | + rustfmt --edition 2021 --check "$file" | ||
| 41 | + done | ||
| 42 | + | ||
| 43 | + rust-clippy: | ||
| 44 | + name: clippy | ||
| 45 | + runs-on: ubuntu-latest | ||
| 46 | + steps: | ||
| 47 | + - uses: actions/checkout@v7 | ||
| 48 | + - uses: dtolnay/rust-toolchain@stable | ||
| 49 | + with: | ||
| 50 | + components: clippy | ||
| 51 | + - uses: Swatinem/rust-cache@v2 | ||
| 52 | + - run: cargo clippy --workspace --exclude atomcode-codingplan-crypto --all-targets | ||
| 53 | + | ||
| 54 | + rust-test: | ||
| 55 | + name: test | ||
| 56 | + runs-on: ubuntu-latest | ||
| 57 | + steps: | ||
| 58 | + - uses: actions/checkout@v7 | ||
| 59 | + - uses: dtolnay/rust-toolchain@stable | ||
| 60 | + - uses: Swatinem/rust-cache@v2 | ||
| 61 | + - run: cargo test --workspace --all-targets | ||
| 62 | + | ||
| 63 | + webui: | ||
| 64 | + name: webui | ||
| 65 | + runs-on: ubuntu-latest | ||
| 66 | + defaults: | ||
| 67 | + run: | ||
| 68 | + working-directory: webui | ||
| 69 | + steps: | ||
| 70 | + - uses: actions/checkout@v7 | ||
| 71 | + - uses: actions/setup-node@v7 | ||
| 72 | + with: | ||
| 73 | + node-version: "22" | ||
| 74 | + cache: npm | ||
| 75 | + cache-dependency-path: webui/package-lock.json | ||
| 76 | + - run: npm ci | ||
| 77 | + - run: npm test | ||
| 78 | + - run: npm run typecheck | ||
| 79 | + - run: npm run build | ||
| 80 | + | ||
| 81 | + jetbrains: | ||
| 82 | + name: jetbrains | ||
| 83 | + runs-on: ubuntu-latest | ||
| 84 | + timeout-minutes: 30 | ||
| 85 | + defaults: | ||
| 86 | + run: | ||
| 87 | + working-directory: extensions/jetbrains | ||
| 88 | + steps: | ||
| 89 | + - uses: actions/checkout@v7 | ||
| 90 | + - uses: actions/setup-java@v6 | ||
| 91 | + with: | ||
| 92 | + distribution: temurin | ||
| 93 | + java-version: "21" | ||
| 94 | + cache: gradle | ||
| 95 | + - run: ./gradlew test --no-daemon | ||