From 154e31be69fb8d4c90051a283e0593a9d2cb4717 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Wed, 19 Oct 2022 00:27:15 +0100 Subject: [PATCH] Improve CI coverage for Casks using `on_os` blocks (#133704) --- .github/workflows/ci.yml | 11 ++++++++--- cmd/lib/ci_matrix.rb | 16 ++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a515f88261..8f1df52c6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,16 +117,21 @@ jobs: id: gems run: brew install-bundler-gems + - name: Run brew readall ${{ matrix.tap }} + id: readall + run: brew readall '${{ matrix.tap }}' + if: always() && steps.gems.outcome == 'success' + - name: Run brew style ${{ matrix.tap }} run: brew style '${{ matrix.tap }}' - if: always() && steps.gems.outcome == 'success' && !matrix.cask + if: always() && steps.readall.outcome == 'success' && !matrix.cask - name: Run brew fetch --cask ${{ matrix.cask.token }} id: fetch run: | brew fetch --cask --retry --force '${{ matrix.cask.path }}' timeout-minutes: 30 - if: always() && steps.gems.outcome == 'success' && matrix.cask + if: always() && steps.readall.outcome == 'success' && matrix.cask - name: Run brew audit --cask${{ (matrix.cask && ' ') || ' --tap ' }}${{ matrix.cask.token || matrix.tap }} id: audit @@ -134,7 +139,7 @@ jobs: brew audit --cask ${{ join(matrix.audit_args, ' ') }}${{ (matrix.cask && ' ') || ' --tap ' }}'${{ matrix.cask.path || matrix.tap }}' timeout-minutes: 30 if: > - always() && steps.gems.outcome == 'success' && + always() && steps.readall.outcome == 'success' && (!matrix.cask || steps.fetch.outcome == 'success') && !matrix.skip_audit diff --git a/cmd/lib/ci_matrix.rb b/cmd/lib/ci_matrix.rb index c5bde88ea3..46392eeb4d 100644 --- a/cmd/lib/ci_matrix.rb +++ b/cmd/lib/ci_matrix.rb @@ -8,8 +8,8 @@ module CiMatrix MAX_JOBS = 256 RUNNERS = { - { symbol: :big_sur, name: "macos-11" } => 0.9, - { symbol: :monterey, name: "macos-12" } => 0.1, + { symbol: :big_sur, name: "macos-11" } => 0.0, + { symbol: :monterey, name: "macos-12" } => 1.0, }.freeze # This string uses regex syntax and is intended to be interpolated into @@ -65,9 +65,13 @@ module CiMatrix cask_content = path.read filtered_runners = filter_runners(cask_content) - if cask_content.match?(/\bMacOS\s*\.version\b/m) && - filtered_runners.keys.any? { |runner| cask_content.include?(runner[:symbol].inspect) } - # If the cask depends on `MacOS.version`, test it on every possible macOS version. + macos_version_found = cask_content.match?(/\bMacOS\s*\.version\b/m) + filtered_macos_found = filtered_runners.keys.any? do |runner| + (macos_version_found && cask_content.include?(runner[:symbol].inspect)) || + cask_content.include?("on_#{runner[:symbol]}") + end + if filtered_macos_found + # If the cask varies on a MacOS version, test it on every possible macOS version. filtered_runners.keys else # Otherwise, select a runner based on weighted random sample. @@ -102,7 +106,7 @@ module CiMatrix jobs = modified_cask_files.count odie "Maximum job matrix size exceeded: #{jobs}/#{MAX_JOBS}" if jobs > MAX_JOBS - changed_files[:modified_cask_files].flat_map do |path| + modified_cask_files.flat_map do |path| cask_token = path.basename(".rb") appcast_arg = if labels.include?("ci-skip-appcast")