From dc015e68d1daa6afb18f58e264319ac5f4eaa45b Mon Sep 17 00:00:00 2001 From: Aziz Chynaliev Date: Mon, 7 Oct 2024 00:15:07 +0500 Subject: [PATCH] server: improve testmerge worker --- .github/workflows/testmerge.yml | 42 +++++++++++++++++++++++++++++---- tgui/bin/tgui | 4 +--- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/.github/workflows/testmerge.yml b/.github/workflows/testmerge.yml index 360cd0f5255..412da275f71 100644 --- a/.github/workflows/testmerge.yml +++ b/.github/workflows/testmerge.yml @@ -48,12 +48,30 @@ jobs: core.setFailed(`No pull requests with the label "${label_needed}" and no merge conflicts found.`); } core.setOutput('labeled_pr_details', prDetails); + - name: Git checkout uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} fetch-depth: 0 ref: ${{ env.BASE_BRANCH }} + + - uses: actions/setup-python@v5 + with: + python-version: '3.11.6' + cache: 'pip' + + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'yarn' + cache-dependency-path: ./tgui/yarn.lock + + - name: Install python packages + run: | + pip3 install -r tools/requirements.txt + pip3 install GitPython + - name: Iterate over PRs and perform actions id: prepare_testmerge_branch run: | @@ -64,6 +82,9 @@ jobs: git switch ${{ env.TESTMERGE_BRANCH }} || git switch -c ${{ env.TESTMERGE_BRANCH }} git reset --hard ${{ env.BASE_BRANCH }} + ./tools/hooks/install.sh + ./tgui/bin/tgui --install-git-hooks + # Print debug information echo "PR details JSON:" echo '${{ steps.get_labeled_prs.outputs.labeled_pr_details }}' @@ -71,25 +92,36 @@ jobs: echo '${{ steps.get_labeled_prs.outputs.labeled_pr_details }}' | jq -c '.[]' | while read -r PR_DETAIL; do PR_NUMBER=$(echo "$PR_DETAIL" | jq -r '.number') PR_TITLE=$(echo "$PR_DETAIL" | jq -r '.title') - echo "Preparing $PR_TITLE (#$PR_NUMBER)" - git fetch origin pull/$PR_NUMBER/head:pr-$PR_NUMBER + PR_LAST_COMMIT=$(git rev-parse --short pr-$PR_NUMBER | head -c 7) + PR_STRING="$PR_TITLE (#$PR_NUMBER) [$PR_LAST_COMMIT]" + echo "$PR_STRING: Preparing..." # Check for merge conflicts git merge --no-commit --no-ff pr-$PR_NUMBER || true CONFLICTS=$(git ls-files -u | wc -l) if [ "$CONFLICTS" -gt 0 ] ; then - echo "There is a merge conflict. Skipping $PR_TITLE (#$PR_NUMBER)" + echo "$PR_STRING: There is a merge conflict. Skipping!" git merge --abort continue fi git merge --abort git merge --squash pr-$PR_NUMBER - git commit -m "$PR_TITLE (#$PR_NUMBER) [testmerge]" + git commit -m "$PR_TITLE (#$PR_NUMBER) [testmerge][$PR_LAST_COMMIT]" # Perform your git actions here, for example: - echo "Successfully merged $PR_TITLE (#$PR_NUMBER)" + echo "$PR_STRING: Successfully merged!" done + # Generate changelog + python3 tools/changelog/gen_changelog.py + git add html/changelogs/archive/\*.yml + CHANGES=$(git diff --name-only --cached | wc -l) + if [ "$CHANGES" -gt 0 ] ; then + git config --local user.email "action@github.com" + git config --local user.name "Changelog Generation" + git commit -m "Automatic changelog generation" + fi + git push -f origin ${{ env.TESTMERGE_BRANCH }} diff --git a/tgui/bin/tgui b/tgui/bin/tgui index b442ccb45b4..4ee35164d84 100755 --- a/tgui/bin/tgui +++ b/tgui/bin/tgui @@ -136,7 +136,7 @@ task-merge-bundle() { echo "----------------------" echo "tgui: prepping to replace a conflicted bundle" cat $file_path > $file_current - task-rebuild-conflicted-bundle & + task-rebuild-conflicted-bundle exit 0 } @@ -145,8 +145,6 @@ task-rebuild-conflicted-bundle() { echo "tgui: rebuilding a conflicted tgui bundle, ${file_path}" task-install task-webpack --mode=production - echo "tgui: committing new bundle" - git commit -am "TGUI Bundle Rebuild" exit 0 }