From 38a3a8829add2e13855879bb97c2ed43a4c6277e Mon Sep 17 00:00:00 2001 From: "sourcery-ai[bot]" <58596630+sourcery-ai[bot]@users.noreply.github.com> Date: Tue, 24 Dec 2024 23:48:05 +0000 Subject: [PATCH] CI: Add workflow to create Advent of Code puzzle issues (#10) CI: - Add a workflow to create issues for Advent of Code puzzles, including instructions for solution and test file placement, and a comment requesting automated analysis from Sourcery. Resolves #3 Co-authored-by: sourcery-ai[bot] --- .github/workflows/create-puzzle-issue.yml | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/create-puzzle-issue.yml diff --git a/.github/workflows/create-puzzle-issue.yml b/.github/workflows/create-puzzle-issue.yml new file mode 100644 index 0000000..434aca4 --- /dev/null +++ b/.github/workflows/create-puzzle-issue.yml @@ -0,0 +1,40 @@ +name: Create Puzzle Issue + +on: + workflow_call: + inputs: + year: + required: true + type: number + description: "The year of the puzzle" + day: + required: true + type: number + description: "The day of the puzzle" + part: + required: true + type: number + description: "The part of the puzzle (1 or 2)" + +permissions: + issues: write + +jobs: + create-issue: + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.USER_TOKEN }} + steps: + - name: Create puzzle issue + id: create-issue + run: | + ISSUE_URL=$(gh issue create \ + --title "Advent of code - ${{ inputs.year }} day ${{ inputs.day }} part ${{ inputs.part }}" \ + --body "Write solution in \`puzzles/year_${{ inputs.year }}/day_${{ inputs.day }}/solution.py\`, and write tests in \`puzzles/year_${{ inputs.year }}/day_${{ inputs.day }}/test_solution.py\` using relative imports") + echo "issue_url=${ISSUE_URL}" >> $GITHUB_OUTPUT + + - name: Add sourcery comment + run: | + gh issue comment "${ISSUE_URL}" --body "@sourcery-ai develop - you can read the puzzle statement with \`uv run advent_of_code.py read ${{ inputs.year }} ${{ inputs.day }} ${{ inputs.part }}\`. Run the solution on \`puzzles/year_${{ inputs.year }}/day_${{ inputs.day }}/input.txt\` and write answer to \`puzzles/year_${{ inputs.year }}/day_${{ inputs.day }}/answer_part${{ inputs.part }}.txt\`" + env: + ISSUE_URL: ${{ steps.create-issue.outputs.issue_url }}