diff --git a/.github/workflows/run-since-updater.yml b/.github/workflows/run-since-updater.yml new file mode 100644 index 000000000000..03bcfe5b7c9d --- /dev/null +++ b/.github/workflows/run-since-updater.yml @@ -0,0 +1,41 @@ +name: Run update-since-todo.py + +on: + schedule: + - cron: "0 16 * * THU" + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + since_updater: + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'jenkinsci' }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Run update-since-todo.py + run: | + body=$(./update-since-todo.py) + + { + echo 'PROGRESS<> $GITHUB_OUTPUT + id: run_script + shell: bash + - name: Create Pull Request + uses: peter-evans/create-pull-request@8867c4aba1b742c39f8d0ba35429c2dfa4b6cb20 # v7 + 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 + branch: actions/update-since-todo + delete-branch: true diff --git a/update-since-todo.py b/update-since-todo.py index 044d441a935e..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 @@ -18,7 +19,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 +45,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 +76,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): @@ -99,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) @@ -107,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):