Changelog test (bsc#1231235) #61
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
name: Changelogs | |
on: | |
pull_request_target: | |
types: [opened, edited, synchronize, reopened, closed] | |
# Only execute on the main branches (feature branches are excluded) | |
branches: | |
- changelog-action | |
- master | |
# Uyuni patches | |
- 'Uyuni-[0-9]+.[0-9]+' | |
# SUSE Manager milestones | |
- 'Manager-[0-9]+.[0-9]+-Alpha[0-9]?' | |
- 'Manager-[0-9]+.[0-9]+-Beta[0-9]?' | |
- 'Manager-[0-9]+.[0-9]+-RC[0-9]?' | |
- 'Manager-[0-9]+.[0-9]+-GMC[0-9]?' | |
- 'Manager-[0-9]+.[0-9]+-GM[0-9]?' | |
# SUSE Manager releases | |
- 'Manager-[0-9]+.[0-9]+' | |
- 'Manager-[0-9]+.[0-9]+-MU-[0-9]+.[0-9]+.[0-9]+' | |
# Only execute on directories that have changelogs | |
paths: | |
- 'branding/**' | |
- 'client/**' | |
- 'containers/**' | |
- 'java/**' | |
- 'projects/**' | |
- 'proxy/**' | |
- 'python/**' | |
- 'reporting/**' | |
- 'schema/**' | |
- 'search-server/**' | |
- 'selinux/**' | |
- 'spacecmd/**' | |
- 'spacewalk/**' | |
- 'susemanager/**' | |
- 'susemanager-branding-oss/**' | |
- 'susemanager-sync-data/**' | |
- 'susemanager-utils/**' | |
- 'suseRegisterInfo/**' | |
- 'tftpsync/**' | |
- 'utils/**' | |
- 'uyuni/**' | |
- 'web/**' | |
jobs: | |
changelog_test: | |
name: Changelog tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone PR head branch | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
HEAD_REPO: ${{ github.event.pull_request.head.repo.clone_url }} | |
HEAD_BRANCH: ${{ github.event.pull_request.head.ref }} | |
run: | | |
echo "Cloning head branch from $HEAD_REPO" | |
git clone --depth 2 --branch $HEAD_BRANCH $HEAD_REPO . | |
echo $(pwd) | |
ls -R . | |
git log -1 | |
- id: master | |
name: Get modified master changelog files | |
uses: Ana06/get-changed-files@v2.3.0 | |
with: | |
filter: '*.changes' | |
- name: Fail if the master changelog files are modified | |
if: steps.master.outputs.all | |
run: | | |
echo "Master changelog files cannot be modified directly." | |
echo "Please revert your changes on the following master changelog file(s):" | |
for file in ${{steps.master.outputs.all}} | |
do | |
echo " - $file" | |
done | |
echo | |
echo "See https://github.com/uyuni-project/uyuni/wiki/Contributing for a guide to writing changelogs." | |
exit 1 | |
- id: files | |
name: Get changed files | |
uses: Ana06/get-changed-files@v2.3.0 | |
- name: Test changelog entries | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BZ_TOKEN: ${{ secrets.BUGZILLA_TOKEN }} | |
run: | | |
pip install python-bugzilla~=3.2.0 | |
echo "Changed files:" | |
echo ${{ steps.files.outputs.added_modified }} | |
# Tracker file can be retrieved from the OBS/IBS API | |
# by calling 'osc api /issue_trackers/' (with authentication) | |
python .github/workflows/changelogs/changelogs.py -v \ | |
--tracker-file .github/workflows/changelogs/trackers.xml \ | |
--git-repo uyuni-project/uyuni \ | |
--pr-number ${{ github.event.pull_request.number }} \ | |
${{ steps.files.outputs.added_modified }} | |
# Warns the user if they merged the PR, but the changelog test failed | |
warn_user_if_merged: | |
name: Warn user if merged | |
if: always() && github.event.action == 'closed' && github.event.pull_request.merged == true && needs.changelog_test.result == 'failure' | |
needs: changelog_test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Remind the author with a comment | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
:warning: No changelog entry has been added. @${{ github.event.pull_request.user.login }}, please add necessary changelog entries with an additional PR. |