Skip to content

chore: bump org.jsoup:jsoup from 1.17.2 to 1.18.1 #160

chore: bump org.jsoup:jsoup from 1.17.2 to 1.18.1

chore: bump org.jsoup:jsoup from 1.17.2 to 1.18.1 #160

name: Create issues from todos
on:
push:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpull_requestpull_request_targetbranchesbranches-ignore
branches:
- master
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-excluding-paths
paths-ignore:
- '**.json'
- '**.jpg'
- '**.png'
- '**.ico'
- '**.md'
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: write # for "git push"
issues: write # connect-todos-to-issues.sh uses "gh issue create"
defaults:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun
run:
# Enable fail-fast behavior using set -eo pipefail
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
shell: bash
jobs:
extract-pdd-puzzles:
name: Extract todos from code
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
runs-on: ubuntu-22.04
steps:
- name: Clone source code
uses: actions/checkout@v4.2.1 # https://github.com/actions/checkout
with:
# Whether to configure the token or SSH key with the local git config. Default: true
persist-credentials: true
- name: Install pdd
run: sudo gem install pdd:0.24.0 --no-document
- name: Checkout existing todos to another directory
run: |
git fetch --depth=1 origin generated-todos
git worktree add generated-todos generated-todos
- name: Extract todos
run: |
pdd \
--skip-gitignore \
--exclude '**/*.json' \
--exclude '**/*.jpg' \
--exclude '**/*.png' \
--exclude '**/*.ico' \
--exclude '**/*.md' \
--exclude '**/*.enc' \
--exclude 'src/test/wiremock/**/*' \
--exclude 'generated-todos/**' \
--verbose \
--format json \
--file pdd.json
- name: Remove the current date from pdd.json
run: sed -i '/"date":/d' pdd.json
- name: Generate todos-in-code.tsv
run: ./src/main/scripts/ci/pdd-json-to-tsv.sh < pdd.json > todos-in-code.tsv
# @todo #1610 Close an issue or post a comment when a puzzle got removed from code
# @todo #1610 Post a comment when issue got closed without removing a puzzle
- name: Check whether there are new todos
run: |
PUZZLES_FILES_MODIFIED=no
if [ ! -f generated-todos/pdd.json ]; then
echo 'pdd.json has just been created'
mv pdd.json generated-todos/pdd.json
PUZZLES_FILES_MODIFIED=yes
elif ! diff --brief generated-todos/pdd.json pdd.json >/dev/null; then
echo 'pdd.json has been modified'
mv pdd.json generated-todos/pdd.json
PUZZLES_FILES_MODIFIED=yes
fi
if [ ! -f generated-todos/todos-in-code.tsv ]; then
echo 'todos-in-code.tsv has just been created'
mv todos-in-code.tsv generated-todos/todos-in-code.tsv
PUZZLES_FILES_MODIFIED=yes
elif ! diff --brief generated-todos/todos-in-code.tsv todos-in-code.tsv >/dev/null; then
echo 'todos-in-code.tsv has been modified'
mv todos-in-code.tsv generated-todos/todos-in-code.tsv
PUZZLES_FILES_MODIFIED=yes
fi
if [ "$PUZZLES_FILES_MODIFIED" = 'yes' ]; then
printf 'pdd.json: %d puzzles\n' "$(jq '.puzzles | length' generated-todos/pdd.json)"
printf 'todos-in-code.tsv: %d todos\n' "$(sed 1d generated-todos/todos-in-code.tsv | wc -l)"
else
echo 'neither pdd.json nor todos-in-code.tsv have been modified'
fi
# Make variable available for the next steps
echo "PUZZLES_FILES_MODIFIED=$PUZZLES_FILES_MODIFIED" | tee -a "$GITHUB_ENV"
# It's possible that for some puzzles we haven't created issues yet
# (because of network, rate limit or other kind of errors)
- name: Check whether there are puzzles without related issues
if: env.PUZZLES_FILES_MODIFIED == 'no'
working-directory: generated-todos
run: |
NEW_PUZZLES="$(comm -23 <(cut -d$'\t' -f1 todos-in-code.tsv | sort) <(cut -d$'\t' -f1 todos-on-github.tsv | sort))"
if [ -n "$NEW_PUZZLES" ]; then
echo "Found puzzles without related issues:"
echo "$NEW_PUZZLES" | while read PUZZLE_ID; do
TITLE="$(grep "$PUZZLE_ID" todos-in-code.tsv | cut -d$'\t' -f3 | sed 's|^"||;s|"$||;s|""|"|g')"
echo "- $PUZZLE_ID: $TITLE"
done
HAVE_PUZZLES_WITHOUT_ISSUES=yes
else
HAVE_PUZZLES_WITHOUT_ISSUES=no
fi
# Make variable available for the next steps
echo "HAVE_PUZZLES_WITHOUT_ISSUES=$HAVE_PUZZLES_WITHOUT_ISSUES" | tee -a "$GITHUB_ENV"
- name: Connect todos to the issues
if: env.PUZZLES_FILES_MODIFIED == 'yes' || env.HAVE_PUZZLES_WITHOUT_ISSUES == 'yes'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./src/main/scripts/ci/connect-todos-to-issues.sh generated-todos/todos-in-code.tsv
- name: Check whether todos-on-github.tsv has been modified
if: env.PUZZLES_FILES_MODIFIED == 'yes' || env.HAVE_PUZZLES_WITHOUT_ISSUES == 'yes'
working-directory: generated-todos
run: |
PUZZLES_MAPPING_MODIFIED=no
if ! git diff-index --quiet HEAD -- todos-on-github.tsv; then
PUZZLES_MAPPING_MODIFIED=yes
echo 'todos-on-github.tsv has been modified'
fi
# Make variable available for the next steps
echo "PUZZLES_MAPPING_MODIFIED=$PUZZLES_MAPPING_MODIFIED" | tee -a "$GITHUB_ENV"
- name: Initialize Git variables for committing the changes
if: env.PUZZLES_FILES_MODIFIED == 'yes' || env.PUZZLES_MAPPING_MODIFIED == 'yes'
run: |
AUTHOR_EMAIL="$(git show "$GITHUB_SHA" --no-patch --format=%aE)"
AUTHOR_NAME="$(git show "$GITHUB_SHA" --no-patch --format=%aN)"
# Make variables available for the next steps
(
echo "COMMIT_MSG=$(git show "$GITHUB_SHA" --no-patch --format=oneline --abbrev-commit)"
echo "GIT_AUTHOR_NAME=GitHub Action on behalf of $AUTHOR_NAME"
echo "GIT_COMMITTER_NAME=GitHub Action on behalf of $AUTHOR_NAME"
echo "GIT_AUTHOR_EMAIL=$AUTHOR_EMAIL"
echo "GIT_COMMITTER_EMAIL=$AUTHOR_EMAIL"
) | tee -a "$GITHUB_ENV"
- name: Commit the changes
if: env.PUZZLES_FILES_MODIFIED == 'yes'
env:
NEW_COMMIT_MSG: "chore: processed ${{ env.COMMIT_MSG }}"
working-directory: generated-todos
run: |
git add pdd.json
git commit pdd.json todos-in-code.tsv -m "$NEW_COMMIT_MSG"
git push
- name: Commit updated mapping
if: env.PUZZLES_MAPPING_MODIFIED == 'yes'
env:
NEW_COMMIT_MSG: "chore: sync issues for ${{ env.COMMIT_MSG }}"
working-directory: generated-todos
run: |
git add todos-on-github.tsv
git commit todos-on-github.tsv -m "$NEW_COMMIT_MSG"
git push
- name: Cleanup
if: always()
run: |
[ ! -f pdd.json ] || rm -fv pdd.json
[ ! -f todos-in-code.tsv ] || rm -fv todos-in-code.tsv
[ ! -d generated-todos ] || git worktree remove generated-todos