-
Notifications
You must be signed in to change notification settings - Fork 3
140 lines (130 loc) · 4.56 KB
/
build.yml
File metadata and controls
140 lines (130 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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."