From 28d9720a6f1c48cc5eae41556a60f03c6a0acd38 Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Tue, 8 Jul 2025 11:13:44 -0400 Subject: [PATCH 1/6] ci: :construction_worker: add workflow to test template creation --- .github/workflows/test.yml | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..627e519 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,52 @@ +name: Test template creation + +on: + push: + branches: + - main + pull_request: + +jobs: + test-copier: + runs-on: ubuntu-latest + env: + TEMPLATE_NAME: template-data-package + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + # Clone template to a subdirectory + path: ${{ env.TEMPLATE_NAME }} + + - name: Set up uv + uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba + with: + enable-cache: true + cache-dependency-glob: "**/uv.lock" + + - name: Generate a data package + # TODO: Add other pre/post setup steps here. + run: | + # List options with `--data` + uvx copier copy --vcs-ref=HEAD ${{ env.TEMPLATE_NAME }} test-data-package \ + --defaults \ + --data project_name="My Project" \ + --data project_description="." \ + --data project_url="https://github.com/user/repo" \ + --data author_name="John Smith" \ + --data author_email="john@example.com" + cd test-data-package + git config --global init.defaultBranch main + # Test that it gets added as Git repo. + git init + git checkout -b test + git add . + + - name: Lint and check + # TODO: Other checks? + run: | + cd test-data-package + uvx ruff check . + uvx mypy . + uvx typos + From cc856375774a94363558a8df21f665b76c70c352 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Jul 2025 15:16:06 +0000 Subject: [PATCH 2/6] chore(pre-commit): :pencil2: automatic fixes --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 627e519..25770d6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,4 +49,3 @@ jobs: uvx ruff check . uvx mypy . uvx typos - From ca01ccca60b607d0ad90f1d059356ba469870125 Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Tue, 8 Jul 2025 15:24:14 -0400 Subject: [PATCH 3/6] ci: :lock: least amount of permissions --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 627e519..c2775da 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,9 @@ on: - main pull_request: +# Least privilege permissions +permissions: read-all + jobs: test-copier: runs-on: ubuntu-latest From eafbb02f75e7aa4bbc9247a77a7fc47613b56e2a Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Fri, 11 Jul 2025 14:27:17 -0400 Subject: [PATCH 4/6] ci: :construction_worker: fixes to test workflow --- .github/workflows/test.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 91fcc0a..71ba045 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,6 +14,7 @@ jobs: runs-on: ubuntu-latest env: TEMPLATE_NAME: template-data-package + TEST_PACKAGE: test-data-package steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -28,27 +29,25 @@ jobs: cache-dependency-glob: "**/uv.lock" - name: Generate a data package - # TODO: Add other pre/post setup steps here. + # TODO: Switch to using the justfile recipe and have install justfile step run: | # List options with `--data` - uvx copier copy --vcs-ref=HEAD ${{ env.TEMPLATE_NAME }} test-data-package \ + uvx copier copy --vcs-ref=HEAD ${{ env.TEMPLATE_NAME }} ${{ env.TEST_PACKAGE }} \ --defaults \ --data project_name="My Project" \ --data project_description="." \ --data project_url="https://github.com/user/repo" \ --data author_name="John Smith" \ --data author_email="john@example.com" - cd test-data-package - git config --global init.defaultBranch main + cd ${{ env.TEST_PACKAGE }} # Test that it gets added as Git repo. git init - git checkout -b test git add . - name: Lint and check # TODO: Other checks? run: | - cd test-data-package + cd ${{ env.TEST_PACKAGE }} uvx ruff check . uvx mypy . uvx typos From c90d28a3a13dc1822be18a0744c8502372e1667c Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Tue, 15 Jul 2025 11:32:09 +0200 Subject: [PATCH 5/6] ci: :construction_worker: switch to using `just test` to standardise testing --- .github/workflows/test.yml | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 71ba045..e4fa9a7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,26 +28,8 @@ jobs: enable-cache: true cache-dependency-glob: "**/uv.lock" - - name: Generate a data package - # TODO: Switch to using the justfile recipe and have install justfile step - run: | - # List options with `--data` - uvx copier copy --vcs-ref=HEAD ${{ env.TEMPLATE_NAME }} ${{ env.TEST_PACKAGE }} \ - --defaults \ - --data project_name="My Project" \ - --data project_description="." \ - --data project_url="https://github.com/user/repo" \ - --data author_name="John Smith" \ - --data author_email="john@example.com" - cd ${{ env.TEST_PACKAGE }} - # Test that it gets added as Git repo. - git init - git add . + - name: Install justfile + run: sudo apt-get install -y just - - name: Lint and check - # TODO: Other checks? - run: | - cd ${{ env.TEST_PACKAGE }} - uvx ruff check . - uvx mypy . - uvx typos + - name: Test and check template creation + run: just test From e17bd472df0422529a6bde6f0cb36aafb1d0c5bf Mon Sep 17 00:00:00 2001 From: "Luke W. Johnston" Date: Tue, 15 Jul 2025 11:35:27 +0200 Subject: [PATCH 6/6] ci: :construction_worker: since standardising on justfile, don't need `env` for template dir --- .github/workflows/test.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e4fa9a7..64faeb9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,21 +12,14 @@ permissions: read-all jobs: test-copier: runs-on: ubuntu-latest - env: - TEMPLATE_NAME: template-data-package - TEST_PACKAGE: test-data-package steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - with: - # Clone template to a subdirectory - path: ${{ env.TEMPLATE_NAME }} - name: Set up uv uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba with: enable-cache: true - cache-dependency-glob: "**/uv.lock" - name: Install justfile run: sudo apt-get install -y just