From d70305366e135a18ec63919584bb525ac41773d3 Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 20:54:34 -0300 Subject: [PATCH 01/17] feat: testing puzzle resolution integration with GitHub Actions. --- puzzles/2015/day 1/.keep | 0 puzzles/2015/day 1/resolution.py | 5 +++++ 2 files changed, 5 insertions(+) delete mode 100644 puzzles/2015/day 1/.keep create mode 100644 puzzles/2015/day 1/resolution.py diff --git a/puzzles/2015/day 1/.keep b/puzzles/2015/day 1/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/puzzles/2015/day 1/resolution.py b/puzzles/2015/day 1/resolution.py new file mode 100644 index 0000000..2b661cb --- /dev/null +++ b/puzzles/2015/day 1/resolution.py @@ -0,0 +1,5 @@ +def main(): + print("Hello world") + +if __name__ == "__main__": + main() From 9214d6ea3bf68d8f0f351992a06aabc7c4d130c4 Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 20:56:19 -0300 Subject: [PATCH 02/17] feat: testing 2 --- puzzles/2015/day 1/resolution.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/puzzles/2015/day 1/resolution.py b/puzzles/2015/day 1/resolution.py index 2b661cb..53fb5a4 100644 --- a/puzzles/2015/day 1/resolution.py +++ b/puzzles/2015/day 1/resolution.py @@ -1,5 +1,2 @@ def main(): print("Hello world") - -if __name__ == "__main__": - main() From e8036a1519145ab0c794315c3fb60b24a7fa5462 Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 20:58:40 -0300 Subject: [PATCH 03/17] feat: testing 3 --- puzzles/2015/day 1/resolution.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/puzzles/2015/day 1/resolution.py b/puzzles/2015/day 1/resolution.py index 53fb5a4..5062962 100644 --- a/puzzles/2015/day 1/resolution.py +++ b/puzzles/2015/day 1/resolution.py @@ -1,2 +1,2 @@ def main(): - print("Hello world") + print("Hello world!") From ab00c5c897106cf0e78fb0cdaffc9864b0c54b0d Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:02:49 -0300 Subject: [PATCH 04/17] fix: fixing workflow to add main branch as the default branch. --- .github/workflows/auto-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index a01e667..bfcbff8 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -31,6 +31,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} - name: create pull request - run: gh pr create -B ${{ GITHUB_DEFAULT_BRANCH }} -H ${{ github.ref_name }} --title 'Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}' + run: gh pr create -B main -H ${{ github.ref_name }} --title 'Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}' env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} From b926835fb150e490ffd0c0a2c58c871ed68392af Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:04:07 -0300 Subject: [PATCH 05/17] fix: adding logs to the workflow. --- .github/workflows/auto-pr.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index bfcbff8..768acba 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -15,7 +15,8 @@ jobs: if [[ ${{ github.ref_name }} =~ puzzle/([0-9]{4})-day-([1-9]|1[0-9]|2[0-5]) ]]; then year=${BASH_REMATCH[1]} day=${BASH_REMATCH[2]} - + echo $year + echo $day issue_number=$(gh issue list -S '[$year] [Day $day] in:title' --json number | jq '.[].number') if [ -z "$issue_number" ]; then From 806be9c251a4de69c45f6a1e209efaec848e0186 Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:05:16 -0300 Subject: [PATCH 06/17] fix: adding checkout repository step. --- .github/workflows/auto-pr.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index 768acba..e4d0ef0 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -9,6 +9,9 @@ jobs: open-pull-request: runs-on: ubuntu-latest steps: + - name: checkout + uses: actions/checkout@v4 + - name: get issue number id: get_issue_number run: | From 968d45d95907d914ebfa9d5e1184eaad3f9ea8e1 Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:07:42 -0300 Subject: [PATCH 07/17] fix: adding logs --- .github/workflows/auto-pr.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index e4d0ef0..aceb205 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -18,10 +18,9 @@ jobs: if [[ ${{ github.ref_name }} =~ puzzle/([0-9]{4})-day-([1-9]|1[0-9]|2[0-5]) ]]; then year=${BASH_REMATCH[1]} day=${BASH_REMATCH[2]} - echo $year - echo $day - issue_number=$(gh issue list -S '[$year] [Day $day] in:title' --json number | jq '.[].number') + issue_number=$(gh issue list -S '[$year] [Day $day] in:title' --json number | jq '.[].number') + echo $issue_number if [ -z "$issue_number" ]; then echo "::error::Issue not found!" exit 1 From 5d7d942902134a051124ac87a9f7e75ea37ca751 Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:11:39 -0300 Subject: [PATCH 08/17] fix: adding double quotes so the variables are readable. --- .github/workflows/auto-pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index aceb205..5836306 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -19,8 +19,8 @@ jobs: year=${BASH_REMATCH[1]} day=${BASH_REMATCH[2]} - issue_number=$(gh issue list -S '[$year] [Day $day] in:title' --json number | jq '.[].number') - echo $issue_number + issue_number=$(gh issue list -S "[$year] [Day $day] in:title" --json number | jq '.[].number') + if [ -z "$issue_number" ]; then echo "::error::Issue not found!" exit 1 From b1a85cf8b0c0c894fadae56f85f1a19977a4c129 Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:13:11 -0300 Subject: [PATCH 09/17] fix: adding double quotes. --- .github/workflows/auto-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index 5836306..15ad3c8 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -34,6 +34,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} - name: create pull request - run: gh pr create -B main -H ${{ github.ref_name }} --title 'Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}' + run: gh pr create -B main -H ${{ github.ref_name }} --title "Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}"" env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} From b39131062f94c2be73ebd5d932254380a6285945 Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:14:33 -0300 Subject: [PATCH 10/17] fix: escaping "#". --- .github/workflows/auto-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index 15ad3c8..b6fa1e5 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -34,6 +34,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} - name: create pull request - run: gh pr create -B main -H ${{ github.ref_name }} --title "Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}"" + run: gh pr create -B main -H ${{ github.ref_name }} --title "Pull request to resolve \#${{ steps.get_issue_number.outputs.issue_number }}" env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} From dbe3196434db74875100edd0da644474b675c09a Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:16:31 -0300 Subject: [PATCH 11/17] fix: adding empty body to pull request. --- .github/workflows/auto-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index b6fa1e5..cea3f6c 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -34,6 +34,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} - name: create pull request - run: gh pr create -B main -H ${{ github.ref_name }} --title "Pull request to resolve \#${{ steps.get_issue_number.outputs.issue_number }}" + run: gh pr create -B main -H ${{ github.ref_name }} --t "Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}" -b "" env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} From 6872df85887b71718add2c48cf0665763a8510cb Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:16:57 -0300 Subject: [PATCH 12/17] fix: fixing parameter for pull request title. --- .github/workflows/auto-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index cea3f6c..278edad 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -34,6 +34,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} - name: create pull request - run: gh pr create -B main -H ${{ github.ref_name }} --t "Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}" -b "" + run: gh pr create -B main -H ${{ github.ref_name }} -t "Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}" -b "" env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} From f83808a78369540d911c543df0b4549ebf537304 Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:24:14 -0300 Subject: [PATCH 13/17] fix: fixing error on the use of "#", it was being interpreted as an YAML comment. --- .github/workflows/auto-pr.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index 278edad..e9a4bd5 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -34,6 +34,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} - name: create pull request - run: gh pr create -B main -H ${{ github.ref_name }} -t "Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}" -b "" + run: | + gh pr create -B main -H ${{ github.ref_name }} -t "Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}" env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} From 772d08390fb33ce0030dc828bae55aef0326e1ca Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:25:20 -0300 Subject: [PATCH 14/17] fix: adding empty body to pull request. --- .github/workflows/auto-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index e9a4bd5..6625814 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -35,6 +35,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} - name: create pull request run: | - gh pr create -B main -H ${{ github.ref_name }} -t "Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}" + gh pr create -B main -H ${{ github.ref_name }} -t "Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}" -b "" env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} From 032b519ea38c9664e3fed071d87ec6d018b56a4c Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:29:03 -0300 Subject: [PATCH 15/17] fix: testing --- .github/workflows/check-resolution.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-resolution.yml b/.github/workflows/check-resolution.yml index 91f03b3..b8f750a 100644 --- a/.github/workflows/check-resolution.yml +++ b/.github/workflows/check-resolution.yml @@ -8,7 +8,7 @@ on: - opened jobs: - get-answer: + submit-answer: runs-on: ubuntu-latest steps: - name: Checkout @@ -22,7 +22,7 @@ jobs: - name: Extract year and day from branch name id: extract run: | - branch_name=$(echo "${{ github.event.pull_request.head.ref }}") + branch_name=$(echo ${{ github.event.pull_request.head.ref }}) if [[ $branch_name =~ puzzle/([0-9]{4})-day-([1-9]|1[0-9]|2[0-5]) ]]; then year="${BASH_REMATCH[1]}" From c911905803a4cff1a2fd82f8be9fdbf9407b0360 Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:35:34 -0300 Subject: [PATCH 16/17] fix: fixing syntax error --- .github/workflows/auto-pr.yml | 6 +++--- .github/workflows/check-resolution.yml | 6 ++++-- .github/workflows/update-issue.yml | 5 +++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml index 6625814..2d2d68f 100644 --- a/.github/workflows/auto-pr.yml +++ b/.github/workflows/auto-pr.yml @@ -9,10 +9,10 @@ jobs: open-pull-request: runs-on: ubuntu-latest steps: - - name: checkout + - name: Checkout uses: actions/checkout@v4 - - name: get issue number + - name: Get issue number id: get_issue_number run: | if [[ ${{ github.ref_name }} =~ puzzle/([0-9]{4})-day-([1-9]|1[0-9]|2[0-5]) ]]; then @@ -33,7 +33,7 @@ jobs: fi env: GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }} - - name: create pull request + - name: Create pull request run: | gh pr create -B main -H ${{ github.ref_name }} -t "Pull request to resolve #${{ steps.get_issue_number.outputs.issue_number }}" -b "" env: diff --git a/.github/workflows/check-resolution.yml b/.github/workflows/check-resolution.yml index b8f750a..480bf07 100644 --- a/.github/workflows/check-resolution.yml +++ b/.github/workflows/check-resolution.yml @@ -8,7 +8,7 @@ on: - opened jobs: - submit-answer: + get-answer: runs-on: ubuntu-latest steps: - name: Checkout @@ -22,7 +22,7 @@ jobs: - name: Extract year and day from branch name id: extract run: | - branch_name=$(echo ${{ github.event.pull_request.head.ref }}) + branch_name=$(echo "${{ github.event.pull_request.head.ref }}") if [[ $branch_name =~ puzzle/([0-9]{4})-day-([1-9]|1[0-9]|2[0-5]) ]]; then year="${BASH_REMATCH[1]}" @@ -33,6 +33,7 @@ jobs: else echo "Branch name does not follow the expected pattern." exit 1 + fi - name: Get answer id: get_answer @@ -50,6 +51,7 @@ jobs: else echo "Script not found: $script_path" exit 1 + fi - name: Submit answer id: submit_answer diff --git a/.github/workflows/update-issue.yml b/.github/workflows/update-issue.yml index cf7d0ec..4b050bc 100644 --- a/.github/workflows/update-issue.yml +++ b/.github/workflows/update-issue.yml @@ -12,20 +12,24 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Parsing issue id: issue-parser uses: stefanbuck/github-issue-parser@v3 with: template-path: .github/ISSUE_TEMPLATE/puzzle.yml + - name: Adding milestone to issue uses: Julexar/Milestone-Assigner@v1.0 with: token: "${{ secrets.ACTION_TOKEN }}" milestone: "${{ steps.issue-parser.outputs.issueparser_puzzle-year }} Puzzles" + - name: Run bash script to extract day from issue title id: extract run: | title="${{ github.event.issue.title }}" + if [[ $title =~ Day\ ([0-9]+) ]]; then day=${BASH_REMATCH[1]} echo "day=${day}" >> $GITHUB_OUTPUT @@ -33,6 +37,7 @@ jobs: echo "::error::Title does not match the expected pattern" exit 1 fi + - name: Create comment uses: peter-evans/create-or-update-comment@v4 with: From 4077bb03a168c2b4418e2efe1bfa1f3b09a24e98 Mon Sep 17 00:00:00 2001 From: victoraugustofd Date: Sat, 4 Jan 2025 21:38:12 -0300 Subject: [PATCH 17/17] fix: escaping blank space on script path. --- .github/workflows/check-resolution.yml | 2 +- puzzles/2015/{day 1 => day-1}/resolution.py | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename puzzles/2015/{day 1 => day-1}/resolution.py (100%) diff --git a/.github/workflows/check-resolution.yml b/.github/workflows/check-resolution.yml index 480bf07..3f4d8a6 100644 --- a/.github/workflows/check-resolution.yml +++ b/.github/workflows/check-resolution.yml @@ -41,7 +41,7 @@ jobs: year="${{ steps.extract.outputs.year }}" day="${{ steps.extract.outputs.day }}" - script_path="puzzles/$year/day $day/resolution.py" + script_path="puzzles/$year/day-$day/resolution.py" if [ -f "$script_path" ]; then echo "Running script: $script_path" diff --git a/puzzles/2015/day 1/resolution.py b/puzzles/2015/day-1/resolution.py similarity index 100% rename from puzzles/2015/day 1/resolution.py rename to puzzles/2015/day-1/resolution.py