Repository navigation
145 lines (127 loc) · 4.43 KB
/
Copy pathci-database.yml
File metadata and controls
145 lines (127 loc) · 4.43 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
141
142
143
144
145
# Registered by the standalone preview repository.
name: Database CI
on:
pull_request:
workflow_dispatch:
permissions:
contents: read
concurrency:
group: database-ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
name: Classify changes
runs-on: ubuntu-latest
outputs:
rust_database: ${{ steps.classify.outputs.rust_database }}
steps:
- name: Check out source
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Resolve comparison base
id: base
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PUSH_BASE_SHA: ${{ github.event.before }}
shell: bash
run: |
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
echo "manual=true" >> "$GITHUB_OUTPUT"
exit 0
fi
base_sha="$PUSH_BASE_SHA"
if [[ "$EVENT_NAME" == "pull_request" ]]; then
base_sha="$PR_BASE_SHA"
fi
{
echo "manual=false"
echo "base_sha=$base_sha"
} >> "$GITHUB_OUTPUT"
- name: Classify changed paths
id: classify
env:
MANUAL: ${{ steps.base.outputs.manual }}
BASE_SHA: ${{ steps.base.outputs.base_sha }}
BASE_REF: ${{ github.base_ref }}
HEAD_REF: ${{ github.head_ref }}
HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
shell: bash
run: |
if [[ "$MANUAL" == "true" ]]; then
echo "rust_database=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Promoting preview to main reruns no lane; macOS CI requires the
# preview verification of the same commit instead.
if [[ "$BASE_REF" == "main" && "$HEAD_REF" == "preview" && "$HEAD_REPOSITORY" == "$GITHUB_REPOSITORY" ]]; then
export LITHE_CI_SCOPE=release_promotion
fi
./scripts/classify-ci-changes.sh "$BASE_SHA" "$GITHUB_SHA" >> "$GITHUB_OUTPUT"
- name: Summarize selected lanes
shell: bash
env:
RUST_DATABASE: ${{ steps.classify.outputs.rust_database }}
run: |
{
echo "### Database CI lanes"
echo "| Lane | Run |"
echo "| --- | --- |"
echo "| Rust database tests | $RUST_DATABASE |"
echo ""
echo "Swift database tests run in **macOS CI → Swift tests**; check **macOS CI gate** for their result."
} >> "$GITHUB_STEP_SUMMARY"
rust-database-tests:
name: Rust database tests
needs: changes
if: needs.changes.outputs.rust_database == 'true'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Check out source
uses: actions/checkout@v7
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Restore Cargo dependencies
uses: actions/cache@v6
with:
path: |
~/.cargo/git
~/.cargo/registry
key: cargo-dependencies-${{ runner.os }}-${{ hashFiles('rust/Cargo.lock') }}
- name: Validate database container configuration
run: docker compose -f infra/docker/database-validation/compose.yaml config --quiet
- name: Check formatting and test database crates
run: |
cargo fmt --manifest-path rust/Cargo.toml -p lithe-db-sidecar -p lithe-db-mcp -- --check
cargo test --manifest-path rust/Cargo.toml -p lithe-db-sidecar
cargo test --manifest-path rust/Cargo.toml -p lithe-db-mcp
gate:
name: Database CI gate
needs:
- changes
- rust-database-tests
if: always()
runs-on: ubuntu-latest
steps:
- name: Verify required jobs
env:
CHANGES_RESULT: ${{ needs.changes.result }}
RUST_DATABASE_SELECTED: ${{ needs.changes.outputs.rust_database }}
RUST_DATABASE_RESULT: ${{ needs.rust-database-tests.result }}
shell: bash
run: |
[[ "$CHANGES_RESULT" == "success" ]]
require_selected_job() {
local selected="$1"
local result="$2"
if [[ "$selected" == "true" ]]; then
[[ "$result" == "success" ]]
else
[[ "$result" == "skipped" ]]
fi
}
require_selected_job "$RUST_DATABASE_SELECTED" "$RUST_DATABASE_RESULT"