Skip to content

Commit

Permalink
CI: support testing on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
amyspark committed Sep 12, 2024
1 parent f71408e commit 5326449
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 8 deletions.
66 changes: 58 additions & 8 deletions .github/workflows/example-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,43 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Clone Git repository
uses: actions/checkout@v4
- name: Install pkgconf
if: startsWith(matrix.os, 'ubuntu')
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: pkgconf

- name: Setup Meson + Ninja
if: startsWith(matrix.os, 'windows')
run: |
python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install meson ninja
- name: Setup MSVC for test
if: startsWith(matrix.os, 'windows')
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x86_64

# https://github.com/pkgconf/pkgconf/issues/364
- name: Install pkgconf
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
git clone https://github.com/amyspark/pkgconf --branch msvc
cd pkgconf
meson setup build --prefix=$CARGO_HOME
meson compile -C build
meson install -C build
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable${{ matrix.toolchain-suffix }}

- name: Clone Git repository
uses: actions/checkout@v4

- name: Install cargo-c applet
run: |
cargo install --path .
Expand Down Expand Up @@ -62,6 +91,13 @@ jobs:
working-directory: example-project
run: |
sudo cp -r temp/usr/local/* /usr/local/
- name: Install into Cargo root
if: startsWith(matrix.os, 'windows')
shell: bash
working-directory: example-project
run: |
cargo cinstall --verbose --release --prefix=$CARGO_HOME
- name: Test pkg-config
if: startsWith(matrix.os, 'macos')
Expand All @@ -70,12 +106,6 @@ jobs:
test "$(pkg-config --cflags example_project)" = "-I/usr/local/include/example-project-0.1"
test "$(pkg-config --libs example_project)" = "-L/usr/local/lib -lexample-project"
- name: Install pkgconf
if: startsWith(matrix.os, 'ubuntu')
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: pkgconf

- name: Test pkgconf
if: startsWith(matrix.os, 'ubuntu')
run: |
Expand All @@ -90,6 +120,18 @@ jobs:
test "${CFLAGS%% }" = "-I/usr/local/include/example-project-0.1"
test "${LIBS%% }" = "-L/usr/local/lib/${ARCHDIR} -lexample-project"
- name: Test pkgconf
if: startsWith(matrix.os, 'windows')
shell: bash
run: |
set -x
pkgconf --version
CFLAGS=$(pkgconf --cflags example_project)
LIBS=$(pkgconf --libs example_project)
test "${CFLAGS%% }" = "-I$CARGO_HOME/bin/../include/example-project-0.1"
test "${LIBS%% }" = "-L$CARGO_HOME/bin/../lib -lexample-project"
- name: Update dynamic linker cache
if: startsWith(matrix.os, 'ubuntu')
run: |
Expand All @@ -101,3 +143,11 @@ jobs:
run: |
make
- name: Test usage from C (Meson)
if: startsWith(matrix.os, 'windows')
working-directory: example-project/usage-from-c
shell: pwsh
run:
meson setup build
meson compile -C build
meson test -C build
7 changes: 7 additions & 0 deletions example-project/usage-from-c/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project('example', 'c')

dep = dependency('example_project', static: true, required: true)

exe = executable('run_tests', files('run_tests.c'), dependencies: dep)

test('run_tests', exe)

0 comments on commit 5326449

Please sign in to comment.