mirror of https://github.com/jenkinsci/jenkins.git
Automate the since updater (#7240)
Co-authored-by: Tim Jacomb <timjacomb1@gmail.com>
This commit is contained in:
parent
65f374c35a
commit
36c155e65e
|
|
@ -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<<EOF'
|
||||
echo "${body}"
|
||||
echo 'EOF'
|
||||
} >> $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
|
||||
|
|
@ -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("<details><summary>Detailed output</summary>\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("</details>\n")
|
||||
|
||||
|
||||
def display_results(commits_and_tags):
|
||||
|
|
|
|||
Loading…
Reference in New Issue