|
| 1 | +--- |
| 2 | +name: CI |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + types: |
| 8 | + - opened |
| 9 | + - synchronize |
| 10 | + - reopened |
| 11 | + - ready_for_review |
| 12 | + paths-ignore: |
| 13 | + - docs/** |
| 14 | + - '**.md' |
| 15 | + - .github/** |
| 16 | + - .gitignore |
| 17 | + push: |
| 18 | + branches: |
| 19 | + - main |
| 20 | + paths-ignore: |
| 21 | + - docs/** |
| 22 | + - '**.md' |
| 23 | + - .github/** |
| 24 | +# run concurrency group for the workflow |
| 25 | +concurrency: |
| 26 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 27 | + cancel-in-progress: true |
| 28 | +jobs: |
| 29 | + changed_files: |
| 30 | + if: ${{ github.event.pull_request.draft == false }} |
| 31 | + runs-on: ubuntu-latest |
| 32 | + name: Test changed-files |
| 33 | + outputs: |
| 34 | + changed-rust-files: ${{ steps.changed-files-yaml.outputs.code_any_changed }} |
| 35 | + changed-lockfile-files: ${{ steps.changed-files-yaml.outputs.lockfile_any_changed }} |
| 36 | + changed-docker-files: ${{ steps.changed-files-yaml.outputs.docker_any_changed }} |
| 37 | + changed-tests-files: ${{ steps.changed-files-yaml.outputs.tests_any_changed }} |
| 38 | + steps: |
| 39 | + # Checkout the repository |
| 40 | + - name: Harden the runner (Audit all outbound calls) |
| 41 | + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 |
| 42 | + with: |
| 43 | + egress-policy: audit |
| 44 | + - name: Checkout Code |
| 45 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 46 | + - name: Get changed files |
| 47 | + id: changed-files-yaml |
| 48 | + uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 |
| 49 | + with: |
| 50 | + files_yaml: | |
| 51 | + code: |
| 52 | + - '**/*.rs' |
| 53 | + - 'rustfmt.toml' |
| 54 | + - 'rust-toolchain.toml' |
| 55 | + lockfile: |
| 56 | + - 'Cargo.lock' |
| 57 | + - 'Cargo.toml' |
| 58 | + docker: |
| 59 | + - 'Dockerfile.development' |
| 60 | + - 'Dockerfile.production' |
| 61 | + - 'docker-compose.yml' |
| 62 | + - 'Cargo.lock' |
| 63 | + - 'Cargo.toml' |
| 64 | + tests: |
| 65 | + - '**/*.rs' |
| 66 | + - tests/**/*.json |
| 67 | + ci: |
| 68 | + if: ${{ github.event.pull_request.draft == false && always() }} |
| 69 | + permissions: |
| 70 | + contents: none |
| 71 | + name: CI |
| 72 | + needs: |
| 73 | + - msrv |
| 74 | + - rustfmt |
| 75 | + - clippy |
| 76 | + runs-on: ubuntu-latest |
| 77 | + steps: |
| 78 | + - name: Harden the runner (Audit all outbound calls) |
| 79 | + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 |
| 80 | + with: |
| 81 | + egress-policy: audit |
| 82 | + - name: Failed |
| 83 | + run: exit 1 |
| 84 | + if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') |
| 85 | + msrv: |
| 86 | + if: ${{ github.event.pull_request.draft == false && github.event_name != 'push' && (needs.changed_files.outputs.changed-rust-files == 'true' || needs.changed_files.outputs.changed-lockfile-files == 'true') }} |
| 87 | + runs-on: ubuntu-latest |
| 88 | + needs: changed_files |
| 89 | + steps: |
| 90 | + # Checkout the repository |
| 91 | + - name: Harden the runner (Audit all outbound calls) |
| 92 | + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 |
| 93 | + with: |
| 94 | + egress-policy: audit |
| 95 | + - name: Checkout Code |
| 96 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 97 | + - name: Prepare |
| 98 | + id: init |
| 99 | + uses: ./.github/actions/prepare |
| 100 | + |
| 101 | + # Get the output of the prepare composite action |
| 102 | + - name: Get cache-hit output |
| 103 | + run: 'echo "Cache hit >>>>>: ${{ steps.init.outputs.cache-hit }}"' |
| 104 | + - name: Install cargo hack |
| 105 | + uses: taiki-e/install-action@7689010b667477e55299b24c373cdf719c945fdf # cargo-hack |
| 106 | + |
| 107 | + # Check the minimum supported Rust version |
| 108 | + - name: Default features |
| 109 | + run: cargo hack check --feature-powerset --locked --rust-version --all-targets |
| 110 | + rustfmt: |
| 111 | + if: ${{ github.event.pull_request.draft == false && github.event_name != 'push' && needs.changed_files.outputs.changed-rust-files == 'true' }} |
| 112 | + needs: changed_files |
| 113 | + runs-on: ubuntu-latest |
| 114 | + steps: |
| 115 | + # Checkout the repository |
| 116 | + - name: Harden the runner (Audit all outbound calls) |
| 117 | + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 |
| 118 | + with: |
| 119 | + egress-policy: audit |
| 120 | + - name: Checkout Code |
| 121 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 122 | + - name: Prepare |
| 123 | + id: init |
| 124 | + uses: ./.github/actions/prepare |
| 125 | + |
| 126 | + # Get the output of the prepare composite action |
| 127 | + - name: Get cache-hit output |
| 128 | + run: 'echo "Cache hit >>>>>: ${{ steps.init.outputs.cache-hit }}"' |
| 129 | + |
| 130 | + # Check the formatting of the code |
| 131 | + - name: Check formatting |
| 132 | + run: cargo fmt --all -- --check |
| 133 | + clippy: |
| 134 | + if: ${{ github.event.pull_request.draft == false && github.event_name != 'push' && needs.changed_files.outputs.changed-rust-files == 'true' }} |
| 135 | + needs: changed_files |
| 136 | + runs-on: ubuntu-latest |
| 137 | + steps: |
| 138 | + # Checkout the repository |
| 139 | + - name: Harden the runner (Audit all outbound calls) |
| 140 | + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 |
| 141 | + with: |
| 142 | + egress-policy: audit |
| 143 | + - name: Checkout Code |
| 144 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 145 | + - name: Prepare |
| 146 | + id: init |
| 147 | + uses: ./.github/actions/prepare |
| 148 | + |
| 149 | + # Get the output of the prepare composite action |
| 150 | + - name: Get cache-hit output |
| 151 | + run: 'echo "Cache hit >>>>>: ${{ steps.init.outputs.cache-hit }}"' |
| 152 | + - name: Install SARIF tools |
| 153 | + run: cargo install clippy-sarif --locked |
| 154 | + - name: Install SARIF tools |
| 155 | + run: cargo install sarif-fmt --locked |
| 156 | + - name: Check |
| 157 | + run: > |
| 158 | + cargo clippy --all-features --all-targets --message-format=json |
| 159 | + | clippy-sarif |
| 160 | + | tee clippy-results.sarif |
| 161 | + | sarif-fmt |
| 162 | + continue-on-error: true |
| 163 | + - name: Report status |
| 164 | + run: cargo clippy --all-features --all-targets -- -D warnings --allow deprecated |
| 165 | + test: |
| 166 | + if: ${{ github.event.pull_request.draft == false && needs.changed_files.outputs.changed-tests-files == 'true' }} |
| 167 | + permissions: |
| 168 | + contents: read |
| 169 | + needs: |
| 170 | + - changed_files |
| 171 | + runs-on: ubuntu-latest |
| 172 | + steps: |
| 173 | + # Checkout the repository |
| 174 | + - name: Harden the runner (Audit all outbound calls) |
| 175 | + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 |
| 176 | + with: |
| 177 | + egress-policy: audit |
| 178 | + - name: Checkout Code |
| 179 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 180 | + - name: Setup Node.js |
| 181 | + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 |
| 182 | + with: |
| 183 | + node-version: '20' |
| 184 | + - name: Prepare |
| 185 | + id: init |
| 186 | + uses: ./.github/actions/prepare |
| 187 | + with: |
| 188 | + components: llvm-tools-preview |
| 189 | + |
| 190 | + # Get the output of the prepare composite action |
| 191 | + - name: Get cache-hit output |
| 192 | + run: 'echo "Cache hit >>>>>: ${{ steps.init.outputs.cache-hit }}"' |
| 193 | + - name: Install cargo hack |
| 194 | + uses: taiki-e/install-action@7689010b667477e55299b24c373cdf719c945fdf # cargo-hack |
| 195 | + - name: Install cargo-llvm-cov |
| 196 | + uses: taiki-e/install-action@16edcff251c6bb06f6878981359f84b77b28e7e2 # cargo-llvm-cov |
| 197 | + - name: Build |
| 198 | + run: cargo test --no-run --locked |
| 199 | + |
| 200 | + # Unit tests coverage |
| 201 | + - name: Run Unit Tests and Generate Coverage Report |
| 202 | + env: |
| 203 | + LLVM_PROFILE_FILE: unit-%p-%m.profraw |
| 204 | + RUSTFLAGS: -Cinstrument-coverage |
| 205 | + RUST_TEST_THREADS: 1 |
| 206 | + run: cargo llvm-cov --workspace --locked --lib --lcov --output-path unit-lcov.info |
0 commit comments