RHEL-9: backport fixes for jinja-renderer #6973
Workflow file for this run
This file contains 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
# Check if only infrastructure files are changed when infrastructure label is set. | |
name: infrastructure-check | |
on: | |
pull_request: | |
types: [ "opened", "synchronize", "reopened", "labeled" ] | |
permissions: | |
contents: read | |
jobs: | |
infra-check: | |
if: contains(github.event.pull_request.labels.*.name, 'infrastructure') | |
runs-on: ubuntu-20.04 | |
name: Infra tags in commit messages | |
steps: | |
- name: Clone Anaconda repository | |
uses: actions/checkout@v3 | |
with: | |
# otherwise we are testing target branch instead of the PR branch (see pull_request_target trigger) | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: 0 | |
- name: Rebase to current | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git log --oneline -1 origin/${{ github.event.pull_request.base.ref }} | |
git rebase origin/${{ github.event.pull_request.base.ref }} | |
- name: Check if all commits have infra postfix or prefix | |
run: | | |
# get commit headers of all the commits added in this PR | |
for i in "$(git log --oneline --pretty=format:%s origin/${{ github.event.pull_request.base.ref }}..HEAD)"; do | |
if ! ( [[ $i =~ \(#infra\)$ ]] || [[ $i =~ ^infra: ]] ); then | |
echo "$i --> Is missing 'infra:' prefix or '(#infra)' postfix" | |
exit 1 | |
fi | |
done | |
- name: Check if all changed files are infra related | |
run: | | |
changed_files=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}..HEAD) | |
# print for debugging | |
echo "----- Changed files -----" | |
echo "$changed_files" | |
echo "-------------------------" | |
# load infrastructure file list | |
. .structure-config | |
failed_check="no" | |
for f in $changed_files; do | |
matched="no" | |
for infra_f in "${INFRASTRUCTURE_FILES[@]}"; do | |
if [[ "$f" =~ "$infra_f" ]]; then | |
matched="yes" | |
break | |
fi | |
done | |
if [ $matched == "no" ]; then | |
echo "$f is not part of the infrastructure" | |
failed_check="yes" | |
fi | |
done | |
if [ "$failed_check" == "yes" ]; then | |
exit 1 | |
fi | |
infra-reload-check: | |
runs-on: ubuntu-20.04 | |
name: Templates match results | |
steps: | |
- name: Clone Anaconda repository | |
uses: actions/checkout@v3 | |
with: | |
# TODO: Are we able to remove ref, fetch-depth and Rebase task? Seems that the checkout | |
# without ref is doing the rebase for us. | |
# otherwise we are testing target branch instead of the PR branch (see pull_request_target trigger) | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: 0 | |
- name: Rebase to current | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git log --oneline -1 origin/${{ github.event.pull_request.base.ref }} | |
git rebase origin/${{ github.event.pull_request.base.ref }} | |
- name: Determine commits to check | |
id: get_commits | |
run: | | |
COMMITS=$(git rev-list origin/${{ github.event.pull_request.base.ref }}..HEAD | tac) | |
# rev-list provides one hash per line, starting at HEAD, adding backwards. | |
# Why `tac` - commits are listed from HEAD backwards, which is reversed order, and need | |
# re-applying in the correct order. | |
echo -e "Commits found:\n$COMMITS" | |
COMMITS_ONELINE=$(echo $COMMITS | tr '\n' ' ') | |
# GH actions truncates plain multiline variables to first line when passing as output/input, | |
# so make it one line on our end and save the trouble. | |
echo "::set-output name=commits::$COMMITS_ONELINE" | |
- name: Check all commits | |
run: | | |
git checkout -b temp origin/${{ github.event.pull_request.base.ref }} | |
for COMMIT in ${{ steps.get_commits.outputs.commits }} ; do | |
echo "Checking $COMMIT" | |
git cherry-pick "$COMMIT" | |
make -f Makefile.am reload-infra | |
CHANGES=$(git status -s) | |
if [[ -n $CHANGES ]] ; then | |
echo "Templates out of sync after commit $COMMIT:" | |
git log -1 "$COMMIT" | |
git status | |
exit 1 | |
fi | |
done |