From 34a6d3b1fb20704905548c10be06eb0bc59df767 Mon Sep 17 00:00:00 2001 From: PawAdam Date: Fri, 14 Nov 2025 12:18:56 +0000 Subject: [PATCH 1/3] new PR template and GHA for PR validation and automatic Changelog entries/versioning --- .github/PULL_REQUEST_TEMPLATE.md | 19 +- .../validate_pr_and_update_changelog.yml | 190 ++++++++++++++++++ 2 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/validate_pr_and_update_changelog.yml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 363942e..41da33a 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -25,4 +25,21 @@ Select all that apply: > [!CAUTION] > The above section is required and must not be manipulated other than checking the check boxes and filling out the summary/ticket information. There is a Github Action that will fail if the pull request template does not conform to this standard. If the ticket information or summary is not filled in it will try to get it from the branch name. ------- \ No newline at end of file +------ + +**Reason for Change**: + + +**Issue Fixed**: + + +**Requirements**: + + +- [ ] follows [commit message convention](https://einstein.kcura.com/pages/viewpage.action?spaceKey=DTT&title=How+to+work+with+git+and+pull+requests) +- [ ] functional tests build pipeline was successful https://trident.kcura.corp/dea/job/Productions/job/Run-Functional-Tests/ +- [ ] adds unit tests where appropriate +- [ ] updated changelog +- [ ] add JIRA story for toggle removal (if applicable) + +**Notes**: \ No newline at end of file diff --git a/.github/workflows/validate_pr_and_update_changelog.yml b/.github/workflows/validate_pr_and_update_changelog.yml new file mode 100644 index 0000000..a5f912e --- /dev/null +++ b/.github/workflows/validate_pr_and_update_changelog.yml @@ -0,0 +1,190 @@ +name: PR Verification and Changelog/Version Update +run-name: ${{ github.actor }} is verifying PR details +on: + pull_request: + types: [opened, synchronize, closed, edited] +jobs: + verify_details: + runs-on: ubuntu-latest + steps: + - name: Get Code + uses: actions/checkout@v4 + with: + ref: main + #token: ${{ secrets.SVC_PAT }} + + - name: Validate And Process PR Template + id: validate + run: | + changeType="Unknown" + deploymentDetails="" + summary="None" + foundEndTags=0 + + stop="false" + startTypeCapture="false" + startDeployCapture="false" + startSumCapture="false" + startTaskVerification="false" + + branch="${{ github.head_ref || github.ref_name }}" + b="${{ github.event.pull_request.body }}"; + mapfile -t StringArray <<< "$b" + for val in "${StringArray[@]}"; do + if [[ "$val" = ""* ]]; then + foundEndTags=$((foundEndTags+1)) + fi + + # echo "Found: $val" + if [[ "$val" = 'Pick **one** of the following:'* ]]; then + startTypeCapture="true" + elif [[ "$val" = "### Deployment Details"* ]]; then + startDeployCapture="true" + elif [[ "$val" = "### Summary"* ]]; then + startSumCapture="true" + elif [[ "$val" = "> [!CAUTION]"* ]]; then + startTaskVerification="true" + fi + + # echo "startTypeCapture: $startTypeCapture" + # echo "startDeployCapture: $startDeployCapture" + # echo "startSumCapture: $startSumCapture" + # echo "startTaskVerification: $startTaskVerification" + + if [[ "$startTypeCapture" = "true" ]]; then + if [[ "${val,,}" = "- - [x]"* ]]; then + prefix="- - [x] " + changeType="${val:8:100}" + startTypeCapture="found" + fi + + if [[ "$val" = ""* ]]; then + startTypeCapture="found" + fi + fi + + if [[ "$startDeployCapture" = "true" ]]; then + if [[ "${val,,}" = "- - [x]"* ]]; then + prefix="- - [x] " + deploymentDetails="$deploymentDetails(${val:8:100})" + fi + + if [[ "$val" = ""* ]]; then + startDeployCapture="found" + fi + fi + + if [[ "$startSumCapture" = "true" ]]; then + if [[ "$val" = ""* ]]; then + startSumCapture="found" + else + summary="$val" + fi + fi + + done; + + if [[ $foundEndTags -ne 3 ]]; then + echo "PR Template is invalid, expected to find 3 ''' tags!!!!" + exit 1 + fi + if [[ "$startSumCapture" != "found" ]]; then + echo "PR Template is invalid, expected to find '### Summary' section!!!!" + exit 1 + fi + if [[ "$startTypeCapture" != "found" ]]; then + echo "PR Template is invalid, expected to find 'Pick one of the following:' section!!!!" + exit 1 + fi + if [[ "$startDeployCapture" != "found" ]]; then + echo "PR Template is invalid, expected to find '### Deployment Details' section!!!!" + exit 1 + fi + + echo "Found raw change type: $changeType" + echo "Found raw deployment details: $deploymentDetails" + echo "Found raw summary: $summary" + + if [[ "$changeType" = "Unknown" ]]; then + echo "No change type!!!!" + exit 1 + fi + + echo "JIRA_LINK=$ticketLong" >> $GITHUB_OUTPUT + + prUrl="https://github.com/relativityone/centralized-review/pull/${{github.event.pull_request.number}}" + changelogLong="[$summary] » [$changeType]" + changelogShort="[$summary]" + if [ "$deploymentDetails" != "" ]; then + changelogLong="$changelogLong - [$deploymentDetails]" + fi + changelogLong="$changelogLong » [PR]($prUrl)" + + changelogLong="${changelogLong//[$'\t\r\n']}" + changelogShort="${changelogShort//[$'\t\r\n']}" + + echo "Final change log:" + echo $changelogLong + + echo "Final change commit message:" + echo $changelogShort + + echo "NEW_CHANGELOG_SHORT=$changelogShort" >> $GITHUB_ENV + echo "NEW_CHANGELOG_LONG=$changelogLong" >> $GITHUB_ENV + echo "DEPLOYMENT_DETS=$deploymentDetails" >> $GITHUB_ENV + shell: bash + + + - name: Update Version + if: github.base_ref == 'main' && github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + run: | + version=`cat version.txt` + changeType="${{ env.DEPLOYMENT_DETS }}" + if [[ "$changeType" = *"Has breaking changes"* ]]; then + echo "Major change" + IFS='.' read -r -a array <<< "$version" + major=${array[0]} + major=$((major+1)) + version="$major.0.0" + elif [[ "$changeType" = *"Cannot be rolled back"* || "$changeType" = *"Runs workspace upgrades"* ]]; then + echo "Minor change" + IFS='.' read -r -a array <<< "$version" + major=${array[0]} + minor=${array[1]} + minor=$((minor+1)) + version="$major.$minor.0" + else + echo "Small change" + IFS='.' read -r -a array <<< "$version" + major=${array[0]} + minor=${array[1]} + patch=${array[2]} + patch=$((patch+1)) + version="$major.$minor.$patch" + fi + echo "Updating to $version" + echo "$version" > "version.txt" + echo "NEW_VERSION=$version" >> $GITHUB_ENV + shell: bash + + - name: Update Changelog + if: github.base_ref == 'main' && github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + run: | + changelog="${{ env.NEW_CHANGELOG_LONG }}" + version="${{ env.NEW_VERSION }}" + versionText="#### $version ($(date -I))" + printf '%s\n%s\n' "" "$(cat CHANGELOG.md)" > CHANGELOG.md + printf '%s\n%s\n' "$changelog" "$(cat CHANGELOG.md)" > CHANGELOG.md + printf '%s\n%s\n\n' "$versionText" "$(cat CHANGELOG.md)" > CHANGELOG.md + shell: bash + + - name: Push changelog and version to main + if: github.base_ref == 'main' && github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + run: | + version="${{ env.NEW_VERSION }}" + git config user.name 'GitHub Action' + git config user.email 'svc_review-center.github-actions@relativity.com' + git add . + git commit -m "[$version] Update version and change log" + git push origin main + shell: bash \ No newline at end of file From 7ae1ccbfb33b0d3f0e8f852b1c4f9d1998105499 Mon Sep 17 00:00:00 2001 From: PawAdam <219140720+PawAdam@users.noreply.github.com> Date: Fri, 14 Nov 2025 12:23:17 +0000 Subject: [PATCH 2/3] Auto-bumping version.txt --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index c5d54ec..7c1886b 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.0.9 +0.0.10 From b85fc13655e5c37362a9e114e7ebc8303c75468a Mon Sep 17 00:00:00 2001 From: PawAdam Date: Fri, 14 Nov 2025 12:26:06 +0000 Subject: [PATCH 3/3] small change to PR template --- .github/PULL_REQUEST_TEMPLATE.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 41da33a..8fa6627 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -18,8 +18,7 @@ Select all that apply: - - [ ] Runs workspace upgrades - - [ ] Has breaking changes -### Jira/Ticket - + ### Summary > [!CAUTION]