Skip to content

Commit 1128bf7

Browse files
committed
CI: support testing on Windows
1 parent f71408e commit 1128bf7

File tree

2 files changed

+65
-8
lines changed

2 files changed

+65
-8
lines changed

.github/workflows/example-project.yml

+58-8
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,43 @@ jobs:
2525
runs-on: ${{ matrix.os }}
2626

2727
steps:
28-
- name: Clone Git repository
29-
uses: actions/checkout@v4
28+
- name: Install pkgconf
29+
if: startsWith(matrix.os, 'ubuntu')
30+
uses: awalsh128/cache-apt-pkgs-action@latest
31+
with:
32+
packages: pkgconf
33+
34+
- name: Setup Meson + Ninja
35+
if: startsWith(matrix.os, 'windows')
36+
run: |
37+
python3 -m pip install --upgrade pip setuptools wheel
38+
python3 -m pip install meson ninja
39+
40+
- name: Setup MSVC for test
41+
if: startsWith(matrix.os, 'windows')
42+
uses: ilammy/msvc-dev-cmd@v1
43+
with:
44+
arch: x86_64
3045

3146
- name: Install Rust
3247
uses: dtolnay/rust-toolchain@stable
3348
with:
3449
toolchain: stable${{ matrix.toolchain-suffix }}
3550

51+
# https://github.com/pkgconf/pkgconf/issues/364
52+
- name: Install pkgconf
53+
if: startsWith(matrix.os, 'windows')
54+
shell: bash
55+
run: |
56+
git clone https://github.com/amyspark/pkgconf --branch msvc
57+
cd pkgconf
58+
meson setup build --prefix=$CARGO_HOME
59+
meson compile -C build
60+
meson install -C build
61+
62+
- name: Clone Git repository
63+
uses: actions/checkout@v4
64+
3665
- name: Install cargo-c applet
3766
run: |
3867
cargo install --path .
@@ -62,6 +91,13 @@ jobs:
6291
working-directory: example-project
6392
run: |
6493
sudo cp -r temp/usr/local/* /usr/local/
94+
95+
- name: Install into Cargo root
96+
if: startsWith(matrix.os, 'windows')
97+
shell: bash
98+
working-directory: example-project
99+
run: |
100+
cargo cinstall --verbose --release --prefix=$CARGO_HOME
65101
66102
- name: Test pkg-config
67103
if: startsWith(matrix.os, 'macos')
@@ -70,12 +106,6 @@ jobs:
70106
test "$(pkg-config --cflags example_project)" = "-I/usr/local/include/example-project-0.1"
71107
test "$(pkg-config --libs example_project)" = "-L/usr/local/lib -lexample-project"
72108
73-
- name: Install pkgconf
74-
if: startsWith(matrix.os, 'ubuntu')
75-
uses: awalsh128/cache-apt-pkgs-action@latest
76-
with:
77-
packages: pkgconf
78-
79109
- name: Test pkgconf
80110
if: startsWith(matrix.os, 'ubuntu')
81111
run: |
@@ -90,6 +120,18 @@ jobs:
90120
test "${CFLAGS%% }" = "-I/usr/local/include/example-project-0.1"
91121
test "${LIBS%% }" = "-L/usr/local/lib/${ARCHDIR} -lexample-project"
92122
123+
- name: Test pkgconf
124+
if: startsWith(matrix.os, 'windows')
125+
shell: bash
126+
run: |
127+
set -x
128+
pkgconf --version
129+
CFLAGS=$(pkgconf --cflags example_project)
130+
LIBS=$(pkgconf --libs example_project)
131+
132+
test "${CFLAGS%% }" = "-I$CARGO_HOME/bin/../include/example-project-0.1"
133+
test "${LIBS%% }" = "-L$CARGO_HOME/bin/../lib -lexample-project"
134+
93135
- name: Update dynamic linker cache
94136
if: startsWith(matrix.os, 'ubuntu')
95137
run: |
@@ -101,3 +143,11 @@ jobs:
101143
run: |
102144
make
103145
146+
- name: Test usage from C (Meson)
147+
if: startsWith(matrix.os, 'windows')
148+
working-directory: example-project/usage-from-c
149+
shell: pwsh
150+
run:
151+
meson setup build
152+
meson compile -C build
153+
meson test -C build
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
project('example', 'c')
2+
3+
dep = dependency('example_project', static: true, required: true)
4+
5+
exe = executable('run_tests', files('run_tests.c'), dependencies: dep)
6+
7+
test('run_tests', exe)

0 commit comments

Comments
 (0)