-
Notifications
You must be signed in to change notification settings - Fork 3
168 lines (146 loc) · 5.93 KB
/
build.yml
File metadata and controls
168 lines (146 loc) · 5.93 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
name: Build and Test
on: [push, pull_request]
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
pg-version: 15
- os: macos-latest
pg-version: 15
- os: windows-latest
pg-version: 15
runs-on: ${{ matrix.os }}
steps:
- name: Check out
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
# Ubuntu PostgreSQL setup
- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev
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
sudo apt-get install -y postgresql-${{ matrix.pg-version }} postgresql-server-dev-${{ matrix.pg-version }}
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install git icu4c pkg-config postgresql@${{ matrix.pg-version }}
echo "/opt/homebrew/opt/postgresql@${{ matrix.pg-version }}/bin" >> $GITHUB_PATH
- name: Install PostgreSQL (Windows)
if: runner.os == 'Windows'
run: |
choco install postgresql${{ matrix.pg-version }} --params '/Password:postgres' -y
echo "C:\Program Files\PostgreSQL\${{ matrix.pg-version }}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\Program Files\PostgreSQL\${{ matrix.pg-version }}\lib" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Cache Rust dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Cache pgrx
uses: actions/cache@v3
with:
path: ~/.pgrx
key: ${{ runner.os }}-pgrx-pg${{ matrix.pg-version }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-pgrx-pg${{ matrix.pg-version }}-
- name: Debug pg_config (macOS)
if: runner.os == 'macOS'
run: |
which pg_config || echo "pg_config not found"
find /opt/homebrew -name pg_config | grep pg_config || echo "pg_config not found in homebrew"
brew info postgresql@${{ matrix.pg-version }}
- name: Install pgrx (macOS)
if: runner.os == 'macOS'
run: |
cargo install --locked cargo-pgrx --version 0.13.1 || true
PG_CONFIG_PATH=$(find /opt/homebrew -name pg_config | grep "@${{ matrix.pg-version }}" | head -n 1)
echo "Found pg_config at: $PG_CONFIG_PATH"
# First do a clean init
cargo pgrx init --control-file
# Then explicitly register PostgreSQL 15
cargo pgrx init --pg${{ matrix.pg-version }} $PG_CONFIG_PATH
env:
CARGO_HTTP_TIMEOUT: 300
PKG_CONFIG_PATH: /opt/homebrew/opt/icu4c/lib/pkgconfig:/opt/homebrew/opt/postgresql@${{ matrix.pg-version }}/lib/pkgconfig
- name: Install pgrx (Linux/Windows)
if: runner.os != 'macOS'
run: |
cargo install --locked cargo-pgrx --version 0.13.1 || true
cargo pgrx init
env:
CARGO_HTTP_TIMEOUT: 300
- name: Lint
run: |
cargo fmt --all -- --check
cargo clippy --all -- -D warnings
- name: Build Extension (Windows)
if: runner.os == 'Windows'
run: |
cargo pgrx package --pg-config "C:\Program Files\PostgreSQL\${{ matrix.pg-version }}\bin\pg_config.exe" --target x86_64-pc-windows-msvc
- name: Build Extension (macOS)
if: runner.os == 'macOS'
run: |
PG_CONFIG_PATH=$(find /opt/homebrew -name pg_config | grep "@${{ matrix.pg-version }}" | head -n 1)
cargo pgrx package --pg-config $PG_CONFIG_PATH
- name: Build Extension (Linux)
if: runner.os == 'Linux'
run: cargo pgrx package --pg-config $(which pg_config)
- name: Upload Extension Artifact (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: pg_sqids-${{ runner.os }}
path: target/release/pg_sqids-pg${{ matrix.pg-version }}/lib/pg_sqids.so
- name: Upload Extension Artifact (macOS)
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: pg_sqids-${{ runner.os }}
path: target/release/pg_sqids-pg${{ matrix.pg-version }}/lib/pg_sqids.dylib
- name: Upload Extension Artifact (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: pg_sqids-${{ runner.os }}
path: target/release/pg_sqids-pg${{ matrix.pg-version }}/lib/pg_sqids.dll
- name: Test
run: cargo test --all
check:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Cache Rust dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-