From 01c3e1e52a944c0a67093663ed6bf62974806c2f Mon Sep 17 00:00:00 2001 From: Kazuya Takei Date: Mon, 7 Oct 2024 02:44:10 +0900 Subject: [PATCH 1/7] feat: Use go-task for taskdef in project --- .../.github/workflows/main.yml | 4 +- .../.github/workflows/release.yml | 8 ++-- .../Taskfile.yaml | 30 +++++++++++++ .../docs/Taskfile.yaml | 44 +++++++++++++++++++ 4 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 {{cookiecutter.project_basename}}/Taskfile.yaml create mode 100644 {{cookiecutter.project_basename}}/docs/Taskfile.yaml diff --git a/{{cookiecutter.project_basename}}/.github/workflows/main.yml b/{{cookiecutter.project_basename}}/.github/workflows/main.yml index 1ffc828..bea155b 100644 --- a/{{cookiecutter.project_basename}}/.github/workflows/main.yml +++ b/{{cookiecutter.project_basename}}/.github/workflows/main.yml @@ -64,10 +64,10 @@ jobs: steps: - uses: actions/checkout@v4 - uses: astral-sh/setup-uv@v2 + - uses: arduino/setup-task@v2 - name: Run tests run: | - uv sync --frozen - uv run make -C docs linkcheck dirhtml + task setup docs:build-linkcheck docs:build-dirhtml build-test: runs-on: ubuntu-latest steps: diff --git a/{{cookiecutter.project_basename}}/.github/workflows/release.yml b/{{cookiecutter.project_basename}}/.github/workflows/release.yml index ab875b6..608ee7e 100644 --- a/{{cookiecutter.project_basename}}/.github/workflows/release.yml +++ b/{{cookiecutter.project_basename}}/.github/workflows/release.yml @@ -64,14 +64,14 @@ jobs: steps: - uses: actions/checkout@v4 - uses: astral-sh/setup-uv@v2 - - name: Run tests + - uses: arduino/setup-task@v2 + - name: Build document run: | - uv sync --frozen - uv run make -C docs dirhtml + task setup docs:build - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: - path: docs/_build/dirhtml + path: docs/_build/mini18n-dirhtml - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 diff --git a/{{cookiecutter.project_basename}}/Taskfile.yaml b/{{cookiecutter.project_basename}}/Taskfile.yaml new file mode 100644 index 0000000..ce82303 --- /dev/null +++ b/{{cookiecutter.project_basename}}/Taskfile.yaml @@ -0,0 +1,30 @@ +version: '3' + +vars: + # If you run bare environment or activated venv, set '' (blank string) + RUN_PYTHON: 'uv run' + +tasks: + setup: + desc: 'Setup workspace' + cmds: + - 'uv sync --frozen' + test: + desc: 'Test environment' + cmds: + - '{{.RUN_PYTHON}} pre-commit run --all-files' + - '{{.RUN_PYTHON}} pytest' + - task: 'docs:intl' + - task: 'docs:build-linkcheck' + - task: 'docs:build-mini18n-dirhtml' + - 'uv build' + release-*: + desc: 'Run elease process' + vars: + LEVEL: '{{index .MATCH 0}}' + cmds: + - 'age {{.LEVEL}}' + - 'uv sync' # To write out as lock-file + +includes: + docs: './docs' diff --git a/{{cookiecutter.project_basename}}/docs/Taskfile.yaml b/{{cookiecutter.project_basename}}/docs/Taskfile.yaml new file mode 100644 index 0000000..d193c56 --- /dev/null +++ b/{{cookiecutter.project_basename}}/docs/Taskfile.yaml @@ -0,0 +1,44 @@ +version: '3' + +vars: + # If you run bare environment or activated venv, set '' (blank string) + # RUN_PYTHON: '' + SPHINX_DEFAULT_BUILD: 'mini18n-dirhtml' + SPHINX_OPTIONS: '' + SPHINX_LANGUAGES: + - 'ja' + +env: + SPHINXINTL_TRANSLATOR: "Kazuya Takei " + +tasks: + intl: + desc: 'Sync i18n environment' + dir: '{{.TASKFILE_DIR}}' + cmds: + - '{{.RUN_PYTHON}} sphinx-build -M gettext . _build {{.SPHINX_OPTIONS}}' + - '{{.RUN_PYTHON}} sphinx-intl update --language={{.SPHINX_LANGUAGES | join ","}}' + dev: + desc: 'Run docs server' + dir: '{{.TASKFILE_DIR}}' + cmds: + - '{{.RUN_PYTHON}} sphinx-autobuild -b dirhtml . _build/dirhtml' + build-*: + desc: 'Make docs' + dir: '{{.TASKFILE_DIR}}' + vars: + TARGET: '{{index .MATCH 0}}' + cmds: + - '{{.RUN_PYTHON}} sphinx-build -M {{.TARGET}} . _build' + build: + desc: 'Make docs (default target)' + deps: + - 'build-{{.SPHINX_DEFAULT_BUILD}}' + help: + desc: 'Display help of docs' + deps: + - 'build-help' + clean: + desc: 'Clean build files of docs' + deps: + - 'build-clean' From c16fd47dc8683dd28319ee29c30e8dc7620de984 Mon Sep 17 00:00:00 2001 From: Kazuya Takei Date: Mon, 7 Oct 2024 02:51:07 +0900 Subject: [PATCH 2/7] fix: Copy taskfiles as raw-text --- cookiecutter.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cookiecutter.json b/cookiecutter.json index 1dfea4f..22e908f 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -8,5 +8,9 @@ "author_name": "Kazuya Takei", "author_email": "myself@attakei.net", "version": "0.0.0", - "requires_python": ["3.9", "3.10", "3.11", "3.12"] + "requires_python": ["3.9", "3.10", "3.11", "3.12"], + "_copy_without_render": [ + "Taskfile.yaml", + "**/Taskfile.yaml" + ] } From cef983c5e2d14c043325e661f0d3af19c717b598 Mon Sep 17 00:00:00 2001 From: Kazuya Takei Date: Mon, 7 Oct 2024 03:00:28 +0900 Subject: [PATCH 3/7] fix!: Remove makefile of docs (replaced taskfile) --- .../docs/Makefile | 28 --------------- .../docs/make.bat | 35 ------------------- 2 files changed, 63 deletions(-) delete mode 100644 {{cookiecutter.project_basename}}/docs/Makefile delete mode 100644 {{cookiecutter.project_basename}}/docs/make.bat diff --git a/{{cookiecutter.project_basename}}/docs/Makefile b/{{cookiecutter.project_basename}}/docs/Makefile deleted file mode 100644 index 9703516..0000000 --- a/{{cookiecutter.project_basename}}/docs/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line, and also -# from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile dev intl - -# Real-time build and local-server -dev: - sphinx-autobuild -b dirhtml $(SOURCEDIR) $(BUILDDIR)/dirhtml $(O) - -intl: - @$(SPHINXBUILD) -M gettext "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - sphinx-intl update --language=ja - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/{{cookiecutter.project_basename}}/docs/make.bat b/{{cookiecutter.project_basename}}/docs/make.bat deleted file mode 100644 index 32bb245..0000000 --- a/{{cookiecutter.project_basename}}/docs/make.bat +++ /dev/null @@ -1,35 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=. -set BUILDDIR=_build - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.https://www.sphinx-doc.org/ - exit /b 1 -) - -if "%1" == "" goto help - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd From 6d797466c18e68d36cbf1515f44e7092a6f8166e Mon Sep 17 00:00:00 2001 From: Kazuya Takei Date: Mon, 7 Oct 2024 03:03:57 +0900 Subject: [PATCH 4/7] fix: Run go-task to verify generated project --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 188a159..4ef6a23 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: astral-sh/setup-uv@v2 + - uses: arduino/setup-task@v2 - name: Create demo project run: | uvx cookiecutter --no-input --output-dir=var . @@ -27,6 +28,4 @@ jobs: cd var/demo git init uv sync --python='${{ steps.setup-python.outputs.python-path }}' - uv run pytest - uv run make -C docs dirhtml - uvx pre-commit run --all-files + task fulltest From 130888f203e4cd36608986058a7ecbf2f057d293 Mon Sep 17 00:00:00 2001 From: Kazuya Takei Date: Mon, 7 Oct 2024 03:11:05 +0900 Subject: [PATCH 5/7] fix: Rename task for verify --- .github/workflows/main.yml | 2 +- {{cookiecutter.project_basename}}/Taskfile.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4ef6a23..7957554 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,4 +28,4 @@ jobs: cd var/demo git init uv sync --python='${{ steps.setup-python.outputs.python-path }}' - task fulltest + task verify diff --git a/{{cookiecutter.project_basename}}/Taskfile.yaml b/{{cookiecutter.project_basename}}/Taskfile.yaml index ce82303..beb844c 100644 --- a/{{cookiecutter.project_basename}}/Taskfile.yaml +++ b/{{cookiecutter.project_basename}}/Taskfile.yaml @@ -9,8 +9,8 @@ tasks: desc: 'Setup workspace' cmds: - 'uv sync --frozen' - test: - desc: 'Test environment' + verify: + desc: 'Verify environment by all procs' cmds: - '{{.RUN_PYTHON}} pre-commit run --all-files' - '{{.RUN_PYTHON}} pytest' From 362af59c2ad5f076611de1da85dd7e061226295b Mon Sep 17 00:00:00 2001 From: Kazuya Takei Date: Mon, 7 Oct 2024 03:13:22 +0900 Subject: [PATCH 6/7] fix: Run pre-commit from uvx --- {{cookiecutter.project_basename}}/Taskfile.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_basename}}/Taskfile.yaml b/{{cookiecutter.project_basename}}/Taskfile.yaml index beb844c..3f1d97e 100644 --- a/{{cookiecutter.project_basename}}/Taskfile.yaml +++ b/{{cookiecutter.project_basename}}/Taskfile.yaml @@ -12,7 +12,7 @@ tasks: verify: desc: 'Verify environment by all procs' cmds: - - '{{.RUN_PYTHON}} pre-commit run --all-files' + - 'uvx pre-commit run --all-files' - '{{.RUN_PYTHON}} pytest' - task: 'docs:intl' - task: 'docs:build-linkcheck' From e5e2f92f5808377d939d8a852ea95832911ee120 Mon Sep 17 00:00:00 2001 From: Kazuya Takei Date: Mon, 7 Oct 2024 03:15:24 +0900 Subject: [PATCH 7/7] fix: Change first doc builder --- {{cookiecutter.project_basename}}/Taskfile.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_basename}}/Taskfile.yaml b/{{cookiecutter.project_basename}}/Taskfile.yaml index 3f1d97e..0c230c9 100644 --- a/{{cookiecutter.project_basename}}/Taskfile.yaml +++ b/{{cookiecutter.project_basename}}/Taskfile.yaml @@ -16,7 +16,7 @@ tasks: - '{{.RUN_PYTHON}} pytest' - task: 'docs:intl' - task: 'docs:build-linkcheck' - - task: 'docs:build-mini18n-dirhtml' + - task: 'docs:build-dirhtml' - 'uv build' release-*: desc: 'Run elease process'