Skip to content

Commit 6bb3853

Browse files
cursoragentlovasoa
andcommitted
Refactor CI matrix and build logic for static linking
Co-authored-by: contact <contact@ophir.dev>
1 parent 31f4202 commit 6bb3853

2 files changed

Lines changed: 44 additions & 26 deletions

File tree

.github/workflows/test.yml

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,49 @@ env:
77

88
jobs:
99
test-unix:
10-
name: ${{ matrix.os }} - ${{ matrix.features }}
10+
name: ${{ matrix.os }} - ${{ matrix.feature-name }}
1111

1212
runs-on: ${{ matrix.os }}
1313

1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest, macos-latest]
17-
features:
18-
- name: "dynamic"
19-
flags: ""
20-
install_deps: true
21-
- name: "static unixODBC"
22-
flags: "--features static"
23-
install_deps: false
24-
- name: "static iODBC"
25-
flags: "--features static,iodbc"
26-
install_deps: false
17+
include:
18+
# Dynamic linking tests
19+
- os: ubuntu-latest
20+
feature-name: "dynamic"
21+
feature-flags: ""
22+
install-deps: true
23+
- os: macos-latest
24+
feature-name: "dynamic"
25+
feature-flags: ""
26+
install-deps: true
27+
# Static unixODBC tests
28+
- os: ubuntu-latest
29+
feature-name: "static unixODBC"
30+
feature-flags: "--features static"
31+
install-deps: false
32+
- os: macos-latest
33+
feature-name: "static unixODBC"
34+
feature-flags: "--features static"
35+
install-deps: false
36+
# Static iODBC tests
37+
- os: ubuntu-latest
38+
feature-name: "static iODBC"
39+
feature-flags: "--features static,iodbc"
40+
install-deps: false
41+
- os: macos-latest
42+
feature-name: "static iODBC"
43+
feature-flags: "--features static,iodbc"
44+
install-deps: false
2745

2846
steps:
2947
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
3048
with:
3149
submodules: 'recursive'
3250

33-
- name: Install system ODBC (if needed)
34-
if: matrix.features.install_deps
51+
- name: Install system ODBC
52+
if: matrix.install-deps
3553
run: |
3654
if [ "$RUNNER_OS" == "Linux" ]; then
3755
sudo apt-get update
@@ -42,34 +60,34 @@ jobs:
4260
shell: bash
4361

4462
- name: Build
45-
run: cargo build --verbose ${{ matrix.features.flags }}
63+
run: cargo build --verbose ${{ matrix.feature-flags }}
4664

4765
- name: Run tests
48-
run: cargo test --verbose ${{ matrix.features.flags }}
66+
run: cargo test --verbose ${{ matrix.feature-flags }}
4967

5068
test-windows:
51-
name: Windows - ${{ matrix.arch }}
69+
name: Windows - ${{ matrix.arch-name }}
5270

5371
runs-on: windows-latest
5472

5573
strategy:
5674
matrix:
57-
arch:
58-
- target: x86_64-pc-windows-msvc
59-
name: "64-bit"
60-
- target: i686-pc-windows-msvc
61-
name: "32-bit"
75+
include:
76+
- arch-name: "64-bit"
77+
target: x86_64-pc-windows-msvc
78+
- arch-name: "32-bit"
79+
target: i686-pc-windows-msvc
6280

6381
steps:
6482
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
6583

6684
- name: Install Rust toolchain
6785
uses: dtolnay/rust-toolchain@stable
6886
with:
69-
target: ${{ matrix.arch.target }}
87+
target: ${{ matrix.target }}
7088

7189
- name: Build
72-
run: cargo build --verbose --target ${{ matrix.arch.target }}
90+
run: cargo build --verbose --target ${{ matrix.target }}
7391

7492
- name: Run tests
75-
run: cargo test --verbose --target ${{ matrix.arch.target }}
93+
run: cargo test --verbose --target ${{ matrix.target }}

build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn create_ltdl_stub(vendor_dir: &Path) -> std::io::Result<()> {
8484
Ok(())
8585
}
8686

87-
#[cfg(feature = "static")]
87+
#[cfg(all(feature = "static", not(feature = "iodbc")))]
8888
fn extract_version_from_configure_ac(configure_ac_path: &Path) -> Option<String> {
8989
let content = fs::read_to_string(configure_ac_path).ok()?;
9090

@@ -107,7 +107,7 @@ fn extract_version_from_configure_ac(configure_ac_path: &Path) -> Option<String>
107107
None
108108
}
109109

110-
#[cfg(feature = "static")]
110+
#[cfg(all(feature = "static", feature = "iodbc"))]
111111
fn extract_iodbc_version(configure_ac_path: &Path) -> Option<String> {
112112
let content = fs::read_to_string(configure_ac_path).ok()?;
113113

0 commit comments

Comments
 (0)