improve checklist #957
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: build | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| changes: | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| run_build: ${{ steps.delta.outputs.run_build }} | |
| diff_range: ${{ steps.delta.outputs.diff_range }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect non-doc and non-tool changes in current update | |
| id: delta | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| event="${{ github.event_name }}" | |
| action="${{ github.event.action || '' }}" | |
| before="${{ github.event.before || '' }}" | |
| after="${{ github.event.after || '' }}" | |
| base_sha="${{ github.event.pull_request.base.sha || '' }}" | |
| head_sha="${{ github.event.pull_request.head.sha || github.sha }}" | |
| before_valid="false" | |
| if [[ -n "$before" && ! "$before" =~ ^0+$ ]]; then | |
| before_valid="true" | |
| fi | |
| if [[ "$event" == "pull_request" && "$action" == "synchronize" && "$before_valid" == "true" && -n "$after" ]]; then | |
| range="${before}...${after}" | |
| elif [[ "$event" == "pull_request" && -n "$base_sha" && -n "$head_sha" ]]; then | |
| range="${base_sha}...${head_sha}" | |
| elif [[ "$event" == "push" && "$before_valid" == "true" && -n "$after" ]]; then | |
| range="${before}...${after}" | |
| elif [[ "$event" == "push" && -n "$after" ]]; then | |
| range="${after}^...${after}" | |
| else | |
| range="HEAD~1...HEAD" | |
| fi | |
| echo "diff_range=${range}" >> "$GITHUB_OUTPUT" | |
| diff_failed="false" | |
| if files="$(git diff --name-only "$range")"; then | |
| : | |
| else | |
| diff_failed="true" | |
| files="" | |
| fi | |
| echo "changed files in ${range}:" | |
| printf '%s\n' "$files" | |
| run_build="false" | |
| if [[ "$diff_failed" == "true" || -z "$files" ]]; then | |
| run_build="true" | |
| else | |
| while IFS= read -r file; do | |
| [[ -z "$file" ]] && continue | |
| if [[ "$file" != docs/* && "$file" != tools/* && "$file" != *.md ]]; then | |
| run_build="true" | |
| break | |
| fi | |
| done <<< "$files" | |
| fi | |
| echo "run_build=${run_build}" >> "$GITHUB_OUTPUT" | |
| echo "run_build=${run_build}" | |
| build: | |
| needs: changes | |
| if: needs.changes.outputs.run_build == 'true' | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Install libaio | |
| run: sudo apt-get install -y libaio1 libaio-dev | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| components: llvm-tools | |
| - name: Install cargo-nextest | |
| uses: taiki-e/install-action@nextest | |
| - name: Install cargo-llvm-cov | |
| uses: taiki-e/install-action@cargo-llvm-cov | |
| - name: Clippy (default backend) | |
| run: cargo clippy -p doradb-storage --all-targets -- -D warnings | |
| - name: Validate with cargo llvm-cov nextest | |
| env: | |
| CARGO_TARGET_DIR: "target/coverage" | |
| CARGO_LLVM_COV_TARGET_DIR: "target/coverage/llvm-cov-target" | |
| RUST_BACKTRACE: "full" | |
| run: cargo llvm-cov nextest --no-report -p doradb-storage --profile ci | |
| - name: Validate alternate libaio backend | |
| env: | |
| RUST_BACKTRACE: "full" | |
| run: cargo nextest run -p doradb-storage --no-default-features --features libaio --profile ci | |
| - name: Upload nextest JUnit reports | |
| if: ${{ always() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nextest-junit | |
| if-no-files-found: warn | |
| path: | | |
| target/**/nextest/ci/junit.xml | |
| - name: Generate coverage report | |
| env: | |
| CARGO_TARGET_DIR: "target/coverage" | |
| CARGO_LLVM_COV_TARGET_DIR: "target/coverage/llvm-cov-target" | |
| run: > | |
| cargo llvm-cov report | |
| --lcov | |
| --output-path lcov.info | |
| --no-default-ignore-filename-regex | |
| --ignore-filename-regex '(^|/)(target|legacy)(/|$)|/\.cargo/(registry|git)/|/rustlib/src/rust/' | |
| -p doradb-storage | |
| - name: Upload to codecov.io | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: lcov.info | |
| token: ${{secrets.CODECOV_TOKEN}} | |
| docs-or-tools-only: | |
| needs: changes | |
| if: needs.changes.outputs.run_build != 'true' | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Skip heavy CI for docs-only or tools-only delta | |
| run: | | |
| echo "No non-doc and non-tool changes detected in update range: ${{ needs.changes.outputs.diff_range }}" | |
| echo "Compile/test jobs are intentionally skipped." |