Skip to content

Commit

Permalink
infra: prompt for manual trigger in case external contributors can't …
Browse files Browse the repository at this point in the history
…run Web UI tests
  • Loading branch information
KKoukiou committed Nov 27, 2024
1 parent dcd2002 commit ccea668
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/trigger-webui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ on:
- 'master'
jobs:
trigger:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
# the default workflow token cannot read our org membership, for deciding who is allowed to trigger tests
environment: gh-cockpituous
container: registry.fedoraproject.org/fedora:40
Expand All @@ -51,6 +51,7 @@ jobs:
# than the COPR srpm build finishes.
- name: Wait for packit COPR build
run: |
exit 0
set -ex
PUSH_TIME=$(date --utc +%Y%m%d%H%M%S -d '${{ github.event.pull_request.head.repo.pushed_at }}')
COPR_NAME="${{ github.event.pull_request.base.user.login }}-${{ github.event.pull_request.base.repo.name }}-${{ github.event.number }}"
Expand All @@ -65,9 +66,29 @@ jobs:
done
exit 1
- name: Clone repository
# need the repo to successfully post a comment :-/
uses: actions/checkout@v4
with:
ref: ${{ needs.pr-info.outputs.sha }}
fetch-depth: 1

- name: Trigger anaconda run
env:
GH_TOKEN: ${{ github.token }}
run: |
git clone --depth=1 https://github.com/cockpit-project/bots
mkdir -p ~/.config/cockpit-dev
echo '${{ secrets.GITHUB_TOKEN }}' > ~/.config/cockpit-dev/github-token
bots/tests-trigger --repo ${{ github.repository }} ${{ github.event.number }} fedora-rawhide-boot/anaconda-pr-${{ github.event.number }}@rhinstaller/anaconda-webui
cmd_output=$(bots/tests-trigger --repo ${{ github.repository }} ${{ github.event.number }} fedora-rawhide-boot/anaconda-pr-${{ github.event.number }}@rhinstaller/anaconda-webui 2>&1)
if echo "$cmd_output" | grep -qv 'Override with --allow'; then
sha="${{ needs.pr-info.outputs.sha }}"
url="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts"
echo -e -n "Trigger manually Web UI tests for external contributors:\n bots/tests-trigger --repo ${{ github.repository }} --allow ${{ github.event.number }} fedora-rawhide-boot/anaconda-pr-${{ github.event.number }}@rhinstaller/anaconda-webui" > comment.txt
cat comment.txt
gh pr comment \
${{ github.event.issue.number }} \
-F comment.txt
fi
25 changes: 23 additions & 2 deletions .github/workflows/trigger-webui.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
- 'master'
jobs:
trigger:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
# the default workflow token cannot read our org membership, for deciding who is allowed to trigger tests
environment: gh-cockpituous
container: registry.fedoraproject.org/fedora:40
Expand All @@ -45,6 +45,7 @@ jobs:
# than the COPR srpm build finishes.
- name: Wait for packit COPR build
run: |
exit 0
set -ex
PUSH_TIME=$(date --utc +%Y%m%d%H%M%S -d '${{ github.event.pull_request.head.repo.pushed_at }}')
COPR_NAME="${{ github.event.pull_request.base.user.login }}-${{ github.event.pull_request.base.repo.name }}-${{ github.event.number }}"
Expand All @@ -59,10 +60,30 @@ jobs:
done
exit 1

- name: Clone repository
# need the repo to successfully post a comment :-/
uses: actions/checkout@v4
with:
ref: ${{ needs.pr-info.outputs.sha }}
fetch-depth: 1

- name: Trigger anaconda run
env:
GH_TOKEN: ${{ github.token }}
run: |
git clone --depth=1 https://github.com/cockpit-project/bots
mkdir -p ~/.config/cockpit-dev
echo '${{ secrets.GITHUB_TOKEN }}' > ~/.config/cockpit-dev/github-token
bots/tests-trigger --repo ${{ github.repository }} ${{ github.event.number }} fedora-rawhide-boot/anaconda-pr-${{ github.event.number }}@rhinstaller/anaconda-webui
cmd_output=$(bots/tests-trigger --repo ${{ github.repository }} ${{ github.event.number }} fedora-rawhide-boot/anaconda-pr-${{ github.event.number }}@rhinstaller/anaconda-webui 2>&1)
if echo "$cmd_output" | grep -qv 'Override with --allow'; then
sha="${{ needs.pr-info.outputs.sha }}"
url="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts"

echo -e -n "Trigger manually Web UI tests for external contributors:\n bots/tests-trigger --repo ${{ github.repository }} --allow ${{ github.event.number }} fedora-rawhide-boot/anaconda-pr-${{ github.event.number }}@rhinstaller/anaconda-webui" > comment.txt
cat comment.txt

gh pr comment \
${{ github.event.issue.number }} \
-F comment.txt
fi
{% endif %}

0 comments on commit ccea668

Please sign in to comment.