-
Notifications
You must be signed in to change notification settings - Fork 32
115 lines (107 loc) · 4.09 KB
/
ci.yml
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
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- master
name: CI Tests
jobs:
check_and_test:
name: Check
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-2019]
features: [default, bundled, buildtime_bindgen]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: recursive
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Set environment variables
shell: bash
run: |
echo "RUSTFLAGS=-D warnings" >> $GITHUB_ENV
echo "RUSTDOCFLAGS=-D warnings" >> $GITHUB_ENV
echo "BINDGEN_EXTRA_CLANG_ARGS=-I./pq-src/source/src/interfaces/libpq/ -I./pq-src/source/src/include/ -I ./pq-src/additional_include" >> $GITHUB_ENV
- name: Install postgres (Linux)
if: runner.os == 'Linux' && matrix.features == 'default'
run: |
sudo apt-get update
sudo apt-get install -y libpq-dev postgresql
echo "host all all 127.0.0.1/32 md5" > sudo tee -a /etc/postgresql/10/main/pg_hba.conf
sudo service postgresql restart && sleep 3
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
sudo service postgresql restart && sleep 3
- name: Install postgres (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' && 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 --no-default-features --features "${{ matrix.features }}"
- name: Tests
shell: bash
run: |
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
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