From b9b88da50d225be8bf206084dd4a565517101090 Mon Sep 17 00:00:00 2001 From: Logan Garbarini Date: Mon, 4 Sep 2023 16:46:02 -0700 Subject: [PATCH] fix MacOS tests and CI --- .bazelrc | 1 - .github/workflows/ci.yaml | 3 ++- tests/BUILD | 18 ++++++++++++++++++ tests/tool/tests/test_mkappimage.py | 9 +++++++-- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.bazelrc b/.bazelrc index 37e761d..60f9a08 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,7 +1,6 @@ test --announce_rc test --test_output=errors test --test_verbose_timeout_warnings -test --spawn_strategy=linux-sandbox build --incompatible_strict_action_env build --keep_going test --keep_going diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3ed40e8..1b83888 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -6,7 +6,7 @@ permissions: read-all jobs: test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} env: USE_BAZEL_VERSION: ${{ matrix.bazel-version }} strategy: @@ -14,6 +14,7 @@ jobs: matrix: python-version: ["3.8", "3.9", "3.10", "3.11"] bazel-version: ["5.x", "6.x", "latest"] + os: ["ubuntu-latest", "macos-latest"] steps: - uses: actions/checkout@v3 diff --git a/tests/BUILD b/tests/BUILD index b8a0b00..3d6f620 100644 --- a/tests/BUILD +++ b/tests/BUILD @@ -14,6 +14,9 @@ appimage_test( size = "small", args = ["--appimage-extract-and-run"], # One way to run if no libfuse2 is available binary = ":test_sh", + target_compatible_with = [ + "@platforms//os:linux", + ], ) sh_binary( @@ -26,6 +29,9 @@ appimage_test( size = "small", binary = ":test_mount-is-readonly", tags = ["requires-fakeroot"], # This helps tests failing with `fusermount3: mount failed: Operation not permitted` + target_compatible_with = [ + "@platforms//os:linux", + ], ) cc_binary( @@ -43,6 +49,9 @@ appimage_test( binary = ":test_cc", env = {"MY_APPIMAGE_ENV": "overwritten"}, # environment variables are propagated from the binary target env attr tags = ["requires-fakeroot"], + target_compatible_with = [ + "@platforms//os:linux", + ], ) sh_test( @@ -79,6 +88,9 @@ appimage_test( ":appimage_data_filegroup", ], env = {"APPIMAGE_EXTRACT_AND_RUN": "1"}, # Another way to run if no libfuse2 is available + target_compatible_with = [ + "@platforms//os:linux", + ], ) appimage( @@ -100,6 +112,9 @@ py_test( size = "small", srcs = ["test_appimage.py"], data = [":appimage_py"], + target_compatible_with = [ + "@platforms//os:linux", + ], deps = [requirement("pytest")], ) @@ -130,4 +145,7 @@ appimage_test( binary = ":runfiles_test_sh", env = {"RUNFILES_LIB_DEBUG": "1"}, tags = ["requires-fakeroot"], + target_compatible_with = [ + "@platforms//os:linux", + ], ) diff --git a/tests/tool/tests/test_mkappimage.py b/tests/tool/tests/test_mkappimage.py index 28ca611..9a9d9cc 100644 --- a/tests/tool/tests/test_mkappimage.py +++ b/tests/tool/tests/test_mkappimage.py @@ -12,13 +12,18 @@ from appimage.private.tool import mkappimage -def test_deps() -> None: - """Test that the runtime and mksquashfs can be executed.""" +# NOTE: mypy warns about `untyped decorator`. Since this is a test, just ignore typing on this line +@pytest.mark.skipif(sys.platform.startswith("linux") is False, reason="AppImage can only run on Linux") # type: ignore +def test_appimage_deps() -> None: + """Test that the runtime can be executed on Linux.""" runtime_path = mkappimage._get_path_or_raise("rules_appimage/tests/tool/tests/appimage_runtime_native") cmd = [os.fspath(runtime_path), "--appimage-version"] output = subprocess.run(cmd, check=True, text=True, stderr=subprocess.PIPE).stderr assert output.startswith("AppImage runtime version") + +def test_mksquashfs_deps() -> None: + """Test that mksquashfs can be executed.""" cmd = [os.fspath(mkappimage.MKSQUASHFS), "-version"] output = subprocess.run(cmd, check=True, text=True, stdout=subprocess.PIPE).stdout assert output.startswith("mksquashfs version")