From 6f00900454df1a5bdecc0cbfc4e1c91e65ec3fc7 Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Tue, 24 Sep 2024 17:10:20 +0200 Subject: [PATCH 1/6] change the way to get the first one --- .github/workflows/autoupdate.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml index 96dcc2c..122164f 100644 --- a/.github/workflows/autoupdate.yml +++ b/.github/workflows/autoupdate.yml @@ -124,7 +124,9 @@ jobs: DIFF_BRANCH="origin/$REPO" else # Check if a closed PR exists with the same title - if gh_pr_list_out=$(gh pr list --search "is:closed is:unmerged '$TITLE' in:title" | grep -P "^\d+\t[^\t]+\tplanemo-autoupdate:" | head -n 1); then + if gh_pr_list_out=$(gh pr list --search "is:closed is:unmerged '$TITLE' in:title" | grep -P "^\d+\t[^\t]+\tplanemo-autoupdate:"); then + # Only take the first one + gh_pr_list_out=$(echo "$gh_pr_list_out" | head -n 1) echo "Found a closed PR with title: $TITLE" OLD_TITLE=$(echo "$gh_pr_list_out" | cut -f 2) PR_EXISTS=1 From cefcc1d2975233375a6235ec3e82bb6f6e6af062 Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Tue, 24 Sep 2024 17:38:01 +0200 Subject: [PATCH 2/6] if a single line change in the changelog ignore it --- .github/workflows/autoupdate.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml index 122164f..3e6a01d 100644 --- a/.github/workflows/autoupdate.yml +++ b/.github/workflows/autoupdate.yml @@ -152,6 +152,15 @@ jobs: fi fi if ! git diff $DIFF_BRANCH --quiet $FILE_TO_CHECK; then + # Check if it is only the date in workflows + if [[ "$REPO" = "workflows/"* ]]; then + if [ $(git diff --numstat $DIFF_BRANCH $FILE_TO_CHECK | cut -f 1) = "1" ]; then + echo "A single line was added, probably the date, nothing is changed" + # clean up for the next repo + git checkout -- . + continue + fi + fi echo "There are changes" if [ "$PR_EXISTS" -eq 1 ]; then # Check if the last commit of the existing branch was manual From c4470d00db18b6fc1df5469357a5a11c02799517 Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Tue, 24 Sep 2024 23:09:14 +0200 Subject: [PATCH 3/6] avoid duplicated lines in changelog and PR body --- pr_text_iwc.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pr_text_iwc.py b/pr_text_iwc.py index 91bf5d5..e66f1ba 100644 --- a/pr_text_iwc.py +++ b/pr_text_iwc.py @@ -28,15 +28,18 @@ ) with open(args.log) as f: + already_reported = {} for line in f.readlines(): if " -> " in line: words = line.split() from_version = words[1] to_version = words[3] - text.append(f"* `{from_version}` should be updated to `{to_version}`") - new_changelog_lines.append( - f"- `{from_version}` was updated to `{to_version}`" - ) + if to_version not in already_reported.get(from_version, []): + text.append(f"* `{from_version}` should be updated to `{to_version}`") + new_changelog_lines.append( + f"- `{from_version}` was updated to `{to_version}`" + ) + already_reported[from_version] = already_reported.get(from_version, []) + [to_version] if "The workflow release number has been updated" in line: release_line = line text.append(f"\n{release_line}") From 646e6c5254b3e5a9a15145fbe0b165d090d1292a Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Tue, 24 Sep 2024 23:15:00 +0200 Subject: [PATCH 4/6] add info on strategy on the PR message --- pr_text.py | 5 +++++ pr_text_iwc.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/pr_text.py b/pr_text.py index 7237c4e..b9c5f9e 100644 --- a/pr_text.py +++ b/pr_text.py @@ -56,6 +56,11 @@ "For any comments, queries or criticism about the bot, not related to the tool being updated in this PR, please create an issue [here](https://github.com/planemo-autoupdate/autoupdate/issues/new)." ) +# Add info on the strategy +text.append("\nIf you want to skip this change, close this PR without deleting the branch. It will be reopened if another change is detected.") +text.append("Any commit from another author than 'planemo-autoupdate' will prevent more auto-updates.") +text.append("To ignore manual changes and allow autoupdates, delete the branch.") + with open(args.out, "w") as f: f.write("\n\n".join(text)) diff --git a/pr_text_iwc.py b/pr_text_iwc.py index e66f1ba..c485305 100644 --- a/pr_text_iwc.py +++ b/pr_text_iwc.py @@ -44,6 +44,11 @@ release_line = line text.append(f"\n{release_line}") +# Add info on the strategy +text.append("\nIf you want to skip this change, close this PR without deleting the branch. It will be reopened if another change is detected.") +text.append("Any commit from another author than 'planemo-autoupdate' will prevent more auto-updates.") +text.append("To ignore manual changes and allow autoupdates, delete the branch.") + with open(args.out, "w") as f: f.write("\n".join(text)) From 1b1b440c6a7e438bb1f3170666d366aa4a2171f9 Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Thu, 26 Sep 2024 09:10:54 +0200 Subject: [PATCH 5/6] write an issue to the repo if there were errors. --- .github/workflows/autoupdate.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml index 3e6a01d..2a3e206 100644 --- a/.github/workflows/autoupdate.yml +++ b/.github/workflows/autoupdate.yml @@ -217,6 +217,15 @@ jobs: if [ ! -z "$errors" ]; then echo "ERRORS OCCURED DURING AUTOUPDATE:" echo -e $errors + # Write these errors to an issue + body="$(date), there were errors when running autoupdate\n\n$errors" + echo -e $body > body.txt + if gh_issue_list=$(gh issue list --author "planemo-autoupdate" | grep -P "^\d+\t[^\t]+\tAutoupdate errors\t"); then + gh issue comment $(echo "$gh_issue_list" | cut -f 1 | head -n 1) -F body.txt + else + gh issue create -t "Autoupdate errors" -F body.txt + fi + rm body.txt exit 1 fi working-directory: ./tools_repo From 57082dff4b3fe55cca8b33afb3c3383239ce55dc Mon Sep 17 00:00:00 2001 From: Lucille Delisle Date: Thu, 26 Sep 2024 09:29:24 +0200 Subject: [PATCH 6/6] put in 'errors' the last line of the stderr --- .github/workflows/autoupdate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml index 2a3e206..9be465a 100644 --- a/.github/workflows/autoupdate.yml +++ b/.github/workflows/autoupdate.yml @@ -92,7 +92,7 @@ jobs: echo "Running autoupdate command..." cd "$REPO" # This may fail - planemo autoupdate . --skiplist "${{ github.workspace }}/autoupdate/${{ matrix.upstream_repo_owner }}_${{ matrix.upstream_repo_name }}_skip_list" > "${{ github.workspace }}/autoupdate.log" || errors="${errors}\nCannot autoupdate $REPO" + planemo autoupdate . --skiplist "${{ github.workspace }}/autoupdate/${{ matrix.upstream_repo_owner }}_${{ matrix.upstream_repo_name }}_skip_list" 2>&1 1> "${{ github.workspace }}/autoupdate.log" | tee "${{ github.workspace }}/autoupdate.err" || errors="${errors}\nCannot autoupdate $REPO, last line of stderr is\n$(tail -n 1 "${{ github.workspace }}/autoupdate.err")" rm -f tool_test_output.* tools.yml cd - # Check if it changed something