Create pre-release tests that run as a github workflow. (#991) * Create a version of the tests that run as a gitlab workflow. - This will become the smoke test before the release workflow. - The buildkite workflows are still needed for the cross platform testing. * do not build distro:all, that has to be manual * stop smoke testing doc_build, that brings in java and we do not have that defined * stamp version ito MODULE.bazel * put zip symlink test behind a tag for bazel 8 * allow tags in the matrix Co-authored-by: Chuck Grindel <chuck.grindel@gmail.com>
diff --git a/.bazelrc b/.bazelrc index 9cbe44f..ccd9dce 100644 --- a/.bazelrc +++ b/.bazelrc
@@ -1 +1 @@ -build --enable_workspace +# Intentionally blank
diff --git a/.github/workflows/checks.sh b/.github/workflows/checks.sh new file mode 100755 index 0000000..0696c54 --- /dev/null +++ b/.github/workflows/checks.sh
@@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail + + +FILTERS=() +if [[ -n "${TEST_FILTER:-}" ]] ; then + FILTERS=(--build_tag_filters="${TEST_FILTER}" --test_tag_filters="${TEST_FILTER}") +fi + +TESTS=$(bazel query 'filter(".*_test$", //tests/...)') + +bazel_cmd=(bazel test --build_tests_only "${FILTERS[@]}" -- ${TESTS} //examples/... -//tests/rpm/...) + +echo "${bazel_cmd[@]}" +"${bazel_cmd[@]}" +exit_code="$?" +if [ "${exit_code}" -ne 0 ] ; then + exit "${exit_code}" +fi + +if [ -n "${BUILD_DISTRO:-}" ] ; then + bazel build //distro:distro + exit_code="$?" + if [ "${exit_code}" -ne 0 ] ; then + echo "Could not build //distro:distro" + exit "${exit_code}" + fi +fi + +exit "${exit_code}"
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..ad9fb19 --- /dev/null +++ b/.github/workflows/checks.yml
@@ -0,0 +1,67 @@ +name: checks + +on: + push: + branches: + - "main" + + pull_request: + branches: + - "main" + + merge_group: {} + + workflow_call: {} + +permissions: + contents: read + +jobs: + checks: + strategy: + fail-fast: false + matrix: + include: + - name: "Bazel 8.x: @rules_pkg (Linux x64)" + bazel_version: "8.x" + build_distro: "true" + filter: "" + runner: "ubuntu-latest" + + - name: "Bazel 7.x: @rules_pkg (Linux x64)" + bazel_version: "7.x" + build_distro: "" + filter: "-REQUIRES_BAZEL_8" + runner: "ubuntu-latest" + + runs-on: + - "${{ matrix.runner }}" + + steps: + - uses: "actions/checkout@v6" + + - name: "Run (Bash)" + working-directory: "${{ github.workspace }}" + env: + BUILD_DISTRO: "${{ matrix.build_distro }}" + USE_BAZEL_VERSION: "${{ matrix.bazel_version }}" + TEST_FILTER: "${{ matrix.filter }}" + run: bash "${{ github.workspace }}/.github/workflows/checks.sh" + + status: + runs-on: + - "ubuntu-latest" + + needs: + - "checks" + if: always() + + steps: + - name: "Report status" + env: + RESULT: "${{ needs.checks.result }}" + run: | + echo "Status: ${RESULT}" + if [[ "${RESULT}" != "success" ]]; then + exit 1 + fi
diff --git a/MODULE.bazel b/MODULE.bazel index 6eaf859..7390ae0 100644 --- a/MODULE.bazel +++ b/MODULE.bazel
@@ -1,6 +1,6 @@ module( name = "rules_pkg", - version = "1.2.0", # Must sync with version.bzl. + version = "", # set by release pipeline from version.bzl. compatibility_level = 1, repo_name = "rules_pkg", ) @@ -11,10 +11,10 @@ bazel_dep(name = "bazel_skylib", version = "1.7.1") # Only for development -bazel_dep(name = "platforms", version = "0.0.10", dev_dependency = True) -bazel_dep(name = "rules_cc", version = "0.0.17", dev_dependency = True) +bazel_dep(name = "platforms", version = "1.0.0", dev_dependency = True) +bazel_dep(name = "rules_cc", version = "0.1.1", dev_dependency = True) +bazel_dep(name = "rules_shell", version = "0.6.1", dev_dependency = True) bazel_dep(name = "stardoc", version = "0.7.2", dev_dependency = True) -bazel_dep(name = "rules_shell", version = "0.3.0", dev_dependency = True) # Find the system rpmbuild if one is available. find_rpm = use_extension("//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild_bzlmod", dev_dependency = True)
diff --git a/distro/BUILD b/distro/BUILD index 389924b..5d3cc43 100644 --- a/distro/BUILD +++ b/distro/BUILD
@@ -57,7 +57,9 @@ name = "small_module", srcs = ["//:MODULE.bazel"], outs = ["MODULE.bazel"], - cmd = "sed -e '/### INTERNAL ONLY/,$$d' $(location //:MODULE.bazel) >$@", + cmd = """sed -e 's/version = ""/version = "{version}"/' -e '/### INTERNAL ONLY/,$$d' $(location //:MODULE.bazel) >$@""".format( + version = version, + ), ) genrule(
diff --git a/tests/tar/BUILD b/tests/tar/BUILD index 4362e46..fe45dfa 100644 --- a/tests/tar/BUILD +++ b/tests/tar/BUILD
@@ -638,17 +638,24 @@ # Test with symlinks # -raw_symlinks(name = "raw_symlinks") +raw_symlinks( + name = "raw_symlinks", + tags = ["REQUIRES_BAZEL_8"], +) pkg_tar( name = "raw_symlinks_tar", srcs = [":raw_symlinks"], include_runfiles = True, + tags = ["REQUIRES_BAZEL_8"], ) verify_archive_test( name = "raw_symlinks_test", - tags = ["no_windows"], + tags = [ + "REQUIRES_BAZEL_8", + "no_windows", + ], target = ":raw_symlinks_tar", # This test checks using relative symlinks, but Bazel always writes absolute # symlinks on windows.
diff --git a/tests/zip/BUILD b/tests/zip/BUILD index c95568b..c2c4276 100644 --- a/tests/zip/BUILD +++ b/tests/zip/BUILD
@@ -272,6 +272,7 @@ create_fake_symlink( name = "fake_symlink", link = "fake_symlink", + tags = ["REQUIRES_BAZEL_8"], target = "../does_not_exist", ) @@ -281,6 +282,7 @@ ":fake_symlink", "//tests:file_and_link", ], + tags = ["REQUIRES_BAZEL_8"], ) py_test( @@ -302,7 +304,6 @@ ":test_zip_package_dir_substitution.zip", ":test_zip_permissions.zip", ":test_zip_stored", - ":test_zip_symlink", ":test_zip_timestamp.zip", ":test_zip_tree.zip", ], @@ -313,6 +314,21 @@ ) py_test( + name = "zip_symlink_test", + srcs = [ + "zip_symlink_test.py", + ], + data = [ + ":test_zip_symlink", + ], + python_version = "PY3", + tags = ["REQUIRES_BAZEL_8"], + deps = [ + ":zip_test_lib", + ], +) + +py_test( name = "zip_byte_for_byte_test", srcs = [ "zip_byte_for_byte_test.py",
diff --git a/tests/zip/zip_symlink_test.py b/tests/zip/zip_symlink_test.py new file mode 100644 index 0000000..9c0b00e --- /dev/null +++ b/tests/zip/zip_symlink_test.py
@@ -0,0 +1,31 @@ +# Copyright 2025 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + +from tests.zip import zip_test_lib + + +class ZipContentsTests(zip_test_lib.ZipContentsTestBase): + + def test_symlink(self): + self.assertZipFileContent("test_zip_symlink.zip", [ + {"filename": "BUILD", "islink": False}, + {"filename": "fake_symlink", "islink": True}, # raw symlink -> keep symlink + {"filename": "outer_BUILD", "islink": False},# nonraw symlink -> copy + ]) + + +if __name__ == "__main__": + unittest.main()
diff --git a/tests/zip/zip_test.py b/tests/zip/zip_test.py index 941c00c..c7efebb 100644 --- a/tests/zip/zip_test.py +++ b/tests/zip/zip_test.py
@@ -12,12 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import datetime -import filecmp import os import sys import unittest -import zipfile from python.runfiles import runfiles from tests.zip import zip_test_lib @@ -150,14 +147,6 @@ {"filename": "loremipsum.txt", "crc": LOREM_CRC, "size": 543}, ]) - def test_symlink(self): - self.assertZipFileContent("test_zip_symlink.zip", [ - {"filename": "BUILD", "islink": False}, - {"filename": "fake_symlink", "islink": True}, # raw symlink -> keep symlink - {"filename": "outer_BUILD", "islink": False},# nonraw symlink -> copy - ]) - - if __name__ == "__main__": unittest.main()