-
Notifications
You must be signed in to change notification settings - Fork 80
169 lines (147 loc) · 5.04 KB
/
Copy pathci.yml
File metadata and controls
169 lines (147 loc) · 5.04 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: CI
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
push:
branches: [main] # Runs on main after merge
schedule:
- cron: '0 2 * * *' # Nightly at 2 AM UTC
workflow_dispatch:
inputs:
pg_version:
description: 'PostgreSQL version(s) to test'
required: false
default: '17'
type: choice
options:
- '17'
- '18'
- '17, 18'
env:
CARGO_TERM_COLOR: always
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
format:
name: Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
run: |
rustup toolchain install nightly --profile minimal --component rustfmt
rustup default nightly
- name: Check formatting
run: cargo fmt --all -- --check
prepare:
name: Prepare Matrix
runs-on: ubuntu-latest
outputs:
pg_versions: ${{ steps.set-matrix.outputs.pg_versions }}
steps:
- id: set-matrix
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo 'pg_versions=[${{ github.event.inputs.pg_version }}]' >> "$GITHUB_OUTPUT"
elif [ "${{ github.event_name }}" = "pull_request" ]; then
if [ "${{ contains(github.event.pull_request.labels.*.name, 'test-pg18') }}" = "true" ]; then
echo 'pg_versions=[17, 18]' >> "$GITHUB_OUTPUT"
else
echo 'pg_versions=[17]' >> "$GITHUB_OUTPUT"
fi
else
echo 'pg_versions=[17, 18]' >> "$GITHUB_OUTPUT"
fi
test:
name: Clippy & Tests (PG${{ matrix.pg_version }})
runs-on: ubuntu-latest
needs: [format, prepare]
permissions:
contents: read
strategy:
fail-fast: false
matrix:
pg_version: ${{ fromJson(needs.prepare.outputs.pg_versions) }}
# PG18 failures are non-blocking while compatibility is being established
continue-on-error: ${{ matrix.pg_version == 18 }}
steps:
- uses: actions/checkout@v4
- name: Install Rust nightly
run: |
rustup toolchain install nightly --profile minimal --component clippy
rustup default nightly
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
pkg-config \
libssl-dev \
libclang-dev \
clang \
bison \
flex \
libreadline-dev \
zlib1g-dev \
libxml2-dev \
libxslt1-dev \
libicu-dev
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
~/.pgrx
target
key: ${{ runner.os }}-cargo-pgrx-pg${{ matrix.pg_version }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-pgrx-pg${{ matrix.pg_version }}-
- name: Install cargo-pgrx
run: cargo install cargo-pgrx --version 0.16.1 --locked
- name: Initialize pgrx
run: cargo pgrx init --pg${{ matrix.pg_version }} download
- name: Configure git credentials for private repos
run: |
git config --global url."https://${{ secrets.GH_PAT }}@github.com/".insteadOf "https://github.com/"
- name: Run clippy
run: cargo clippy --no-default-features --features pg${{ matrix.pg_version }} -- -D warnings
- name: Run unit tests
run: cargo pgrx test pg${{ matrix.pg_version }}
- name: Run E2E tests (shared_preload_libraries enforcement)
id: e2e_no_preload
run: ./scripts/test-e2e-local.sh --no-preload
- name: Run E2E tests
id: e2e_tests
run: ./scripts/test-e2e-local.sh --pg-version ${{ matrix.pg_version }}
- name: Upload PostgreSQL logs on E2E failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: postgresql-logs-pg${{ matrix.pg_version }}
path: |
~/.pgrx/${{ matrix.pg_version }}.log
~/.pgrx/data-${{ matrix.pg_version }}/log/*.log
if-no-files-found: warn
# TODO: Re-enable once pg_regress tests are stabilized
# - name: Run pg_regress tests
# id: pg_regress
# env:
# PGDATABASE: contrib_regression
# run: |
# ./scripts/pg-start.sh
# cd test/regress
# make installcheck
# - name: Upload pg_regress results on failure
# if: steps.pg_regress.outcome == 'failure'
# uses: actions/upload-artifact@v4
# with:
# name: pg_regress-results
# path: |
# test/regress/regression.out
# test/regress/regression.diffs
# if-no-files-found: ignore
# - name: Stop PostgreSQL after pg_regress
# if: steps.pg_regress.outcome != 'skipped'
# run: ./scripts/pg-stop.sh