-
Notifications
You must be signed in to change notification settings - Fork 2
203 lines (180 loc) · 7.33 KB
/
ci.yaml
File metadata and controls
203 lines (180 loc) · 7.33 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: CI
on:
push:
branches:
- next
pull_request:
branches:
- main
- next
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: "false"
jobs:
Test:
strategy:
fail-fast: false # We want all of them to run, even if one fails
matrix:
os: ["buildjet-4vcpu-ubuntu-2204"]
pg: ["13", "14", "15", "16", "17", "18"]
runs-on: ${{ matrix.os }}
env:
RUSTC_WRAPPER: sccache
SCCACHE_DIR: /home/runner/.cache/sccache
RUST_TOOLCHAIN: ${{ matrix.rust || 'stable' }}
# Github token is there to avoid hitting the rate limits (which does happen for some reason when querying the latest release)
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install PostgreSQL (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get install -y wget gnupg
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update -y -qq --fix-missing
sudo apt-get install -y postgresql-${{ matrix.pg }} postgresql-server-dev-${{ matrix.pg }}
sudo chmod a+rwx `/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config --pkglibdir` `/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config --sharedir`/extension /var/run/postgresql/
- name: Install PostgreSQL (macOS)
if: runner.os == 'macOS'
run: |
brew install postgresql@${{ matrix.pg_version }}
echo "/usr/local/opt/postgresql@${{ matrix.pg_version }}/bin" >> $GITHUB_PATH
- name: Set up prerequisites and environment
run: |
sudo apt-get update -y -qq --fix-missing
echo ""
echo "----- Install sccache -----"
mkdir -p $HOME/.local/bin
curl -L https://github.com/mozilla/sccache/releases/download/v0.2.15/sccache-v0.2.15-x86_64-unknown-linux-musl.tar.gz | tar xz
mv -f sccache-v0.2.15-x86_64-unknown-linux-musl/sccache $HOME/.local/bin/sccache
chmod +x $HOME/.local/bin/sccache
echo "$HOME/.local/bin" >> $GITHUB_PATH
mkdir -p /home/runner/.cache/sccache
echo ""
echo "----- Set up dynamic variables -----"
cat $GITHUB_ENV
echo ""
echo "----- Install system dependencies -----"
sudo apt-get install -y \
build-essential \
llvm-14-dev libclang-14-dev clang-14 \
gcc \
libssl-dev \
libz-dev \
make \
pkg-config \
strace \
zlib1g-dev
echo ""
echo "----- Print env -----"
env
echo ""
- name: Cache cargo registry
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/registry
~/.cargo/git
key: tests-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '.github/workflows/tests.yml') }}
- name: Cache sccache directory
uses: actions/cache@v4
continue-on-error: false
with:
path: /home/runner/.cache/sccache
key: pgrx-tests-sccache-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '.github/workflows/tests.yml') }}
- name: Start sccache server
run: sccache --start-server
- name: Print sccache stats (before run)
run: sccache --show-stats
- name: Install cargo-pgrx
run: |
PGRX_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="pgrx")|.version')
cargo install --locked --version=$PGRX_VERSION cargo-pgrx --debug --force
cargo pgrx init --pg${{ matrix.pg }} /usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config
- name: Run tests
run: echo "\q" | cargo pgrx run pg${{ matrix.pg }} && cargo test --no-default-features --features pg${{ matrix.pg }}
- name: Build
run: cargo pgrx package --features pg${{ matrix.pg }} --pg-config /usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: typeid-${{matrix.pg}}
path: |
target/release/typeid-pg${{ matrix.pg }}
# Attempt to make the cache payload slightly smaller.
- name: Clean up built PGRX files
run: |
cd target/debug/deps/
for built_file in $(find * -type f -executable -print | grep -v "\.so$"); do
base_name=$(echo $built_file | cut -d- -f1);
for basefile in "$base_name".*; do
[ -f "$basefile" ] || continue;
echo "Removing $basefile"
rm $basefile
done;
echo "Removing $built_file"
rm $built_file
done
- name: Stop sccache server
run: sccache --stop-server || true
Install:
runs-on: ubuntu-latest
strategy:
matrix:
os: ["buildjet-4vcpu-ubuntu-2204"]
pg: ["16"]
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install PostgreSQL (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get install -y wget gnupg
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update -y -qq --fix-missing
sudo apt-get install -y postgresql-${{ matrix.pg }} postgresql-server-dev-${{ matrix.pg }}
sudo chmod a+rwx `/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config --pkglibdir` `/usr/lib/postgresql/${{ matrix.pg }}/bin/pg_config --sharedir`/extension /var/run/postgresql/
- name: Install PostgreSQL (macOS)
if: runner.os == 'macOS'
run: |
brew install postgresql@${{ matrix.pg }}
echo "/usr/local/opt/postgresql@${{ matrix.pg }}/bin" >> $GITHUB_PATH
- name: Install cargo-pgrx
run: |
PGRX_VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[]|select(.name=="pgrx")|.version')
cargo install --locked --version=$PGRX_VERSION cargo-pgrx --debug --force
cargo pgrx init --pg${{ matrix.pg }} $(which pg_config)
- name: Install TypeID/pgrx
run: |
cargo pgrx install --no-default-features --release --sudo
- name: Start PostgreSQL
run: |
sudo systemctl start postgresql.service
pg_isready
# superuser (-s), can create databases (-d) and roles (-r), no password prompt (-w) named runner
sudo -u postgres createuser -s -d -r -w runner
- name: Verify install
run: |
createdb -U runner runner
psql -U runner -c "create extension typeid;"
psql -U runner -c "select typeid_generate('user');"
rustfmt:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run rustfmt
run: cargo fmt -- --check