-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a pq-src crate for a bundled feature flag
- Loading branch information
Showing
14 changed files
with
1,525 additions
and
912 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,11 +14,13 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-2019] | ||
features: [default, bundled] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
with: | ||
submodules: recursive | ||
- name: Cache cargo registry | ||
uses: actions/cache@v3 | ||
with: | ||
|
@@ -32,7 +34,7 @@ jobs: | |
echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV | ||
echo "RUSTDOCFLAGS=-D warnings" >> $GITHUB_ENV | ||
- name: Install postgres (Linux) | ||
if: runner.os == 'Linux' | ||
if: runner.os == 'Linux' && matrix.features == 'default' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y libpq-dev postgresql | ||
|
@@ -42,42 +44,71 @@ jobs: | |
sudo service postgresql restart && sleep 3 | ||
- name: Install postgres (MacOS) | ||
if: runner.os == 'macOS' | ||
if: runner.os == 'macOS' && matrix.features == 'default' | ||
run: | | ||
initdb -D /usr/local/var/postgres | ||
pg_ctl -D /usr/local/var/postgres start | ||
sleep 3 | ||
createuser -s postgres | ||
- name: Install postgres (Windows) | ||
if: runner.os == 'Windows' | ||
if: runner.os == 'Windows' && matrix.features == 'default' | ||
shell: bash | ||
run: | | ||
choco install postgresql12 --force --params '/Password:root' | ||
echo "C:\Program Files\PostgreSQL\12\bin" >> $GITHUB_PATH | ||
echo "C:\Program Files\PostgreSQL\12\lib" >> $GITHUB_PATH | ||
echo "PQ_LIB_DIR=C:\Program Files\PostgreSQL\12\lib" >> $GITHUB_ENV | ||
# - name: Add msbuild to PATH | ||
# if: runner.os == 'Windows' && matrix.features == 'bundled' | ||
# uses: microsoft/[email protected] | ||
# with: | ||
# msbuild-architecture: x64 | ||
# - uses: ilammy/msvc-dev-cmd@v1 | ||
# if: runner.os == 'Windows' && matrix.features == 'bundled' | ||
- name: Windows setup (bundled) | ||
if: runner.os == 'Windows' && matrix.features == 'bundled' | ||
shell: bash | ||
run: | | ||
echo "OPENSSL_RUST_USE_NASM=0" >> $GITHUB_ENV | ||
echo OPENSSL_SRC_PERL=C:/Strawberry/perl/bin/perl >> $GITHUB_ENV | ||
# - name: Windows setup (bundled) | ||
# if: runner.os == 'Windows' && matrix.features == 'bundled' | ||
# shell: cmd | ||
# run: | | ||
# cd pq-src/source/ | ||
# src\tools\msvc\build.bat libpq | ||
- name: Install rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: Check | ||
shell: bash | ||
run: | | ||
cargo check | ||
cargo check --no-default-features --features "${{ matrix.features }}" | ||
- name: Tests | ||
shell: bash | ||
run: | | ||
cargo test | ||
cargo test --no-default-features --features "${{ matrix.features }}" | ||
- name: Test compile diesel | ||
shell: bash | ||
run: | | ||
cargo new test_diesel | ||
cd test_diesel | ||
echo "[workspace]" >> Cargo.toml | ||
cargo add diesel --no-default-features --features "postgres" | ||
cargo add pq-sys | ||
echo "[patch.crates-io]" >> Cargo.toml | ||
echo "pq-sys = { path = \"..\" }" >> Cargo.toml | ||
cat Cargo.toml | ||
echo "use diesel::prelude::*;" > src/main.rs | ||
echo "fn main() { PgConnection::establish(\"foo\").unwrap(); }" >> src/main.rs | ||
cat src/main.rs | ||
cargo build | ||
cargo build --features "pq-sys/${{ matrix.features }}" | ||
- name: Test all files included | ||
shell: bash | ||
if: matrix.features == 'bundled' | ||
run: | | ||
cd pq-src | ||
cargo publish --dry-run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "pq-src/source"] | ||
path = pq-src/source | ||
url = https://github.com/postgres/postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[package] | ||
name = "pq-src" | ||
version = "0.1.0" | ||
edition = "2021" | ||
include = [ | ||
"src/*", | ||
"build.rs", | ||
"additional_include/pg_config.h", | ||
"additional_include/pg_config_paths.h", | ||
"additional_include/pg_config_ext.h", | ||
|
||
"source/src/include/*", | ||
"source/src/port/*", | ||
"source/src/common/*", | ||
"source/src/interfaces/libpq/*", | ||
] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[target.'cfg(not(target_os = "windows"))'.dependencies] | ||
openssl-sys = { version = "0.9.93", features = ["vendored"] } | ||
|
||
[build-dependencies] | ||
cc = "1.0.83" | ||
|
||
[target.'cfg(not(target_os = "windows"))'.build-dependencies] | ||
openssl-src = "300" |
Oops, something went wrong.