From 5ff0b297cbeaca6b52aa51bb1377feb9a81ebf83 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Tue, 10 Sep 2024 18:15:43 +0800 Subject: [PATCH] workflows/dispatch-build-bottle: check for an existing bottle We currently have limited checks against duplicate bottle jobs being run. We set `concurrency`, but this only delays the duplicate job until after the original one has completed. This wastes CI resources when the original job is successful, because the duplicate job will happily go through a build only to error out in the `brew bottle` step. Let's fix that by checking for an existing bottle before attempting to build anything at all. --- .github/workflows/dispatch-build-bottle.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/dispatch-build-bottle.yml b/.github/workflows/dispatch-build-bottle.yml index bf69fe1869475..906aec18306df 100644 --- a/.github/workflows/dispatch-build-bottle.yml +++ b/.github/workflows/dispatch-build-bottle.yml @@ -114,6 +114,24 @@ jobs: bottles-directory: ${{ env.BOTTLES_DIR }} cleanup: ${{ matrix.cleanup }} + - name: Check for existing bottle + shell: brew ruby {0} + env: + HOMEBREW_DISPATCHED_FORMULA: ${{ inputs.formula }} + run: | + formula_name = ENV.fetch("HOMEBREW_DISPATCHED_FORMULA") + formula = Formulary.factory(formula_name) + current_bottle_tag = Utils::Bottles.tag + bottled_on_current_os = formula.bottle_specification.tag?(current_bottle_tag, no_older_versions: true) + + return unless bottled_on_current_os + + puts GitHub::Actions::Annotation.new( + :error, + "#{formula_name} already has a bottle for #{current_bottle_tag}!", + ) + exit 1 + - working-directory: ${{ env.BOTTLES_DIR }} run: | brew test-bot \