Skip to content

Commit

Permalink
[release-1.33] Verify promotion tag for patch releases (#2755)
Browse files Browse the repository at this point in the history
* Verify promotion tag for patch releases

One of the pre-requisites for patch releases is to bump the
promotion tag and name.

With this additional verification, we make sure that it's done
before or block the PR from merging if not done.

Signed-off-by: Pierangelo Di Pilato <[email protected]>

* Temp: Test failure

Signed-off-by: Pierangelo Di Pilato <[email protected]>

* Update output

Signed-off-by: Pierangelo Di Pilato <[email protected]>

* Use separate workflow file

Signed-off-by: Pierangelo Di Pilato <[email protected]>

* Revert "Temp: Test failure"

This reverts commit 56248b6.

* Remove restriction on file

Signed-off-by: Pierangelo Di Pilato <[email protected]>

---------

Signed-off-by: Pierangelo Di Pilato <[email protected]>
  • Loading branch information
pierDipi authored Jul 5, 2024
1 parent a85a5dd commit fb0580c
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
88 changes: 88 additions & 0 deletions .github/workflows/validate-release-promotion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
name: Validate Release Promotion

on:
pull_request:
branches:
- 'release-**'

jobs:
promotion:
if: ${{ github.event_name == 'pull_request' && contains(github.base_ref, 'release-') }}
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
steps:

- name: Setup Golang
uses: actions/setup-go@v5
with:
go-version: 1.21.x

- name: Install yq
run: |
go install github.com/mikefarah/yq/v3@latest
- name: Checkout
uses: actions/checkout@v4
with:
path: ./src/github.com/openshift-knative/serverless-operator
fetch-depth: 0

- name: Merge upstream
if: github.event_name == 'pull_request'
working-directory: ./src/github.com/openshift-knative/serverless-operator
run: |
if ! git config user.name > /dev/null; then
git config user.name "John Doe"
fi
if ! git config user.email > /dev/null; then
git config user.email "johndoe@localhost"
fi
git remote add upstream https://github.com/openshift-knative/serverless-operator.git
git pull --no-rebase upstream ${{ github.base_ref }}
shell: bash

- name: Checkout openshift/release
uses: actions/checkout@v4
with:
branch: 'master'
repository: 'openshift/release'
path: ./src/github.com/openshift/release

- name: Verify promotion tag or name in openshift/release
working-directory: ./src/github.com/openshift/release
shell: bash
run: |
tag="release-$(yq read ../../openshift-knative/serverless-operator/olm-catalog/serverless-operator/project.yaml 'project.version')"
release=${{ github.base_ref }}
count=0
while IFS= read -r -d '' file
do
promotion_name=$(yq r "$file" 'promotion.to[0].name')
if [ "$promotion_name" != "" ] && [ "$promotion_name" != "${tag}" ]; then
count=$(( count + 1 ))
echo "File: $file"
echo "promotion.to[0].name: $promotion_name"
echo
fi
promotion_tag=$(yq r "$file" 'promotion.to[0].tag')
if [ "$promotion_tag" != "" ] && [ "$promotion_tag" != "${tag}" ]; then
count=$(( count + 1 ))
echo "File: $file"
echo "promotion.to[0].name: $promotion_tag"
echo
fi
done < <(find ci-operator/config/openshift-knative/serverless-operator -type f -name "*${release}*" -print0)
if [ $count -ne 0 ]; then
echo "## $count files with an unexpected promotion name or tag"
echo "1. Use the [release-generate-ci](https://github.com/openshift-knative/serverless-operator/actions/workflows/release-generate-ci.yaml?query=branch%3Arelease-1.33) GH actions workflow in serverless-operator on the $release branch with inputs:"
echo " - **use workflow from**: **$release**"
echo " - **branch**: **$release**"
echo " - **tag**: **$tag**"
echo "2. merge the created PR in openshift/release"
exit 1
fi
2 changes: 1 addition & 1 deletion .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
uses: golangci/golangci-lint-action@v5
with:
version: v1.55.2
args: --timeout=10m0s --verbose
args: --timeout=10m0s --verbose
working-directory: ./src/github.com/${{ github.repository }}

# This is mostly copied from https://github.com/get-woke/woke-action-reviewdog/blob/main/entrypoint.sh
Expand Down

0 comments on commit fb0580c

Please sign in to comment.