Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publish-commit-bottles: optionally push to pull request branch. #125556

Merged
merged 1 commit into from
Mar 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/dispatch-build-bottle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,23 @@ jobs:
with:
workdir: ${{matrix.workdir || github.workspace}}
result_path: bottles/steps_output.txt
step_name: 'Build summary on ${{ matrix.runner }}'
step_name: "Build summary on ${{ matrix.runner }}"

- name: Output brew linkage result
if: always()
uses: Homebrew/actions/failures-summary-and-bottle-result@master
with:
workdir: ${{matrix.workdir || github.workspace}}
result_path: bottles/linkage_output.txt
step_name: '`brew linkage` output on ${{ matrix.runner }}'
step_name: "`brew linkage` output on ${{ matrix.runner }}"

- name: Output brew bottle result
if: always()
uses: Homebrew/actions/failures-summary-and-bottle-result@master
with:
workdir: ${{matrix.workdir || github.workspace}}
result_path: bottles/bottle_output.txt
step_name: '`brew bottle` output on ${{ matrix.runner }}'
step_name: "`brew bottle` output on ${{ matrix.runner }}"

- name: Upload logs
if: always()
Expand Down
48 changes: 41 additions & 7 deletions .github/workflows/publish-commit-bottles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,34 @@ on:
default: ""
large_runner:
description: "Whether to run the upload job on a large runner (default: false)"
type: boolean
required: false
default: false
commit_bottles_to_pr_branch:
description: "Whether to push bottle commits to the pull request branch (default: false)"
type: boolean
required: false
default: false
Comment on lines +19 to +23
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turned out to be a bit fiddly to check the PR for labels, so let's use a workflow dispatch input instead. We can teach brew pr-publish to pass the right argument here if the PR has a given label if desired.


env:
GNUPGHOME: /tmp/gnupghome
HOMEBREW_DEVELOPER: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_FROM_API: 1
GH_REPO: ${{github.repository}}
GH_NO_UPDATE_NOTIFIER: 1
GH_PROMPT_DISABLED: 1

permissions:
contents: read

jobs:
upload:
runs-on: ${{github.event.inputs.large_runner == 'true' && 'homebrew-large-bottle-upload' || 'ubuntu-22.04'}}
runs-on: ${{inputs.large_runner && 'homebrew-large-bottle-upload' || 'ubuntu-22.04'}}
container:
image: ghcr.io/homebrew/ubuntu22.04:master
permissions:
pull-requests: write
steps:
- name: Post comment once started
uses: Homebrew/actions/post-comment@master
Expand All @@ -55,11 +67,6 @@ jobs:
- name: Install gems
run: brew install-bundler-gems

- name: Install skopeo and unzip for bottle upload
run: |
sudo apt-get update -y
sudo apt-get install -y skopeo unzip

- name: Configure Git user
uses: Homebrew/actions/git-user-config@master

Expand All @@ -68,14 +75,35 @@ jobs:
with:
signing_key: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY }}

- name: Checkout PR branch
run: gh pr checkout ${{github.event.inputs.pull_request}}
carlocab marked this conversation as resolved.
Show resolved Hide resolved
if: inputs.commit_bottles_to_pr_branch
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I've tried GITHUB_TOKEN, but it seems to not have the right permissions either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carlocab Working now. Needed to add permissions.


- name: Pull and upload bottles to GitHub Packages
env:
BREWTESTBOT_NAME_EMAIL: "BrewTestBot <1589480+BrewTestBot@users.noreply.github.com>"
HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_CORE_PUBLIC_REPO_EMAIL_TOKEN}}
HOMEBREW_GITHUB_PACKAGES_USER: brewtestbot
HOMEBREW_GITHUB_PACKAGES_TOKEN: ${{secrets.HOMEBREW_CORE_GITHUB_PACKAGES_TOKEN}}
run: brew pr-pull --debug --workflows=tests.yml --committer="$BREWTESTBOT_NAME_EMAIL" --root-url="https://ghcr.io/v2/homebrew/core" ${{github.event.inputs.args}} ${{github.event.inputs.pull_request}}
run: |
brew pr-pull \
--debug \
--workflows=tests.yml \
--committer="$BREWTESTBOT_NAME_EMAIL" \
--root-url="https://ghcr.io/v2/homebrew/core" \
${{inputs.commit_bottles_to_pr_branch && '--no-autosquash'}} \
${{inputs.commit_bottles_to_pr_branch && '--clean'}} \
${{github.event.inputs.args}} \
${{github.event.inputs.pull_request}}

- name: Add CI-published-bottle-commits label
run: gh pr edit --add-label CI-published-bottle-commits ${{github.event.inputs.pull_request}}
if: inputs.commit_bottles_to_pr_branch
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Push commits
uses: Homebrew/actions/git-try-push@master
Expand All @@ -87,6 +115,12 @@ jobs:
GIT_COMMITTER_EMAIL: 1589480+BrewTestBot@users.noreply.github.com
HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}

- name: Enable PR automerge
run: gh pr merge --auto ${{github.event.inputs.pull_request}}
if: inputs.commit_bottles_to_pr_branch
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Post comment on failure
if: ${{!success()}}
uses: Homebrew/actions/post-comment@master
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/remove-disabled-formulae.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ jobs:
with:
username: BrewTestBot

- name: Install gpg for commit signing
run: |
sudo apt-get update -y
sudo apt-get install -y gpg

- name: Set up commit signing
uses: Homebrew/actions/setup-commit-signing@master
with:
Expand Down
23 changes: 16 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ on:
branches:
- master
pull_request:
merge_group:

env:
HOMEBREW_DEVELOPER: 1
HOMEBREW_GITHUB_ACTIONS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_FROM_API: 1
GH_REPO: ${{github.repository}}
GH_NO_UPDATE_NOTIFIER: 1
GH_PROMPT_DISABLED: 1

concurrency:
group: "tests-${{ github.ref }}"
Expand Down Expand Up @@ -83,6 +87,11 @@ jobs:
core.setOutput('syntax-only', 'false')
}

if (label_names.includes('CI-published-bottle-commits')) {
console.log('CI-published-bottle-commits label found. Skipping tests job.')
core.setOutput('syntax-only', 'true')
}

if (label_names.includes('CI-linux-self-hosted')) {
core.setOutput('linux-runner', 'linux-self-hosted-1')
} else {
Expand Down Expand Up @@ -256,25 +265,25 @@ jobs:
with:
workdir: ${{matrix.workdir || github.workspace}}
result_path: bottles/steps_output.txt
step_name: 'Build summary on ${{ matrix.runner }}'
step_name: "Build summary on ${{ matrix.runner }}"

- name: Output brew linkage result
if: always()
uses: Homebrew/actions/failures-summary-and-bottle-result@master
with:
workdir: ${{matrix.workdir || github.workspace}}
result_path: bottles/linkage_output.txt
step_name: '`brew linkage` output on ${{ matrix.runner }}'
collapse: 'true'
step_name: "`brew linkage` output on ${{ matrix.runner }}"
collapse: "true"

- name: Output brew bottle result
if: always()
uses: Homebrew/actions/failures-summary-and-bottle-result@master
with:
workdir: ${{matrix.workdir || github.workspace}}
result_path: bottles/bottle_output.txt
step_name: '`brew bottle` output on ${{ matrix.runner }}'
collapse: 'true'
step_name: "`brew bottle` output on ${{ matrix.runner }}"
collapse: "true"

- name: Run brew test-bot ${{ needs.setup_tests.outputs.test-bot-dependents-args }} --skipped-or-failed-formulae=${{ steps.brew-test-bot-formulae.outputs.skipped_or_failed_formulae }}
if: ${{(success() || failure()) && fromJson(needs.setup_tests.outputs.test-dependents)}}
Expand All @@ -288,8 +297,8 @@ jobs:
with:
workdir: ${{matrix.workdir || github.workspace}}
result_path: bottles/steps_output.txt
step_name: 'Dependent summary on ${{ matrix.runner }}'
collapse: 'true'
step_name: "Dependent summary on ${{ matrix.runner }}"
collapse: "true"

- name: Upload logs
if: always()
Expand Down