Fix "Run tests (with coverage collection)" ignoring test failures (#716) #275
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto update broker variant branches | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| concurrency: auto-update-broker-variants | |
| permissions: | |
| pull-requests: write | |
| contents: write | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| jobs: | |
| update-snap-branches: | |
| name: Update snap branches | |
| strategy: | |
| matrix: | |
| branch_name: ["google","msentraid"] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: canonical/desktop-engineering/gh-actions/common/dpkg-install-speedup@main | |
| - name: Install dependencies | |
| run: | | |
| set -eu | |
| sudo apt-get update | |
| sudo apt-get install -y git | |
| - uses: actions/checkout@v5 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Merge main into branches | |
| id: merge | |
| run: | | |
| set -eux | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git fetch | |
| git checkout ${{ matrix.branch_name }} | |
| # First, assume that we will have conflicts due to the merge command | |
| # failing the action if there's any. | |
| echo "has_conflicts=true" >> $GITHUB_OUTPUT | |
| has_conflicts=true | |
| if git merge main --commit; then | |
| has_conflicts=false | |
| fi | |
| echo "has_conflicts=${has_conflicts}" >> $GITHUB_OUTPUT | |
| - uses: actions/setup-go@v6 | |
| if: ${{ steps.merge.outputs.has_conflicts == 'false' }} | |
| with: | |
| go-version-file: go.mod | |
| - name: Regenerate consts for this broker | |
| if: ${{ steps.merge.outputs.has_conflicts == 'false' }} | |
| run: | | |
| set -eux | |
| # Regenerate the consts for the broker | |
| go generate ./internal/consts/ | |
| - name: Find generated changes | |
| if: ${{ steps.merge.outputs.has_conflicts == 'false' }} | |
| id: check-diff | |
| uses: canonical/desktop-engineering/gh-actions/common/has-diff@main | |
| with: | |
| working-directory: ./internal/consts/ | |
| fail-on-diff: false | |
| - name: Commit generated changes | |
| if: ${{ steps.merge.outputs.has_conflicts == 'false' && steps.check-diff.outputs.diff == 'true' }} | |
| run: | | |
| set -eux | |
| git add ./internal/consts/ | |
| git commit -m "Regenerate consts for ${{ matrix.branch_name }}" | |
| - name: Create Pull Request | |
| if: ${{ steps.merge.outputs.has_conflicts == 'false' }} | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| commit-message: Auto update ${{ matrix.branch_name }} branch | |
| title: Auto update ${{ matrix.branch_name }} branch | |
| body: | | |
| Automated merge from main of ${{ matrix.branch_name }}. | |
| branch: update-${{ matrix.branch_name }} | |
| delete-branch: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Push branch | |
| if: ${{ steps.merge.outputs.has_conflicts == 'false' }} | |
| run: | | |
| set -eux | |
| git push origin update-${{ matrix.branch_name }}:${{ matrix.branch_name }} | |
| - name: Restore and prepare branch | |
| if: ${{ steps.merge.outputs.has_conflicts == 'true' }} | |
| run: | | |
| set -eux | |
| # Reset the state of the current destination | |
| git merge --abort | |
| # Apply the changes we want to merge (which is the content of main) | |
| git reset --hard main | |
| - name: Create Pull Request | |
| if: ${{ steps.merge.outputs.has_conflicts == 'true' }} | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| commit-message: Auto update ${{ matrix.branch_name }} branch | |
| title: Auto update ${{ matrix.branch_name }} branch | |
| body: | | |
| Pull request created due to conflicts found when merging main into ${{ matrix.branch_name }}. | |
| Remember to run go generate ./internal/consts/ and committing those changes before merging this PR. | |
| branch: update-${{ matrix.branch_name }} | |
| delete-branch: true | |
| token: ${{ secrets.GITHUB_TOKEN }} |