diff --git a/.github/scripts/validate_yaml.py b/.github/scripts/validate_yaml.py new file mode 100644 index 000000000000..962c3607a8f2 --- /dev/null +++ b/.github/scripts/validate_yaml.py @@ -0,0 +1,58 @@ +"""Validate the YAML files for GitHub Actions workflows.""" + +import os + +import yaml + +# Ensure every job is in the list of blocking jobs. +with open( + os.path.join(os.path.dirname(__file__), '../workflows/test_runner.yml'), 'r' +) as f: + data = yaml.safe_load(f) + + all_jobs = data['jobs'].keys() + blocking_jobs = data['jobs']['all_blocking_tests']['needs'] + for job in all_jobs: + if job != 'all_blocking_tests': + if job not in blocking_jobs: + raise ValueError( + 'Job %s is not in the list of blocking jobs.' + % (job) + ) + +# Ensure every job with a continuous prefix conditions every step on whether we +# are in a continuous run. +for root, dirs, files in os.walk( + os.path.join(os.path.dirname(__file__), '../workflows') +): + for file in files: + if file.endswith('.yml'): + with open(os.path.join(root, file), 'r') as f: + data = yaml.safe_load(f) + if 'jobs' not in data: + continue + jobs = data['jobs'] + for job in jobs: + if 'steps' not in jobs[job]: + continue + continuous_condition = 'inputs.continuous-prefix' in jobs[job]['name'] + steps = jobs[job]['steps'] + for step in steps: + if 'if' in step: + if continuous_condition: + if 'continuous-run' not in step['if']: + raise ValueError( + 'Step %s in job %s does not check the continuous-run ' + 'condition' % (step['name'], job) + ) + elif 'continuous-run' in step['if']: + raise ValueError( + 'Step %s in job %s checks the continuous-run condition but ' + 'the job does not contain the continuous-prefix' + % (step['name'], job) + ) + elif continuous_condition: + raise ValueError( + 'Step %s in job %s does not check the continuous-run ' + 'condition' % (step['name'], job) + ) diff --git a/.github/workflows/staleness_check.yml b/.github/workflows/staleness_check.yml index 9fc9480221e7..de40b0d4aed5 100644 --- a/.github/workflows/staleness_check.yml +++ b/.github/workflows/staleness_check.yml @@ -6,6 +6,11 @@ on: - cron: 0 10 * * * workflow_call: inputs: + continuous-run: + required: true + description: "Boolean string denoting whether this run is continuous -- + empty string for presubmit, non-empty string for continuous." + type: string safe-checkout: required: false description: "The SHA key for the commit we want to run over" @@ -20,6 +25,11 @@ jobs: matrix: branch: [main, 25.x, 27.x, 28.x] os: [{ name: Linux, value: ubuntu-latest}] + exclude: + # If we are in a presubmit run, only test main + - branch: ${{ !inputs.continuous-run && '25.x' }} + - branch: ${{ !inputs.continuous-run && '27.x' }} + - branch: ${{ !inputs.continuous-run && '28.x' }} name: Test staleness ${{ matrix.os.name }} ${{ github.head_ref && 'PR' || matrix.branch }} runs-on: ${{ matrix.os.value }} diff --git a/.github/workflows/test_bazel.yml b/.github/workflows/test_bazel.yml index a61c66271141..1b25c50db5fa 100644 --- a/.github/workflows/test_bazel.yml +++ b/.github/workflows/test_bazel.yml @@ -3,10 +3,19 @@ name: Bazel Tests on: workflow_call: inputs: + continuous-run: + required: true + description: "Boolean string denoting whether this run is continuous -- + empty string for presubmit, non-empty string for continuous." + type: string safe-checkout: required: true description: "The SHA key for the commit we want to run over" type: string + continuous-prefix: + required: true + description: "The prefix for tests that should only be run continuously" + type: string permissions: contents: read @@ -24,26 +33,30 @@ jobs: bazelversion: '6.4.0' # Not running Bazel 6 with bzlmod, because it doesn't support use_repo_rule in rules_jvm_external bzlmod: false + continuous-only: true runs-on: ${{ matrix.runner }}-latest - name: Examples ${{ matrix.runner }} ${{ matrix.bazelversion }}${{ matrix.bzlmod && ' (bzlmod)' || '' }} + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Examples ${{ matrix.runner }} ${{ matrix.bazelversion }}${{ matrix.bzlmod && ' (bzlmod)' || '' }} steps: - name: Checkout pending changes + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: Windows startup flags - if: runner.os == 'Windows' + if: ${{ runner.os == 'Windows' && (!matrix.continuous-only || inputs.continuous-run) }} working-directory: examples shell: bash run: echo "startup --output_user_root=C:/ --windows_enable_symlinks" >> .bazelrc - name: Configure Bazel version + if: ${{ !matrix.continuous-only || inputs.continuous-run }} working-directory: examples shell: bash run: echo "${{ matrix.bazelversion }}" > .bazelversion - name: Run tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel@v3 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} diff --git a/.github/workflows/test_cpp.yml b/.github/workflows/test_cpp.yml index 4b36b561c223..dca08be2cd38 100644 --- a/.github/workflows/test_cpp.yml +++ b/.github/workflows/test_cpp.yml @@ -3,10 +3,20 @@ name: C++ Tests on: workflow_call: inputs: + continuous-run: + required: true + description: "Boolean string denoting whether this run is continuous -- + empty string for presubmit, non-empty string for continuous." + type: string safe-checkout: required: true description: "The SHA key for the commit we want to run over" type: string + continuous-prefix: + required: true + description: "The prefix for tests that should only be run continuously" + type: string + permissions: contents: read @@ -18,12 +28,12 @@ jobs: matrix: config: - { name: Optimized, flags: --config=opt } - - { name: Debug, flags: --config=dbg } + - { name: Debug, flags: --config=dbg, continuous-only: true } - { name: ASAN, flags: --config=asan, runner: ubuntu-22-4core } - - { name: MSAN, flags: --config=docker-msan, runner: ubuntu-22-4core } - - { name: TSAN, flags: --config=tsan, runner: ubuntu-22-4core } - - { name: UBSAN, flags: --config=ubsan } - - { name: No-RTTI, flags: --cxxopt=-fno-rtti } + - { name: MSAN, flags: --config=docker-msan, runner: ubuntu-22-4core, continuous-only: true } + - { name: TSAN, flags: --config=tsan, runner: ubuntu-22-4core, continuous-only: true } + - { name: UBSAN, flags: --config=ubsan, continuous-only: true } + - { name: No-RTTI, flags: --cxxopt=-fno-rtti, continuous-only: true } include: # Set defaults - image: us-docker.pkg.dev/protobuf-build/containers/test/linux/sanitize@sha256:3d959f731dc5c54af4865c31ee2bd581ec40028adcdf4c038f3122581f595191 @@ -46,14 +56,16 @@ jobs: cache_key: TcMalloc targets: "//src/... //src/google/protobuf/compiler:protoc_aarch64_test //third_party/utf8_range/..." image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:6.3.0-aarch64-68e662b3a56b881804dc4e9d45f949791cbc4b94" - name: Linux ${{ matrix.config.name }} + name: ${{ matrix.config.continuous-only && inputs.continuous-prefix || '' }} Linux ${{ matrix.config.name }} runs-on: ${{ matrix.config.runner || 'ubuntu-latest' }} steps: - name: Checkout pending changes + if: ${{ !matrix.config.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: Run tests + if: ${{ !matrix.config.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel-docker@v3 with: image: ${{ matrix.image }} @@ -131,29 +143,34 @@ jobs: - flags: -Dprotobuf_BUILD_EXAMPLES=ON -DCMAKE_CXX_STANDARD=14 - name: Ninja flags: -G Ninja -DCMAKE_CXX_STANDARD=14 + continuous-only: true - name: Shared flags: -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_EXAMPLES=ON -DCMAKE_CXX_STANDARD=14 + continuous-only: true - name: C++17 flags: -DCMAKE_CXX_STANDARD=17 # TODO Re-enable this. #- name: C++20 # flags: -DCMAKE_CXX_STANDARD=20 - name: Linux CMake ${{ matrix.name}} + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Linux CMake ${{ matrix.name}} runs-on: ubuntu-latest steps: - name: Checkout pending changes + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: Setup sccache + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/sccache@v3 with: cache-prefix: linux-cmake credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - name: Run tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/docker@v3 with: image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.13.3-63dd26c0c7a808d92673a3e52e848189d4ab0f17 @@ -198,6 +215,8 @@ jobs: linux-cmake-examples: name: Linux CMake Examples + # Skip this test on presubmit + if: ${{ inputs.continuous-run }} runs-on: ubuntu-latest steps: - name: Checkout pending changes @@ -234,25 +253,29 @@ jobs: flags: -DCMAKE_CXX_STANDARD=14 - name: C++17 flags: -DCMAKE_CXX_STANDARD=17 + continuous-only: true - name: C++20 flags: -DCMAKE_CXX_STANDARD=20 - name: Linux CMake GCC ${{ matrix.name }} + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Linux CMake GCC ${{ matrix.name }} runs-on: ubuntu-latest steps: - name: Checkout pending changes + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} submodules: recursive - name: Setup sccache + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/sccache@v3 with: cache-prefix: linux-cmake-gcc credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} - name: Run tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/docker@v3 with: image: us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:12.2-6.3.0-63dd26c0c7a808d92673a3e52e848189d4ab0f17 @@ -337,6 +360,7 @@ jobs: cache_key: macos-12-bazel7 bazel: test //src/... //third_party/utf8_range/... bazel_version: '7.1.2' + continuous-only: true - name: MacOS Apple Silicon (build only) Bazel os: macos-12 cache_key: macos-12-arm @@ -352,14 +376,17 @@ jobs: cache_key: windows-2022-bazel7 bazel: test //src/... @com_google_protobuf_examples//... --test_tag_filters=-conformance --build_tag_filters=-conformance bazel_version: '7.1.2' - name: ${{ matrix.name }} + continuous-only: true + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} ${{ matrix.name }} runs-on: ${{ matrix.os }} steps: - name: Checkout pending changes + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: Run tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel@v3 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} @@ -385,6 +412,7 @@ jobs: -Dprotobuf_BUILD_EXAMPLES=ON vsversion: '2022' cache-prefix: windows-2022-cmake + continuous-only: true - name: Windows CMake 2019 os: windows-2019 flags: >- @@ -395,6 +423,7 @@ jobs: cache-prefix: windows-2019-cmake # windows-2019 has python3.7 installed, which is incompatible with the latest gcloud python-version: '3.9' + continuous-only: true - name: Windows CMake 32-bit os: windows-2022 flags: >- @@ -402,6 +431,7 @@ jobs: vsversion: '2022' windows-arch: 'win32' cache-prefix: windows-2022-win32-cmake + continuous-only: true - name: Windows CMake Shared os: windows-2022 flags: >- @@ -418,17 +448,19 @@ jobs: -Dprotobuf_BUILD_PROTOBUF_BINARIES=OFF vsversion: '2022' cache-prefix: windows-2022-cmake - name: ${{ matrix.name }} + continuous-only: true + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} ${{ matrix.name }} runs-on: ${{ matrix.os }} steps: - name: Checkout pending changes + if: ${{ runner.os == 'Windows' && (!matrix.continuous-only || inputs.continuous-run) }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} submodules: recursive - name: Setup MSVC - if: ${{ runner.os == 'Windows' }} + if: ${{ runner.os == 'Windows' && (!matrix.continuous-only || inputs.continuous-run) }} uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 # v1.12.1 with: arch: ${{ matrix.windows-arch || 'x64' }} @@ -436,22 +468,23 @@ jobs: # Workaround for Abseil incompatibility with CMake 3.30 (b/352354235). - name: Downgrade CMake - if: ${{ runner.os == 'Windows' }} + if: ${{ runner.os == 'Windows' && (!matrix.continuous-only || inputs.continuous-run)}} run: choco install cmake --version 3.29.6 --force shell: bash # Workaround for incompatibility between gcloud and windows-2019 runners. - name: Install Python - if: ${{ matrix.python-version }} + if: ${{ matrix.python-version && (!matrix.continuous-only || inputs.continuous-run) }} uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 with: python-version: ${{ matrix.python-version }} - name: Use custom python for gcloud - if: ${{ matrix.python-version }} + if: ${{ matrix.python-version && (!matrix.continuous-only || inputs.continuous-run) }} run: echo "CLOUDSDK_PYTHON=${Python3_ROOT_DIR}\\python3" >> $GITHUB_ENV shell: bash - name: Setup sccache + if: ${{ runner.os == 'Windows' && (!matrix.continuous-only || inputs.continuous-run) }} uses: protocolbuffers/protobuf-ci/sccache@v3 with: cache-prefix: ${{ matrix.cache-prefix }} @@ -459,42 +492,46 @@ jobs: # Install phase. - name: Configure CMake for install - if: matrix.install-flags + if: ${{ matrix.install-flags && (!matrix.continuous-only || inputs.continuous-run) }} uses: protocolbuffers/protobuf-ci/bash@v3 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} command: cmake . ${{ matrix.install-flags }} ${{ env.SCCACHE_CMAKE_FLAGS }} -Dprotobuf_ALLOW_CCACHE=ON - name: Build for install - if: matrix.install-flags + if: ${{ matrix.install-flags && (!matrix.continuous-only || inputs.continuous-run) }} shell: bash run: VERBOSE=1 cmake --build . --parallel 20 - name: Install - if: matrix.install-flags + if: ${{ matrix.install-flags && (!matrix.continuous-only || inputs.continuous-run) }} shell: bash run: cmake --build . --target install - name: Report and clear sccache stats - if: matrix.install-flags + if: ${{ matrix.install-flags && (!matrix.continuous-only || inputs.continuous-run) }} shell: bash run: sccache -s && sccache -z - name: Clear CMake cache - if: matrix.install-flags + if: ${{ matrix.install-flags && (!matrix.continuous-only || inputs.continuous-run) }} shell: bash run: cmake --build . --target clean && rm CMakeCache.txt - name: Configure CMake + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bash@v3 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} command: cmake . ${{ matrix.flags }} ${{ env.SCCACHE_CMAKE_FLAGS }} -Dprotobuf_ALLOW_CCACHE=ON - name: Build + if: ${{ !matrix.continuous-only || inputs.continuous-run }} shell: bash run: VERBOSE=1 cmake --build . --parallel 20 - name: Test + if: ${{ !matrix.continuous-only || inputs.continuous-run }} shell: bash run: ctest --verbose --parallel 20 -C Debug - name: Report sccache stats + if: ${{ !matrix.continuous-only || inputs.continuous-run }} shell: bash run: sccache -s diff --git a/.github/workflows/test_csharp.yml b/.github/workflows/test_csharp.yml index 8b04ff4d9165..ae0b76d40bd4 100644 --- a/.github/workflows/test_csharp.yml +++ b/.github/workflows/test_csharp.yml @@ -12,6 +12,8 @@ permissions: contents: read jobs: + # All C# jobs are currently run on presubmit + # If you wish to add continuous-only jobs you will need to import test-type above linux: name: Linux runs-on: ubuntu-latest diff --git a/.github/workflows/test_java.yml b/.github/workflows/test_java.yml index 5f08ab2dfb55..cb45db34745d 100644 --- a/.github/workflows/test_java.yml +++ b/.github/workflows/test_java.yml @@ -3,10 +3,20 @@ name: Java Tests on: workflow_call: inputs: + continuous-run: + required: true + description: "Boolean string denoting whether this run is continuous -- + empty string for presubmit, non-empty string for continuous." + type: string safe-checkout: required: true description: "The SHA key for the commit we want to run over" type: string + continuous-prefix: + required: true + description: "The prefix for tests that should only be run continuously" + type: string + permissions: contents: read @@ -23,10 +33,12 @@ jobs: # TODO: b/318555165 - enable the layering check. Currently it does # not work correctly with the toolchain in this Docker image. targets: //java/... //java/internal:java_version //compatibility/... --features=-layering_check + continuous-only: true - name: OpenJDK 11 cache_key: '11' image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:11-1fdbb997433cb22c1e49ef75ad374a8d6bb88702 targets: //java/... //java/internal:java_version //compatibility/... + continuous-only: true - name: OpenJDK 17 cache_key: '17' image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:17-1fdbb997433cb22c1e49ef75ad374a8d6bb88702 @@ -46,15 +58,17 @@ jobs: image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-63dd26c0c7a808d92673a3e52e848189d4ab0f17 targets: //java/... //compatibility/... //src/google/protobuf/compiler:protoc_aarch64_test - name: Linux ${{ matrix.name }} + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Linux ${{ matrix.name }} runs-on: ubuntu-latest steps: - name: Checkout pending changes uses: protocolbuffers/protobuf-ci/checkout@v3 + if: ${{ !matrix.continuous-only || inputs.continuous-run }} with: ref: ${{ inputs.safe-checkout }} - name: Run tests uses: protocolbuffers/protobuf-ci/bazel-docker@v3 + if: ${{ !matrix.continuous-only || inputs.continuous-run }} with: image: ${{ matrix.image }} credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} diff --git a/.github/workflows/test_objectivec.yml b/.github/workflows/test_objectivec.yml index ea2726dd62cd..a2e8ce495961 100644 --- a/.github/workflows/test_objectivec.yml +++ b/.github/workflows/test_objectivec.yml @@ -3,10 +3,20 @@ name: Objective-C Tests on: workflow_call: inputs: + continuous-run: + required: true + description: "Boolean string denoting whether this run is continuous -- + empty string for presubmit, non-empty string for continuous." + type: string safe-checkout: required: true description: "The SHA key for the commit we want to run over" type: string + continuous-prefix: + required: true + description: "The prefix for tests that should only be run continuously" + type: string + permissions: contents: read @@ -27,24 +37,31 @@ jobs: - platform: "iOS" destination: "platform=iOS Simulator,name=iPhone 13,OS=latest" xc_project: "ProtocolBuffers_iOS.xcodeproj" + # We run presubmits on all "Debug" entries, but not on "Release" entries + - xc_config: "Debug" + - xc_config: "Release" + continuous-only: true - name: Xcode ${{ matrix.platform}} ${{ matrix.xc_config }} + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Xcode ${{ matrix.platform}} ${{ matrix.xc_config }} runs-on: macos-12 env: DEVELOPER_DIR: /Applications/Xcode_14.1.app/Contents/Developer steps: - name: Checkout pending changes + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: Setup ccache + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/ccache@v3 with: cache-prefix: objectivec_${{ matrix.platform }}_${{ matrix.xc_config }} support-modules: true - name: Run tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bash@v3 env: CC: ${{ github.workspace }}/ci/clang_wrapper @@ -60,6 +77,7 @@ jobs: test - name: Report ccache stats + if: ${{ !matrix.continuous-only || inputs.continuous-run }} shell: bash run: ccache -s -v @@ -75,16 +93,23 @@ jobs: - OS: macos-14 PLATFORM: "visionos" XCODE: "15.2" - name: CocoaPods ${{ matrix.PLATFORM }} ${{ matrix.CONFIGURATION }} + # We run presubmits on all "Debug" entries, but not on "Release" entries + - CONFIGURATION: "Debug" + - CONFIGURATION: "Release" + continuous-only: true + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} CocoaPods ${{ matrix.PLATFORM }} ${{ matrix.CONFIGURATION }} runs-on: ${{ matrix.OS }} steps: - name: Checkout pending changes + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: Xcode version + if: ${{ !matrix.continuous-only || inputs.continuous-run }} run: sudo xcode-select -switch /Applications/Xcode_${{ matrix.XCODE }}.app - name: Pod lib lint + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel@v3 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} @@ -104,6 +129,7 @@ jobs: - name: Optimized flags: --config=opt bazel_action: test + continuous-only: true - name: Debug flags: --config=dbg bazel_action: test @@ -112,6 +138,7 @@ jobs: - name: Apple_Silicon_Optimized flags: --config=opt --cpu=darwin_arm64 bazel_action: build + continuous-only: true - name: Apple_Silicon_Debug flags: --config=dbg --cpu=darwin_arm64 bazel_action: build @@ -120,14 +147,16 @@ jobs: include: - platform: "macOS" bazel_targets: //objectivec/... - name: Bazel ${{ matrix.platform }} ${{ matrix.config.name }} + name: ${{ matrix.config.continuous-only && inputs.continuous-prefix || '' }} Bazel ${{ matrix.platform }} ${{ matrix.config.name }} runs-on: macos-12 steps: - name: Checkout pending changes + if: ${{ !matrix.config.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: bazel ${{ matrix.config.bazel_action }} + if: ${{ !matrix.config.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel@v3 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} diff --git a/.github/workflows/test_php.yml b/.github/workflows/test_php.yml index 86d24954b2c8..fbc48e16db48 100644 --- a/.github/workflows/test_php.yml +++ b/.github/workflows/test_php.yml @@ -4,10 +4,20 @@ name: PHP Tests on: workflow_call: inputs: + continuous-run: + required: true + description: "Boolean string denoting whether this run is continuous -- + empty string for presubmit, non-empty string for continuous." + type: string safe-checkout: required: true description: "The SHA key for the commit we want to run over" type: string + continuous-prefix: + required: true + description: "The prefix for tests that should only be run continuously" + type: string + permissions: contents: read @@ -26,33 +36,39 @@ jobs: version: 8.1.14-dbg version-short: "8.1" command: composer test \&\& composer test_c + continuous-only: true - name: 8.1 Memory Leak version: 8.1.14-dbg version-short: "8.1" # Run specialized memory leak & multirequest tests. command: composer test_c \&\& tests/multirequest.sh \&\& tests/memory_leak_test.sh + continuous-only: true - name: 8.1 Valgrind version: 8.1.14-dbg version-short: "8.1" command: composer test_valgrind + continuous-only: true - name: 8.3 Optimized version: "8.3.1" version-short: "8.3" command: composer test \&\& composer test_c - name: Linux ${{ matrix.name}} + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Linux ${{ matrix.name}} runs-on: ubuntu-latest steps: - name: Checkout pending changes + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: Setup composer + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/composer-setup@v3 with: cache-prefix: php-${{ matrix.version-short }} directory: php - name: Run tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/docker@v3 with: image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php:${{ matrix.version }}-66964dc8b07b6d1fc73a5cc14e59e84c1c534cea @@ -73,20 +89,26 @@ jobs: include: - suffix: '-zts' suffix_name: ' Thread Safe' + continuous-only: true - test: 'test_c' test_name: ' Extension' + continuous-only: true + - suffix: '' + test: 'test' - name: Linux 32-bit ${{ matrix.version}}${{ matrix.suffix_name }}${{ matrix.test_name }} + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Linux 32-bit ${{ matrix.version}}${{ matrix.suffix_name }}${{ matrix.test_name }} runs-on: ubuntu-latest env: image: us-docker.pkg.dev/protobuf-build/containers/test/linux/32bit@sha256:836f2cedcfe351d9a30055076630408e61994fc7d783e8333a99570968990eeb steps: - name: Checkout pending changes + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: Cross compile protoc for i386 + if: ${{ !matrix.continuous-only || inputs.continuous-run }} id: cross-compile uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v3 with: @@ -95,12 +117,14 @@ jobs: architecture: linux-i386 - name: Setup composer + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/composer-setup@v3 with: cache-prefix: php-${{ matrix.version }} directory: php - name: Run tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/docker@v3 with: image: ${{ env.image }} @@ -155,37 +179,47 @@ jobs: strategy: fail-fast: false # Don't cancel all jobs if one fails. matrix: - version: ['8.2', '8.3'] + include: + - version: '8.2' + continuous-only: true + - version: '8.3' - name: MacOS PHP ${{ matrix.version }} + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} MacOS PHP ${{ matrix.version }} runs-on: macos-12 steps: - name: Checkout pending changes + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: Uninstall problematic libgd + if: ${{ !matrix.continuous-only || inputs.continuous-run }} run: brew uninstall --ignore-dependencies gd - name: Install dependencies + if: ${{ !matrix.continuous-only || inputs.continuous-run }} run: brew install coreutils gd - name: Pin PHP version + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: shivammathur/setup-php@8872c784b04a1420e81191df5d64fbd59d3d3033 # 2.30.2 with: php-version: ${{ matrix.version }} - name: Check PHP version + if: ${{ !matrix.continuous-only || inputs.continuous-run }} run: php --version | grep ${{ matrix.version }} || (echo "Invalid PHP version - $(php --version)" && exit 1) - name: Setup composer + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/composer-setup@v3 with: cache-prefix: php-${{ matrix.version }} directory: php - name: Run tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bash@v3 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} @@ -198,6 +232,7 @@ jobs: popd - name: Run conformance tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel@v3 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} diff --git a/.github/workflows/test_php_ext.yml b/.github/workflows/test_php_ext.yml index dfe1951b1104..f9a60ea7f00e 100644 --- a/.github/workflows/test_php_ext.yml +++ b/.github/workflows/test_php_ext.yml @@ -3,10 +3,20 @@ name: PHP Extension Tests on: workflow_call: inputs: + continuous-run: + required: true + description: "Boolean string denoting whether this run is continuous -- + empty string for presubmit, non-empty string for continuous." + type: string safe-checkout: required: true description: "The SHA key for the commit we want to run over" type: string + continuous-prefix: + required: true + description: "The prefix for tests that should only be run continuously" + type: string + permissions: contents: read # to fetch code (actions/checkout) @@ -41,15 +51,22 @@ jobs: strategy: fail-fast: false # Don't cancel all jobs if one fails. matrix: - version: ["8.1", "8.2", "8.3"] - name: Build ${{ matrix.version }} + include: + - version: "8.1" + continuous-only: true + - version: "8.2" + continuous-only: true + - version: "8.3" + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Build ${{ matrix.version }} runs-on: ubuntu-latest steps: - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a + if: ${{ !matrix.continuous-only || inputs.continuous-run }} with: name: protobuf-php-release - name: Run tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/docker@v3 with: image: us-docker.pkg.dev/protobuf-build/containers/test/linux/php-extension:${{ matrix.version }}-a48f26c08d9a803dd0177dda63563f6ea6f7b2d4 diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index b48da36aabf2..a7cf85f35ecd 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -3,10 +3,20 @@ name: Python Tests on: workflow_call: inputs: + continuous-run: + required: true + description: "Boolean string denoting whether this run is continuous -- + empty string for presubmit, non-empty string for continuous." + type: string safe-checkout: required: true description: "The SHA key for the commit we want to run over" type: string + continuous-prefix: + required: true + description: "The prefix for tests that should only be run continuously" + type: string + permissions: contents: read @@ -32,15 +42,23 @@ jobs: # TODO Enable this once conformance tests are fixed. flags: --define=use_fast_cpp_protos=true --test_tag_filters=-conformance image: us-docker.pkg.dev/protobuf-build/containers/test/linux/emulation:aarch64-63dd26c0c7a808d92673a3e52e848189d4ab0f17 + - version: "3.8" + - version: "3.9" + continuous-only: true + - version: "3.10" + continuous-only: true + - version: "3.11" - name: Linux ${{ matrix.type }} ${{ matrix.version }} + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Linux ${{ matrix.type }} ${{ matrix.version }} runs-on: ubuntu-latest steps: - name: Checkout pending changes + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: Run tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel-docker@v3 with: image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/python:{0}-63dd26c0c7a808d92673a3e52e848189d4ab0f17', matrix.version) }} diff --git a/.github/workflows/test_ruby.yml b/.github/workflows/test_ruby.yml index 8d754189ce91..b9b89eb298b0 100644 --- a/.github/workflows/test_ruby.yml +++ b/.github/workflows/test_ruby.yml @@ -3,10 +3,20 @@ name: Ruby Tests on: workflow_call: inputs: + continuous-run: + required: true + description: "Boolean string denoting whether this run is continuous -- + empty string for presubmit, non-empty string for continuous." + type: string safe-checkout: required: true description: "The SHA key for the commit we want to run over" type: string + continuous-prefix: + required: true + description: "The prefix for tests that should only be run continuously" + type: string + permissions: contents: read @@ -20,22 +30,24 @@ jobs: # Test both FFI and Native implementations on the highest and lowest # Ruby versions for CRuby and JRuby, but only on Bazel 5.x. - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: NATIVE } - - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: FFI } - - { name: Ruby 3.1, ruby: ruby-3.1.0 } - - { name: Ruby 3.2, ruby: ruby-3.2.0 } + - { name: Ruby 3.0, ruby: ruby-3.0.2, ffi: FFI, continuous-only: true } + - { name: Ruby 3.1, ruby: ruby-3.1.0, continuous-only: true } + - { name: Ruby 3.2, ruby: ruby-3.2.0, continuous-only: true } - { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: NATIVE } - { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: FFI } - { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: NATIVE } - { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: FFI } - name: Linux ${{ matrix.name }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }} + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Linux ${{ matrix.name }} ${{ matrix.ffi == 'FFI' && ' FFI' || '' }} runs-on: ubuntu-latest steps: - name: Checkout pending changes + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: Run tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel-docker@v3 with: image: ${{ matrix.image || format('us-docker.pkg.dev/protobuf-build/containers/test/linux/ruby:{0}-6.3.0-9848710ff1370795ee7517570a20b81e140112ec', matrix.ruby) }} @@ -45,6 +57,7 @@ jobs: # Useful tool for troubleshooting, but the action introduces flakes as well, # e.g. https://github.com/actions/upload-artifact/issues/569 # - name: Archive log artifacts +# if: ${{ matrix.presubmit || inputs.test-type == 'continuous' }} # uses: actions/upload-artifact@v4 # with: # name: test-logs-${{ matrix.ruby }}_${{ matrix.ffi || 'NATIVE' }} @@ -121,29 +134,33 @@ jobs: # Ruby versions for CRuby, but only on Bazel 5.x. # Quote versions numbers otherwise 3.0 will render as 3 - { version: "3.0", ffi: NATIVE } - - { version: "3.0", ffi: FFI } - - { version: "3.1" } - - { version: "3.2" } + - { version: "3.0", ffi: FFI, continuous-only: true } + - { version: "3.1", continuous-only: true } + - { version: "3.2", continuous-only: true } - { version: "3.3", ffi: NATIVE } - { version: "3.3", ffi: FFI } - name: MacOS Ruby ${{ matrix.version }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }} + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} MacOS Ruby ${{ matrix.version }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }} runs-on: macos-12 steps: - name: Checkout pending changes + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: Pin Ruby version + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: ruby/setup-ruby@961f85197f92e4842e3cb92a4f97bd8e010cdbaf # v1.165.0 with: ruby-version: ${{ matrix.version }} - name: Validate version + if: ${{ !matrix.continuous-only || inputs.continuous-run }} run: ruby --version | grep ${{ matrix.version }} || (echo "Invalid Ruby version - $(ruby --version)" && exit 1) - name: Run tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel@v3 with: credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} @@ -165,7 +182,9 @@ jobs: - { name: Ruby 3.3, ruby: ruby-3.3.0, ffi: FFI } - { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: NATIVE } - { name: JRuby 9.4, ruby: jruby-9.4.6.0, ffi: FFI } - name: Install ${{ matrix.name }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }} + name: (Continuous) Install ${{ matrix.name }}${{ matrix.ffi == 'FFI' && ' FFI' || '' }} + # None of these ruby gem tests should be run on presubmit + if: ${{ inputs.continuous-run }} runs-on: ubuntu-latest steps: - name: Checkout pending changes diff --git a/.github/workflows/test_runner.yml b/.github/workflows/test_runner.yml index 70cfc27a4ad6..6bda52b3ec54 100644 --- a/.github/workflows/test_runner.yml +++ b/.github/workflows/test_runner.yml @@ -48,7 +48,7 @@ on: # manual workflow_dispatch: - + permissions: contents: read @@ -57,8 +57,8 @@ concurrency: cancel-in-progress: ${{ contains(fromJSON('["pull_request", "pull_request_target", "workflow_dispatch"]'), github.event_name) }} jobs: - check-tag: - name: Check for Safety + set-vars: + name: Set Variables # Avoid running tests twice on PR updates. If the PR is coming from our # repository, it's safe and we can use `pull_request`. Otherwise, we should @@ -77,6 +77,15 @@ jobs: # Store the sha for checkout so we can easily use it later. For safe # events, this will be blank and use the defaults. checkout-sha: ${{ steps.safe-checkout.outputs.sha }} + # Stores a string to be used as a boolean denoting whether this is a + # continuous run. An empty string denotes that the run is on presubmit, + # otherwise we are in a continuous run. This helps us determine which + # tests to block on. + continuous-run: ${{ steps.set-test-type-vars.outputs.continuous-run }} + # Stores a string that will serve as the prefix for all continuous tests. + # Either way we prepend "(Continuous)" but in the case that we are in + # a presubmit run, we should also mark them "[SKIPPED]" + continuous-prefix: ${{ steps.set-test-type-vars.outputs.continuous-prefix }} steps: - name: Check # Trivially pass for safe PRs, and explicitly error for unsafe ones @@ -93,9 +102,20 @@ jobs: ${{ github.event_name != 'pull_request_target' }} || echo "sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT + - name: Set Test Type Variables + id: set-test-type-vars + run: | + if [ "${{ github.event_name }}" == 'pull_request' ] || [ "${{ github.event_name }}" == 'pull_request_target' ]; then + echo "continuous-run=" >> "$GITHUB_OUTPUT" + echo "continuous-prefix=[SKIPPED] (Continuous)" >> "$GITHUB_OUTPUT" + else + echo "continuous-run=continuous" >> "$GITHUB_OUTPUT" + echo "continuous-prefix=(Continuous)" >> "$GITHUB_OUTPUT" + fi + remove-tag: name: Remove safety tag - needs: [check-tag] + needs: [set-vars] if: github.event.action == 'labeled' runs-on: ubuntu-latest permissions: @@ -106,103 +126,142 @@ jobs: fail_on_error: true labels: ':a: safe for tests' + validate-yaml: + name: Validate YAML + runs-on: ubuntu-latest + steps: + - name: Run YAML validator + run: | + python ../scripts/validate_yaml.py + # Note: this pattern of passing the head sha is vulnerable to PWN requests for # pull_request_target events. We carefully limit those workflows to require a # human stamp before continuing. bazel: name: Bazel - needs: [check-tag] + needs: [set-vars] uses: ./.github/workflows/test_bazel.yml with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} + continuous-run: ${{ needs.set-vars.outputs.continuous-run }} + safe-checkout: ${{ needs.set-vars.outputs.checkout-sha }} + continuous-prefix: ${{ needs.set-vars.outputs.continuous-prefix }} secrets: inherit cpp: name: C++ - needs: [check-tag] + needs: [set-vars] uses: ./.github/workflows/test_cpp.yml with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} + continuous-run: ${{ needs.set-vars.outputs.continuous-run }} + safe-checkout: ${{ needs.set-vars.outputs.checkout-sha }} + continuous-prefix: ${{ needs.set-vars.outputs.continuous-prefix }} secrets: inherit java: name: Java - needs: [check-tag] + needs: [set-vars] uses: ./.github/workflows/test_java.yml with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} + continuous-run: ${{ needs.set-vars.outputs.continuous-run }} + safe-checkout: ${{ needs.set-vars.outputs.checkout-sha }} + continuous-prefix: ${{ needs.set-vars.outputs.continuous-prefix }} secrets: inherit python: name: Python - needs: [check-tag] + needs: [set-vars] uses: ./.github/workflows/test_python.yml with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} + continuous-run: ${{ needs.set-vars.outputs.continuous-run }} + safe-checkout: ${{ needs.set-vars.outputs.checkout-sha }} + continuous-prefix: ${{ needs.set-vars.outputs.continuous-prefix }} secrets: inherit ruby: name: Ruby - needs: [check-tag] + needs: [set-vars] uses: ./.github/workflows/test_ruby.yml with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} + continuous-run: ${{ needs.set-vars.outputs.continuous-run }} + safe-checkout: ${{ needs.set-vars.outputs.checkout-sha }} + continuous-prefix: ${{ needs.set-vars.outputs.continuous-prefix }} secrets: inherit php: name: PHP - needs: [check-tag] + needs: [set-vars] uses: ./.github/workflows/test_php.yml with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} + continuous-run: ${{ needs.set-vars.outputs.continuous-run }} + safe-checkout: ${{ needs.set-vars.outputs.checkout-sha }} + continuous-prefix: ${{ needs.set-vars.outputs.continuous-prefix }} secrets: inherit php-ext: name: PHP Extension - needs: [check-tag] + needs: [set-vars] uses: ./.github/workflows/test_php_ext.yml with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} + continuous-run: ${{ needs.set-vars.outputs.continuous-run }} + safe-checkout: ${{ needs.set-vars.outputs.checkout-sha }} + continuous-prefix: ${{ needs.set-vars.outputs.continuous-prefix }} secrets: inherit csharp: name: C# - needs: [check-tag] + needs: [set-vars] uses: ./.github/workflows/test_csharp.yml with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} + safe-checkout: ${{ needs.set-vars.outputs.checkout-sha }} secrets: inherit objectivec: name: Objective-C - needs: [check-tag] + needs: [set-vars] uses: ./.github/workflows/test_objectivec.yml with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} + continuous-run: ${{ needs.set-vars.outputs.continuous-run }} + safe-checkout: ${{ needs.set-vars.outputs.checkout-sha }} + continuous-prefix: ${{ needs.set-vars.outputs.continuous-prefix }} secrets: inherit rust: name: Rust - needs: [check-tag] + needs: [set-vars] uses: ./.github/workflows/test_rust.yml with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} + safe-checkout: ${{ needs.set-vars.outputs.checkout-sha }} secrets: inherit upb: name: μpb - needs: [check-tag] + needs: [set-vars] uses: ./.github/workflows/test_upb.yml with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} + continuous-run: ${{ needs.set-vars.outputs.continuous-run }} + safe-checkout: ${{ needs.set-vars.outputs.checkout-sha }} + continuous-prefix: ${{ needs.set-vars.outputs.continuous-prefix }} secrets: inherit staleness: name: Staleness - needs: [check-tag] + needs: [set-vars] uses: ./.github/workflows/staleness_check.yml # Staleness tests have scheduled runs during off-hours to avoid race conditions. if: ${{ github.event_name != 'schedule' }} with: - safe-checkout: ${{ needs.check-tag.outputs.checkout-sha }} + continuous-run: ${{ needs.set-vars.outputs.continuous-run }} + safe-checkout: ${{ needs.set-vars.outputs.checkout-sha }} secrets: inherit + + # This test depends on all blocking tests and indicates whether they all suceeded. + all_blocking_tests: + name: All Blocking Tests + needs: [set-vars, remove-tag, bazel, cpp, java, python, ruby, php, php-ext, csharp, objectivec, rust, upb, staleness] + runs-on: ubuntu-latest + steps: + - name: Check test results + run: "${{ !contains(join(needs.*.result, ' '), 'failure') && !contains(join(needs.*.result, ' '), 'cancelled') }}" + # This workflow must run even if one or more of the dependent workflows + # failed. + if: always() && ${{ needs.check-tag.result != 'skipped' }} diff --git a/.github/workflows/test_rust.yml b/.github/workflows/test_rust.yml index 00c2e4b7bb45..ea1f02491b13 100644 --- a/.github/workflows/test_rust.yml +++ b/.github/workflows/test_rust.yml @@ -12,6 +12,7 @@ permissions: contents: read jobs: + # This job should be run on presubmit, if any continuous-only tests are added we will need to input test-type above linux: name: Linux runs-on: ubuntu-latest diff --git a/.github/workflows/test_upb.yml b/.github/workflows/test_upb.yml index 945b7c01b4f4..dc054ef3ca33 100644 --- a/.github/workflows/test_upb.yml +++ b/.github/workflows/test_upb.yml @@ -3,10 +3,20 @@ name: μpb Tests on: workflow_call: inputs: + continuous-run: + required: true + description: "Boolean string denoting whether this run is continuous -- + empty string for presubmit, non-empty string for continuous." + type: string safe-checkout: required: true description: "The SHA key for the commit we want to run over" type: string + continuous-prefix: + required: true + description: "The prefix for tests that should only be run continuously" + type: string + permissions: contents: read @@ -17,24 +27,26 @@ jobs: fail-fast: false # Don't cancel all jobs if one fails. matrix: config: - - { name: "Bazel 7", bazel_version: "7.1.1" } + - { name: "Bazel 7", bazel_version: "7.1.1", continuous-only: true } - { name: "Fastbuild" } - - { name: "Optimized", flags: "-c opt" } + - { name: "Optimized", flags: "-c opt", continuous-only: true } - { name: "ASAN", flags: "--config=asan -c dbg", exclude-targets: "-//benchmarks:benchmark -//python/...", runner: ubuntu-22-4core } - - { name: "UBSAN", flags: "--config=ubsan -c dbg", exclude-targets: "-//benchmarks:benchmark -//python/... -//lua/..." } + - { name: "UBSAN", flags: "--config=ubsan -c dbg", exclude-targets: "-//benchmarks:benchmark -//python/... -//lua/...", continuous-only: true } - { name: "32-bit", flags: "--copt=-m32 --linkopt=-m32", exclude-targets: "-//benchmarks:benchmark -//python/..." } # TODO: Add 32-bit ASAN test # TODO: Restore the FastTable tests - name: ${{ matrix.config.name }} + name: ${{ matrix.config.continuous-only && inputs.continuous-prefix || '' }} ${{ matrix.config.name }} runs-on: ${{ matrix.config.runner || 'ubuntu-latest' }} steps: - name: Checkout pending changes + if: ${{ !matrix.config.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/checkout@v3 with: ref: ${{ inputs.safe-checkout }} - name: Run tests + if: ${{ !matrix.config.continuous-only || inputs.continuous-run }} uses: protocolbuffers/protobuf-ci/bazel-docker@v3 with: image: us-docker.pkg.dev/protobuf-build/containers/test/linux/sanitize:${{ matrix.config.bazel_version || '6.3.0' }}-75f2a85ece6526cc3d54087018c0f1097d78d42b @@ -161,8 +173,6 @@ jobs: path: python/requirements.txt test_wheels: - name: Test Wheels - needs: build_wheels strategy: fail-fast: false # Don't cancel all jobs if one fails. matrix: @@ -175,22 +185,24 @@ jobs: - { os: macos-12, python-version: "3.8", architecture: x64, type: 'binary' } - { os: ubuntu-latest, python-version: "3.12", architecture: x64, type: 'binary' } - { os: macos-13, python-version: "3.12", architecture: x64, type: 'binary' } - - { os: ubuntu-latest, python-version: "3.8", architecture: x64, type: 'source' } - - { os: macos-12, python-version: "3.8", architecture: x64, type: 'source' } - - { os: ubuntu-latest, python-version: "3.12", architecture: x64, type: 'source' } - - { os: macos-13, python-version: "3.12", architecture: x64, type: 'source' } + - { os: ubuntu-latest, python-version: "3.8", architecture: x64, type: 'source', continuous-only: true } + - { os: macos-12, python-version: "3.8", architecture: x64, type: 'source', continuous-only: true } + - { os: ubuntu-latest, python-version: "3.12", architecture: x64, type: 'source', continuous-only: true } + - { os: macos-13, python-version: "3.12", architecture: x64, type: 'source', continuous-only: true } # Windows uses the full API up until Python 3.10. - - { os: windows-2019, python-version: "3.8", architecture: x86, type: 'binary' } - - { os: windows-2019, python-version: "3.9", architecture: x86, type: 'binary' } - - { os: windows-2019, python-version: "3.10", architecture: x86, type: 'binary' } - - { os: windows-2019, python-version: "3.11", architecture: x86, type: 'binary' } - - { os: windows-2019, python-version: "3.12", architecture: x86, type: 'binary' } + - { os: windows-2019, python-version: "3.8", architecture: x86, type: 'binary', continuous-only: true } + - { os: windows-2019, python-version: "3.9", architecture: x86, type: 'binary', continuous-only: true } + - { os: windows-2019, python-version: "3.10", architecture: x86, type: 'binary', continuous-only: true } + - { os: windows-2019, python-version: "3.11", architecture: x86, type: 'binary', continuous-only: true } + - { os: windows-2019, python-version: "3.12", architecture: x86, type: 'binary', continuous-only: true } - { os: windows-2019, python-version: "3.8", architecture: x64, type: 'binary' } - - { os: windows-2019, python-version: "3.9", architecture: x64, type: 'binary' } - - { os: windows-2019, python-version: "3.10", architecture: x64, type: 'binary' } - - { os: windows-2019, python-version: "3.11", architecture: x64, type: 'binary' } + - { os: windows-2019, python-version: "3.9", architecture: x64, type: 'binary', continuous-only: true } + - { os: windows-2019, python-version: "3.10", architecture: x64, type: 'binary', continuous-only: true } + - { os: windows-2019, python-version: "3.11", architecture: x64, type: 'binary', continuous-only: true } - { os: windows-2019, python-version: "3.12", architecture: x64, type: 'binary' } + name: ${{ matrix.continuous-only && inputs.continuous-prefix || '' }} Test Wheels Python ${{ matrix.python-version }} ${{ matrix.os }} ${{ matrix.architecture }} ${{ matrix.type }} + needs: build_wheels runs-on: ${{ matrix.os }} if: ${{ github.event_name != 'pull_request_target' }} defaults: @@ -198,20 +210,24 @@ jobs: shell: bash steps: - name: Download Wheels + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: actions/download-artifact@v3 with: name: python-wheels path: wheels - name: Download Requirements + if: ${{ !matrix.continuous-only || inputs.continuous-run }} uses: actions/download-artifact@v3 with: name: requirements path: requirements - uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1 # v4.7.0 + if: ${{ !matrix.continuous-only || inputs.continuous-run }} with: python-version: ${{ matrix.python-version }} architecture: ${{ matrix.architecture }} - name: Setup Python venv + if: ${{ !matrix.continuous-only || inputs.continuous-run }} run: | python -m pip install --upgrade pip python -m venv env @@ -221,24 +237,28 @@ jobs: - name: Install tzdata run: pip install tzdata # Only needed on Windows, Linux ships with tzdata. - if: ${{ contains(matrix.os, 'windows') }} + if: ${{ contains(matrix.os, 'windows') && (!matrix.continuous-only || inputs.continuous-run) }} - name: Install requirements + if: ${{ !matrix.continuous-only || inputs.continuous-run }} run: pip install -r requirements/requirements.txt - name: Install Protobuf Binary Wheel + if: ${{ matrix.type == 'binary' && (!matrix.continuous-only || inputs.continuous-run) }} run: pip install -vvv --no-index --find-links wheels protobuf - if: ${{ matrix.type == 'binary' }} - name: Install Protobuf Source Wheel + if: ${{ matrix.type == 'source' && (!matrix.continuous-only || inputs.continuous-run) }} run: | cd wheels tar -xzvf *.tar.gz cd protobuf-*/ pip install . - if: ${{ matrix.type == 'source' }} - name: Test that module is importable + if: ${{ !matrix.continuous-only || inputs.continuous-run }} run: python -v -c 'from google._upb import _message; assert "google._upb._message.MessageMeta" in str(_message.MessageMeta)' - name: Install Protobuf Test Wheel + if: ${{ !matrix.continuous-only || inputs.continuous-run }} run: pip install -vvv --no-index --find-links wheels protobuftests - name: Run the unit tests + if: ${{ !matrix.continuous-only || inputs.continuous-run }} run: | TESTS=$(pip show -f protobuftests | grep pb_unit_tests.*py$ | sed 's,/,.,g' | sed 's,\\,.,g' | sed -E 's,.py$,,g') for test in $TESTS; do