|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +name: CI |
| 19 | +on: |
| 20 | + pull_request: |
| 21 | + branches: [ main ] |
| 22 | + push: |
| 23 | + branches: [ main ] |
| 24 | + |
| 25 | +# Concurrency strategy: |
| 26 | +# github.workflow: distinguish this workflow from others |
| 27 | +# github.event_name: distinguish `push` event from `pull_request` event |
| 28 | +# github.event.number: set to the number of the pull request if `pull_request` event |
| 29 | +# github.run_id: otherwise, it's a `push` event, only cancel if we rerun the workflow |
| 30 | +# |
| 31 | +# Reference: |
| 32 | +# https://docs.github.com/en/actions/using-jobs/using-concurrency |
| 33 | +# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context |
| 34 | +concurrency: |
| 35 | + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.number || github.run_id }} |
| 36 | + cancel-in-progress: true |
| 37 | +jobs: |
| 38 | + check: |
| 39 | + name: Check |
| 40 | + runs-on: ubuntu-24.04 |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v6 |
| 43 | + - name: Delete rust-toolchain.toml |
| 44 | + run: rm rust-toolchain.toml |
| 45 | + - name: Install toolchain |
| 46 | + uses: dtolnay/rust-toolchain@nightly |
| 47 | + with: |
| 48 | + components: rustfmt,clippy |
| 49 | + - uses: Swatinem/rust-cache@v2 |
| 50 | + - uses: taiki-e/install-action@v2 |
| 51 | + with: |
| 52 | + tool: typos-cli,taplo-cli,hawkeye |
| 53 | + - name: Check all |
| 54 | + run: | |
| 55 | + hawkeye check |
| 56 | + taplo format --check |
| 57 | + typos |
| 58 | + cargo +nightly fmt --all -- --check |
| 59 | + cargo +nightly clippy --all-targets --all-features -- -D warnings |
| 60 | +
|
| 61 | + msrv: |
| 62 | + name: Resolve MSRV |
| 63 | + runs-on: ubuntu-24.04 |
| 64 | + outputs: |
| 65 | + rust-versions: ${{ steps.metadata.outputs.rust-versions }} |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@v6 |
| 68 | + - id: metadata |
| 69 | + run: | |
| 70 | + msrv=$(yq '.package.rust-version' Cargo.toml) |
| 71 | + echo "MSRV: $msrv" |
| 72 | + echo "rust-versions=[\"${msrv}\", \"stable\"]" >> "$GITHUB_OUTPUT" |
| 73 | +
|
| 74 | + test: |
| 75 | + name: Run tests |
| 76 | + needs: msrv |
| 77 | + strategy: |
| 78 | + matrix: |
| 79 | + os: [ ubuntu-24.04, macos-14, windows-2022 ] |
| 80 | + rust-version: ${{ fromJson(needs.msrv.outputs.rust-versions) }} |
| 81 | + runs-on: ${{ matrix.os }} |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v6 |
| 84 | + - name: Delete rust-toolchain.toml |
| 85 | + run: rm rust-toolchain.toml |
| 86 | + - uses: Swatinem/rust-cache@v2 |
| 87 | + - name: Install toolchain |
| 88 | + uses: dtolnay/rust-toolchain@master |
| 89 | + with: |
| 90 | + toolchain: ${{ matrix.rust-version }} |
| 91 | + - name: Build |
| 92 | + run: cargo build --workspace --all-features --bins --tests --examples --benches --lib |
| 93 | + - name: Run unit tests |
| 94 | + shell: bash |
| 95 | + run: cargo test --all-features -- --nocapture |
| 96 | + - name: Run examples |
| 97 | + shell: bash |
| 98 | + run: | |
| 99 | + set -x |
| 100 | + cargo run --example hll_usage |
| 101 | +
|
| 102 | + required: |
| 103 | + name: Required |
| 104 | + runs-on: ubuntu-24.04 |
| 105 | + if: ${{ always() }} |
| 106 | + needs: |
| 107 | + - check |
| 108 | + - test |
| 109 | + steps: |
| 110 | + - name: Guardian |
| 111 | + run: | |
| 112 | + if [[ ! ( \ |
| 113 | + "${{ needs.check.result }}" == "success" \ |
| 114 | + && "${{ needs.test.result }}" == "success" \ |
| 115 | + ) ]]; then |
| 116 | + echo "Required jobs haven't been completed successfully." |
| 117 | + exit -1 |
| 118 | + fi |
0 commit comments