From 799db11ceb5a91f0817913fe7e1ec45d19ab99d8 Mon Sep 17 00:00:00 2001 From: Mike Grimes Date: Mon, 24 Oct 2022 11:09:40 -0600 Subject: [PATCH] remove update-score from VerifyPR and move update to different script --- .github/workflows/VerifyPR.yml | 10 ---------- score.sh | 25 +------------------------ update-score.sh | 21 +++++++++++++++++++++ 3 files changed, 22 insertions(+), 34 deletions(-) create mode 100755 update-score.sh diff --git a/.github/workflows/VerifyPR.yml b/.github/workflows/VerifyPR.yml index 935ef0f7..c660f7d3 100644 --- a/.github/workflows/VerifyPR.yml +++ b/.github/workflows/VerifyPR.yml @@ -63,13 +63,3 @@ jobs: - name: Verify NON_EQUIVALENT run: make NON_EQUIVALENT=1 - - name: Update decomp score in README - run: ./score.sh --update-readme - - - name: Update PR - uses: test-room-7/action-update-file@v1 - with: - file-path: README.md - commit-msg: Update score in README - branch: ${{ env.GITHUB_REF_NAME }} - github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/score.sh b/score.sh index 4853b7c4..70c5f759 100755 --- a/score.sh +++ b/score.sh @@ -1,24 +1 @@ -if [[ $1 == '--update-readme' ]]; then - export NEW_SCORE=$(python3 ./tools/python/score.py) - echo "$NEW_SCORE" - python3 - <<'EOF' > README.md.tmp -import sys -import os -import re -from datetime import datetime - -BEGIN = '' -END = '' -DATE_STR = datetime.now().strftime('As of %B %-d, %Y, this is our current score:') -print( - re.sub( - fr'(?s).{BEGIN}.*{END}', - f'\n{BEGIN}\n{DATE_STR}\n```\n{os.environ["NEW_SCORE"]}\n```\n{END}', - open('README.md', 'r').read() - ) -) -EOF -sed '$ { /^$/ d}' README.md.tmp > README.md # removes extra newlines at end of file -else - python3 ./tools/python/score.py "$@" -fi +python3 ./tools/python/score.py "$@" diff --git a/update-score.sh b/update-score.sh new file mode 100755 index 00000000..2ed9b538 --- /dev/null +++ b/update-score.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +export NEW_SCORE=$(python3 ./tools/python/score.py) +python3 - <<'EOF' > README.md.tmp +import sys +import os +import re +from datetime import datetime + +BEGIN = '' +END = '' +DATE_STR = datetime.now().strftime('As of %B %-d, %Y, this is our current score:') +print( + re.sub( + fr'(?s).{BEGIN}.*{END}', + f'\n{BEGIN}\n{DATE_STR}\n```\n{os.environ["NEW_SCORE"]}\n```\n{END}', + open('README.md', 'r').read() + ), + end='' +) +EOF +mv README.md.tmp README.md