Skip to content

Commit b666dfb

Browse files
committed
ci: run e2e tests on macOS and Windows; gate Docker-based tests to Linux
- e2e job uses OS matrix: ubuntu-latest, macos-latest, windows-latest - Use cargo test --test "*" for cross-platform instead of make - Windows setup: enable git long paths; set CMAKE_POLICY_VERSION_MINIMUM=3.5 for aws-lc-sys - tests: gate Docker/testcontainers tests (airgap, push) to Linux and add no-op stubs elsewhere Signed-off-by: Rishi Jat <[email protected]>
1 parent b293ac3 commit b666dfb

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,31 @@ jobs:
6363

6464
e2e-tests:
6565
name: E2E tests
66-
runs-on: ubuntu-latest
66+
runs-on: ${{ matrix.os }}
67+
strategy:
68+
matrix:
69+
os: [ubuntu-latest, macos-latest, windows-latest]
6770
steps:
71+
- name: enable git long paths on Windows
72+
if: matrix.os == 'windows-latest'
73+
run: git config --global core.longpaths true
74+
6875
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
76+
6977
- uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
7078
# FIXME workaround for https://github.com/kubewarden/kwctl/issues/1245
7179
with:
7280
cosign-release: "v2.5.0"
81+
82+
# aws-lc-sys CMakefile contains a directive that has been removed from
83+
# cmake v4 (released Mar 2025). The build failure can be fixed by setting an env var
84+
- name: fix aws-lc-sys building with cmake 4.0.0 (Windows)
85+
if: matrix.os == 'windows-latest'
86+
shell: pwsh
87+
run: echo 'CMAKE_POLICY_VERSION_MINIMUM=3.5' >> $env:GITHUB_ENV
88+
7389
- name: run e2e tests
74-
run: make e2e-tests
90+
run: cargo test --test "*"
7591

7692
coverage:
7793
name: coverage

tests/airgap.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
use assert_cmd::Command;
22
use std::path::{Path, PathBuf};
33
use tempfile::tempdir;
4+
5+
// Only import and use testcontainers on Linux runners where Docker is available
6+
#[cfg(target_os = "linux")]
47
use testcontainers::{core::WaitFor, runners::SyncRunner};
58

69
mod common;
710

11+
// Run this test only on Linux where Docker/testcontainers is available
12+
#[cfg(target_os = "linux")]
813
#[test]
914
fn test_airgap() {
1015
let tempdir = tempdir().unwrap();
@@ -101,6 +106,13 @@ fn test_airgap() {
101106
.success();
102107
}
103108

109+
// Provide a harmless stub on non-Linux platforms so the suite passes
110+
#[cfg(not(target_os = "linux"))]
111+
#[test]
112+
fn test_airgap() {
113+
eprintln!("skipping test_airgap on non-Linux platforms");
114+
}
115+
104116
fn setup_airgap_script_command(script: &Path, tempdir: &Path) -> Command {
105117
let mut cmd = Command::new(script);
106118

tests/e2e.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ use predicates::{prelude::*, str::contains, str::is_empty};
1717
use rstest::rstest;
1818
use sha2::{Digest, Sha256};
1919
use tempfile::tempdir;
20+
// Only import testcontainers on Linux (Docker availability)
21+
#[cfg(target_os = "linux")]
2022
use testcontainers::{core::WaitFor, runners::SyncRunner};
2123

2224
mod common;
@@ -696,6 +698,8 @@ fn test_save_and_load() {
696698
}
697699
}
698700

701+
// Run push test only on Linux where Docker/testcontainers is available
702+
#[cfg(target_os = "linux")]
699703
#[test]
700704
fn test_push() {
701705
let registry_image = testcontainers::GenericImage::new("docker.io/library/registry", "2")
@@ -780,6 +784,13 @@ fn test_push() {
780784
.stdout(contains("my-pod-privileged-policy:v0.1.10"));
781785
}
782786

787+
// Provide a harmless stub on non-Linux platforms so the suite passes
788+
#[cfg(not(target_os = "linux"))]
789+
#[test]
790+
fn test_push() {
791+
eprintln!("skipping test_push on non-Linux platforms");
792+
}
793+
783794
#[rstest]
784795
#[case::pull_policies_before_scaffold(true)]
785796
#[case::pull_policies_on_demand(false)]

0 commit comments

Comments
 (0)