-
Notifications
You must be signed in to change notification settings - Fork 237
150 lines (148 loc) · 6.68 KB
/
Copy pathci.yml
File metadata and controls
150 lines (148 loc) · 6.68 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
146
147
148
149
150
name: ci
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
# Build both pgdog artifacts in parallel:
# - release: plain release binary
# - coverage: llvm-cov instrumented debug binary used by the
# integration suites to produce line coverage for Codecov
build:
runs-on: blacksmith-4vcpu-ubuntu-2404
strategy:
fail-fast: false
matrix:
include:
- artifact: release
path: target/release/pgdog
rust_prefix: build-v1
- artifact: coverage
path: target/llvm-cov-target/debug/pgdog
# Separate prefix: instrumented artifacts live in
# target/llvm-cov-target and must not race with the plain
# build's cache.
rust_prefix: build-cov-debug-v1
steps:
- uses: actions/checkout@v6
- name: Install CI deps
run: bash integration/ci/install-deps.sh
# Compute the binary key before restoring rust-cache: rust-cache restores
# target/ build outputs that would otherwise change the key. Use the
# split cache actions so pgdog binaries are saved immediately after the
# build, before rust-cache's post-job cleanup prunes workspace binaries
# from target/.
- name: Compute cache key
id: cache-key
run: echo "key=pgdog-bin-${{ runner.os }}-${{ matrix.artifact }}-$(bash integration/ci/cache-key.sh)" >> "$GITHUB_OUTPUT"
- name: Restore pgdog binary
id: pgdog-bin
uses: actions/cache/restore@v5
with:
path: ${{ matrix.path }}
key: ${{ steps.cache-key.outputs.key }}
- uses: Swatinem/rust-cache@v2
if: steps.pgdog-bin.outputs.cache-hit != 'true'
with:
prefix-key: ${{ matrix.rust_prefix }}
- name: Build (release)
if: steps.pgdog-bin.outputs.cache-hit != 'true' && matrix.artifact == 'release'
run: cargo build --release --bin pgdog
- name: Build (instrumented debug, for coverage)
if: steps.pgdog-bin.outputs.cache-hit != 'true' && matrix.artifact == 'coverage'
run: bash integration/ci/prepare-instrumented-pgdog.sh debug
- name: Save pgdog binary
if: steps.pgdog-bin.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: ${{ matrix.path }}
key: ${{ steps.cache-key.outputs.key }}
ci:
runs-on: blacksmith-4vcpu-ubuntu-2404
needs: [build]
timeout-minutes: 30
continue-on-error: ${{ matrix.continue_on_error == true }}
strategy:
fail-fast: false
matrix:
include:
- { name: pgbench, script: integration/pgbench/run.sh }
- { name: schema-sync, script: integration/schema_sync/run.sh }
- { name: go, script: integration/go/run.sh }
- { name: js, script: integration/js/pg_tests/run.sh }
- { name: ruby, script: integration/ruby/run.sh }
- { name: java, script: integration/java/run.sh }
- { name: mirror, script: integration/mirror/run.sh }
- { name: sql, script: integration/sql/run.sh }
- { name: toxi, script: integration/toxi/run.sh }
- { name: rust, script: integration/rust/run.sh }
- { name: python, script: integration/python/run.sh }
- { name: two-pc, script: integration/two_pc/run.sh }
- { name: complex, script: integration/complex/run.sh }
- { name: dry-run, script: integration/dry_run/run.sh }
- { name: copy-data, script: integration/copy_data/run.sh }
- { name: load-balancer, script: integration/load_balancer/run.sh }
- { name: tls, script: integration/tls/run.sh }
- { name: resharding, script: integration/resharding/run.sh }
# plugins/run.sh builds 4 plugin crates with cargo, so it needs
# the workspace target/ cache; the other entries just run the
# cached pgdog binary.
- { name: plugins, script: integration/plugins/run.sh, needs_rust_cache: true, continue_on_error: true }
env:
# All suites run against the llvm-cov instrumented debug binary so we
# get line coverage from integration tests, not just unit tests.
PGDOG_BIN: ${{ github.workspace }}/target/llvm-cov-target/debug/pgdog
# NB: cargo llvm-cov report only globs profraw files at the top of
# target/llvm-cov-target, so LLVM_PROFILE_FILE must point there.
LLVM_PROFILE_FILE: ${{ github.workspace }}/target/llvm-cov-target/${{ matrix.name }}-%p-%m.profraw
steps:
- uses: actions/checkout@v6
- name: Install CI deps
run: bash integration/ci/install-deps.sh
- name: Compute cache key
id: cache-key
run: echo "key=pgdog-bin-${{ runner.os }}-coverage-$(bash integration/ci/cache-key.sh)" >> "$GITHUB_OUTPUT"
# rust-cache must run before the binary restore: it lays down a
# stale target/ that can otherwise wipe target binaries when cargo
# reconciles fingerprints during plugin builds.
- name: Restore Rust cache for plugin builds
if: matrix.needs_rust_cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: build-v1
- name: Restore instrumented pgdog binary
uses: actions/cache/restore@v5
with:
path: target/llvm-cov-target/debug/pgdog
key: ${{ steps.cache-key.outputs.key }}
fail-on-cache-miss: true
# The Rust cache (plugins job) can lay down stale .profraw files that
# don't match the restored instrumented binary; start clean.
- name: Prepare coverage profile dir
run: |
mkdir -p target/llvm-cov-target
rm -f target/llvm-cov-target/*.profraw target/llvm-cov-target/*.profdata
- name: Setup dependencies
run: bash integration/ci/setup.sh --with-toxi
- name: Run ${{ matrix.name }}
run: bash ${{ matrix.script }}
- name: Ensure PgDog stopped
if: always()
run: bash integration/ci/ensure-pgdog-stopped.sh
- name: Generate coverage report
if: always()
run: cargo llvm-cov report --package pgdog --lcov --output-path ${{ matrix.name }}.lcov
# Codecov merges uploads per flag server-side, so each suite uploads
# its own lcov under the shared "integration" flag.
- name: Upload coverage to Codecov
if: always()
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ${{ matrix.name }}.lcov
flags: integration
name: integration-${{ matrix.name }}
fail_ci_if_error: false