From c3039c2f945a65412ee012e321986c5b0683f5b6 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Sun, 9 Oct 2022 20:44:46 +0200 Subject: [PATCH 1/3] chore: Automate the since updater --- .github/workflows/run-since-updater.yml | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/run-since-updater.yml diff --git a/.github/workflows/run-since-updater.yml b/.github/workflows/run-since-updater.yml new file mode 100644 index 000000000000..f76782738d24 --- /dev/null +++ b/.github/workflows/run-since-updater.yml @@ -0,0 +1,36 @@ +name: Run update-since-todo.py + +on: + schedule: + - cron: "0 16 * * THU" + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + run_script: + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'jenkinsci' }} + steps: + - uses: actions/checkout@v3 + - name: Run update-since-todo.py + run: | + body=$(./update-since-todo.py) + body="${body//'%'/'%25'}" + body="${body//$'\n'/'%0A'}" + body="${body//$'\r'/'%0D'}" + echo "PROGRESS=$body" >> $GITHUB_OUTPUT + id: run_script + shell: bash + - name: Create Pull Request + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: Fill in since annotations + title: Fill in since annotations + body: ${{ steps.run_script.outputs.PROGRESS }} + base: master + labels: skip-changelog + delete-branch: true From f8e2844760351dd5ab31783f0ca94605aca9bf02 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Tue, 10 Sep 2024 21:36:13 +0100 Subject: [PATCH 2/3] Refresh for 2024 --- .github/workflows/run-since-updater.yml | 19 ++++++++++++------- update-since-todo.py | 9 +++++---- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/run-since-updater.yml b/.github/workflows/run-since-updater.yml index f76782738d24..03bcfe5b7c9d 100644 --- a/.github/workflows/run-since-updater.yml +++ b/.github/workflows/run-since-updater.yml @@ -10,22 +10,26 @@ permissions: pull-requests: write jobs: - run_script: + since_updater: runs-on: ubuntu-latest if: ${{ github.repository_owner == 'jenkinsci' }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Run update-since-todo.py run: | body=$(./update-since-todo.py) - body="${body//'%'/'%25'}" - body="${body//$'\n'/'%0A'}" - body="${body//$'\r'/'%0D'}" - echo "PROGRESS=$body" >> $GITHUB_OUTPUT + + { + echo 'PROGRESS<> $GITHUB_OUTPUT id: run_script shell: bash - name: Create Pull Request - uses: peter-evans/create-pull-request@v4 + uses: peter-evans/create-pull-request@8867c4aba1b742c39f8d0ba35429c2dfa4b6cb20 # v7 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: Fill in since annotations @@ -33,4 +37,5 @@ jobs: body: ${{ steps.run_script.outputs.PROGRESS }} base: master labels: skip-changelog + branch: actions/update-since-todo delete-branch: true diff --git a/update-since-todo.py b/update-since-todo.py index 044d441a935e..cbddfc99c797 100755 --- a/update-since-todo.py +++ b/update-since-todo.py @@ -18,7 +18,7 @@ def update_file(file, lineno, old, new): :param old: The old substring. :param new: The new substring. """ - print("\tUpdating file in place") + print("* Updating file in place") with fileinput.FileInput(file, inplace=True) as f: for line in f: if f.lineno() == lineno and old in line: @@ -44,13 +44,13 @@ def analyze_file(file, lineno, commits_and_tags, dry_run=False): .split("\n", 1)[0] .split(" ", 1)[0] ) - print(f"\tfirst sha: {line_sha}") + print(f"* first sha: {line_sha}") first_tag = subprocess.check_output( [GIT, "tag", "--sort=creatordate", "--contains", line_sha, "jenkins-*"], text=True, ).split("\n", 1)[0] if first_tag: - print(f"\tfirst tag was {first_tag}") + print(f"* first tag was {first_tag}") commits_and_tags[line_sha] = first_tag if not dry_run: since_version = first_tag.replace("jenkins-", "") @@ -75,10 +75,11 @@ def analyze_file(file, lineno, commits_and_tags, dry_run=False): else: print( - "\tNot updating file, no tag found. " + "* Not updating file, no tag found. " "Normal if the associated PR/commit is not merged and released yet; " "otherwise make sure to fetch tags from jenkinsci/jenkins" ) + print() # Add a newline for markdown rendering def analyze_files(commits_and_tags, dry_run=False): From b6508cd688c50ba22fce417ecda19e891fe95227 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Wed, 11 Sep 2024 21:58:00 +0100 Subject: [PATCH 3/3] Collapse debug output --- update-since-todo.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/update-since-todo.py b/update-since-todo.py index cbddfc99c797..3b0241a9928f 100755 --- a/update-since-todo.py +++ b/update-since-todo.py @@ -3,6 +3,7 @@ import argparse import fileinput import io +import os import shutil import subprocess @@ -100,6 +101,10 @@ def analyze_files(commits_and_tags, dry_run=False): "*.jelly", "*.js", ] + + runningInCI = os.environ.get("CI", "false") == "true" + if runningInCI: + print("
Detailed output\n\n") with subprocess.Popen(cmd, stdout=subprocess.PIPE) as proc: for line in io.TextIOWrapper(proc.stdout): parts = line.rstrip().split(":", 2) @@ -108,6 +113,8 @@ def analyze_files(commits_and_tags, dry_run=False): if retcode: raise subprocess.CalledProcessError(retcode, cmd) print() + if runningInCI: + print("
\n") def display_results(commits_and_tags):