From 98b13e94df8687044e1e044e7d4835027793183b Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sat, 27 Apr 2024 07:34:25 +0800 Subject: [PATCH 01/16] ci: cache package installation in github actions --- Makefile | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index c2342922..a7983da0 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,6 @@ # Variables ######################################################################################## -# Global option for pdm, when in CI or readthedocs environment, no need to use venv. -PDM_GLOBAL := $(shell [ "$$CI" = "true" ] || [ "$$READTHEDOCS" = "True" ] && echo "--global --project .") - # Documentation target directory, will be adapted to specific folder for readthedocs. PUBLIC_DIR := $(shell [ "$$READTHEDOCS" = "True" ] && echo "$$READTHEDOCS_OUTPUT/html" || echo "public") @@ -47,16 +44,16 @@ deepclean: clean # Install the package in editable mode. install: - pdm install $(PDM_GLOBAL) --prod + pdm install --prod # Install the package in editable mode with specific optional dependencies. dev-%: - pdm install $(PDM_GLOBAL) --dev --group $* + pdm install --dev --group $* # Prepare the development environment. # Install the pacakge in editable mode with all optional dependencies and pre-commit hoook. dev: - pdm install $(PDM_GLOBAL) + pdm install if [ "$(CI)" != "true" ] && command -v pre-commit > /dev/null 2>&1; then pre-commit install; fi ######################################################################################## @@ -65,19 +62,19 @@ dev: # Check lint with mypy. mypy: - pdm run $(PDM_GLOBAL) python -m mypy . + pdm run python -m mypy . # Lint with ruff. ruff: - pdm run $(PDM_GLOBAL) python -m ruff check . + pdm run python -m ruff check . # Format with ruff. ruff-format: - pdm run $(PDM_GLOBAL) python -m ruff format --check . + pdm run python -m ruff format --check . # Check lint with toml-sort. toml-sort: - pdm run $(PDM_GLOBAL) toml-sort --check pyproject.toml + pdm run toml-sort --check pyproject.toml # Check lint with all linters. lint: mypy ruff ruff-format toml-sort @@ -92,13 +89,13 @@ pre-commit: # Clean and run test with coverage. test-run: - pdm run $(PDM_GLOBAL) python -m coverage erase - pdm run $(PDM_GLOBAL) python -m coverage run -m pytest + pdm run python -m coverage erase + pdm run python -m coverage run -m pytest # Generate coverage report for terminal and xml. test: test-run - pdm run $(PDM_GLOBAL) python -m coverage report - pdm run $(PDM_GLOBAL) python -m coverage xml + pdm run python -m coverage report + pdm run python -m coverage xml ######################################################################################## # Package @@ -118,7 +115,7 @@ publish: # Generate documentation with auto build when changes happen. doc-autobuild: - pdm run $(PDM_GLOBAL) python -m sphinx_autobuild docs $(PUBLIC_DIR) \ + pdm run python -m sphinx_autobuild docs $(PUBLIC_DIR) \ --watch README.md \ --watch src @@ -129,24 +126,24 @@ changelog: echo "Existing Changelog found at '$(CHANGELOG_URL)', download for incremental generation."; \ wget -q -O $(CHANGELOG_PATH) $(CHANGELOG_URL); \ fi - pdm run $(PDM_GLOBAL) git-changelog -ETrio $(CHANGELOG_PATH) -c conventional -s build,chore,ci,doc,feat,fix,perf,refactor,revert,style,test + pdm run git-changelog -ETrio $(CHANGELOG_PATH) -c conventional -s build,chore,ci,doc,feat,fix,perf,refactor,revert,style,test # Generate release notes from changelog. release-notes: - @pdm run $(PDM_GLOBAL) git-changelog --input $(CHANGELOG_PATH) --release-notes + @pdm run git-changelog --input $(CHANGELOG_PATH) --release-notes # Build documentation only from src. doc-gen: - pdm run $(PDM_GLOBAL) python -m sphinx.cmd.build docs $(PUBLIC_DIR) + pdm run python -m sphinx.cmd.build docs $(PUBLIC_DIR) # Generate mypy reports. doc-mypy: doc-gen - pdm run $(PDM_GLOBAL) python -m mypy src tests --html-report $(PUBLIC_DIR)/reports/mypy + pdm run python -m mypy src tests --html-report $(PUBLIC_DIR)/reports/mypy # Generate html coverage reports with badge. doc-coverage: test-run doc-gen - pdm run $(PDM_GLOBAL) python -m coverage html -d $(PUBLIC_DIR)/reports/coverage - pdm run $(PDM_GLOBAL) bash scripts/generate-coverage-badge.sh $(PUBLIC_DIR)/_static/badges + pdm run python -m coverage html -d $(PUBLIC_DIR)/reports/coverage + pdm run bash scripts/generate-coverage-badge.sh $(PUBLIC_DIR)/_static/badges # Generate all documentation with reports. doc: changelog doc-gen doc-mypy doc-coverage From d9162b8407e51af4f50068842b5cffa6b3dddaac Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 11:06:41 +0800 Subject: [PATCH 02/16] spcify pdm backend version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8b883017..cc4bcddd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [build-system] build-backend = "pdm.backend" requires = [ - "pdm-backend", + "pdm-backend==2.2.1", ] [project] From ab35ad56d168c29ac61a54f38a2f0552de986ca7 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 11:08:50 +0800 Subject: [PATCH 03/16] Remove unnecessary no editable installation due to pdm backend change --- .github/workflows/release.yml | 2 -- .gitlab/workflows/release.yml | 2 +- .readthedocs.yaml | 2 +- template/.readthedocs.yaml | 2 +- .../workflows/release.yml.jinja | 2 -- .../workflows/release.yml.jinja | 2 +- 6 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e1909bda..31f9f20a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,8 +16,6 @@ jobs: uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 - run: env | sort - run: make dev-doc - env: - PDM_NO_EDITABLE: true - run: make doc env: CI_PAGES_URL: ${{ steps.pages.outputs.base_url }} diff --git a/.gitlab/workflows/release.yml b/.gitlab/workflows/release.yml index fda5ebd1..4724ece3 100644 --- a/.gitlab/workflows/release.yml +++ b/.gitlab/workflows/release.yml @@ -7,7 +7,7 @@ pages-build: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: - - PDM_NO_EDITABLE=true make dev-doc + - make dev-doc - make doc - make release-notes > release-notes.md stage: release diff --git a/.readthedocs.yaml b/.readthedocs.yaml index cfff1a44..3304d8fa 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -23,7 +23,7 @@ build: fi post_install: - python -m pip install --upgrade --no-cache-dir pdm==2.15.0 - - PDM_NO_EDITABLE=true make dev-doc + - make dev-doc pre_build: - CI_PAGES_URL=https://${READTHEDOCS_PROJECT}.readthedocs.io/${READTHEDOCS_LANGUAGE}/stable make changelog os: ubuntu-22.04 diff --git a/template/.readthedocs.yaml b/template/.readthedocs.yaml index cfff1a44..3304d8fa 100644 --- a/template/.readthedocs.yaml +++ b/template/.readthedocs.yaml @@ -23,7 +23,7 @@ build: fi post_install: - python -m pip install --upgrade --no-cache-dir pdm==2.15.0 - - PDM_NO_EDITABLE=true make dev-doc + - make dev-doc pre_build: - CI_PAGES_URL=https://${READTHEDOCS_PROJECT}.readthedocs.io/${READTHEDOCS_LANGUAGE}/stable make changelog os: ubuntu-22.04 diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja index f356ad25..8b5b3bd5 100644 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja @@ -17,8 +17,6 @@ jobs: uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 - run: env | sort - run: make dev-doc - env: - PDM_NO_EDITABLE: true - run: make doc env: CI_PAGES_URL: {{ '${{ steps.pages.outputs.base_url }}' }} diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja index b4ccab16..e425afc3 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja @@ -8,7 +8,7 @@ pages-build: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: - - PDM_NO_EDITABLE=true make dev-doc + - make dev-doc - make doc - make release-notes > release-notes.md stage: release From 2d5f47fe2cc3410afe9ca8647de40f810ef99e21 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 11:19:26 +0800 Subject: [PATCH 04/16] install pdm with asdf in readthedocs --- .readthedocs.yaml | 5 ++++- template/.readthedocs.yaml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 3304d8fa..82339c94 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -21,8 +21,11 @@ build: then exit 183; fi + pre_create_environment: + - asdf plugin add pdm + - asdf install pdm 2.15.0 + - asdf global pdm 2.15.0 post_install: - - python -m pip install --upgrade --no-cache-dir pdm==2.15.0 - make dev-doc pre_build: - CI_PAGES_URL=https://${READTHEDOCS_PROJECT}.readthedocs.io/${READTHEDOCS_LANGUAGE}/stable make changelog diff --git a/template/.readthedocs.yaml b/template/.readthedocs.yaml index 3304d8fa..82339c94 100644 --- a/template/.readthedocs.yaml +++ b/template/.readthedocs.yaml @@ -21,8 +21,11 @@ build: then exit 183; fi + pre_create_environment: + - asdf plugin add pdm + - asdf install pdm 2.15.0 + - asdf global pdm 2.15.0 post_install: - - python -m pip install --upgrade --no-cache-dir pdm==2.15.0 - make dev-doc pre_build: - CI_PAGES_URL=https://${READTHEDOCS_PROJECT}.readthedocs.io/${READTHEDOCS_LANGUAGE}/stable make changelog From 8020e29c1051d8dd926bd03de9d93843458a6279 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 13:58:12 +0800 Subject: [PATCH 05/16] update asdf installed pdm with renovate --- .renovaterc.json | 6 ++++-- template/.renovaterc.json.jinja | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.renovaterc.json b/.renovaterc.json index 7102896c..7d371cbc 100644 --- a/.renovaterc.json +++ b/.renovaterc.json @@ -21,8 +21,10 @@ "^template/docs/.+\\.md(\\.jinja)?$" ], "matchStrings": [ - "pipx install (?.*?)==(?.*?)[;\n]", - "pip install.* (?.*?)==(?.*?)[\"\n]" + "asdf global (?.*?) (?.*?)\n", + "asdf install (?.*?) (?.*?)\n", + "pip install.* (?.*?)==(?.*?)[\"\n]", + "pipx install (?.*?)==(?.*?)[;\n]" ] }, { diff --git a/template/.renovaterc.json.jinja b/template/.renovaterc.json.jinja index bb857081..291f9e55 100644 --- a/template/.renovaterc.json.jinja +++ b/template/.renovaterc.json.jinja @@ -24,8 +24,10 @@ [%- endif %] ], "matchStrings": [ - "pipx install (?.*?)==(?.*?)[;\n]", - "pip install.* (?.*?)==(?.*?)[\"\n]" + "asdf global (?.*?) (?.*?)\n", + "asdf install (?.*?) (?.*?)\n", + "pip install.* (?.*?)==(?.*?)[\"\n]", + "pipx install (?.*?)==(?.*?)[;\n]" ] }, { From 828cc1906fd18d4cf988edf95d532d5f787938ff Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 14:11:04 +0800 Subject: [PATCH 06/16] update template for renovate --- .renovaterc.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.renovaterc.json b/.renovaterc.json index 7d371cbc..c0b784e0 100644 --- a/.renovaterc.json +++ b/.renovaterc.json @@ -121,6 +121,17 @@ ] } }, + { + "matchManagers": [ + "pypi" + ], + "postUpgradeTasks": { + "commands": [ + "find template -type f -exec sed -i 's|{{{depName}}} {{{currentValue}}}|{{{depName}}} {{{newValue}}}|g' {} +", + "find template -type f -exec sed -i 's|{{{depName}}}=={{{currentValue}}}|{{{depName}}}=={{{newValue}}}|g' {} +" + ] + } + }, { "matchDepTypes": [ "container", From 759c15e47943e3af7a87780836f39a7c56591879 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 14:11:47 +0800 Subject: [PATCH 07/16] update template --- template/.renovaterc.json.jinja | 11 ++++++++++ template/Makefile.jinja | 39 +++++++++++++++------------------ template/pyproject.toml.jinja | 2 +- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/template/.renovaterc.json.jinja b/template/.renovaterc.json.jinja index 291f9e55..db43fe10 100644 --- a/template/.renovaterc.json.jinja +++ b/template/.renovaterc.json.jinja @@ -131,6 +131,17 @@ ] } }, + { + "matchManagers": [ + "pypi" + ], + "postUpgradeTasks": { + "commands": [ + "find template -type f -exec sed -i {{ '\'s|{{{depName}}} {{{currentValue}}}|{{{depName}}} {{{newValue}}}|g\' {} +' }}", + "find template -type f -exec sed -i {{ '\'s|{{{depName}}}=={{{currentValue}}}|{{{depName}}}=={{{newValue}}}|g\' {} +' }}" + ] + } + }, { "matchDepTypes": [ "container", diff --git a/template/Makefile.jinja b/template/Makefile.jinja index cbe60e55..8da7a565 100644 --- a/template/Makefile.jinja +++ b/template/Makefile.jinja @@ -6,9 +6,6 @@ # Variables ######################################################################################## -# Global option for pdm, when in CI or readthedocs environment, no need to use venv. -PDM_GLOBAL := $(shell [ "$$CI" = "true" ] || [ "$$READTHEDOCS" = "True" ] && echo "--global --project .") - # Documentation target directory, will be adapted to specific folder for readthedocs. PUBLIC_DIR := $(shell [ "$$READTHEDOCS" = "True" ] && echo "$$READTHEDOCS_OUTPUT/html" || echo "public") @@ -49,16 +46,16 @@ deepclean: clean # Install the package in editable mode. install: - pdm install $(PDM_GLOBAL) --prod + pdm install --prod # Install the package in editable mode with specific optional dependencies. dev-%: - pdm install $(PDM_GLOBAL) --dev --group $* + pdm install --dev --group $* # Prepare the development environment. # Install the pacakge in editable mode with all optional dependencies and pre-commit hoook. dev: - pdm install $(PDM_GLOBAL) + pdm install if [ "$(CI)" != "true" ] && command -v pre-commit > /dev/null 2>&1; then pre-commit install; fi ######################################################################################## @@ -67,19 +64,19 @@ dev: # Check lint with mypy. mypy: - pdm run $(PDM_GLOBAL) python -m mypy . + pdm run python -m mypy . # Lint with ruff. ruff: - pdm run $(PDM_GLOBAL) python -m ruff check . + pdm run python -m ruff check . # Format with ruff. ruff-format: - pdm run $(PDM_GLOBAL) python -m ruff format --check . + pdm run python -m ruff format --check . # Check lint with toml-sort. toml-sort: - pdm run $(PDM_GLOBAL) toml-sort --check pyproject.toml + pdm run toml-sort --check pyproject.toml # Check lint with all linters. lint: mypy ruff ruff-format toml-sort @@ -94,13 +91,13 @@ pre-commit: # Clean and run test with coverage. test-run: - pdm run $(PDM_GLOBAL) python -m coverage erase - pdm run $(PDM_GLOBAL) python -m coverage run -m pytest + pdm run python -m coverage erase + pdm run python -m coverage run -m pytest # Generate coverage report for terminal and xml. test: test-run - pdm run $(PDM_GLOBAL) python -m coverage report - pdm run $(PDM_GLOBAL) python -m coverage xml + pdm run python -m coverage report + pdm run python -m coverage xml ######################################################################################## # Package @@ -120,7 +117,7 @@ publish: # Generate documentation with auto build when changes happen. doc-autobuild: - pdm run $(PDM_GLOBAL) python -m sphinx_autobuild docs $(PUBLIC_DIR) \ + pdm run python -m sphinx_autobuild docs $(PUBLIC_DIR) \ --watch README.md \ --watch src @@ -131,24 +128,24 @@ changelog: echo "Existing Changelog found at '$(CHANGELOG_URL)', download for incremental generation."; \ wget -q -O $(CHANGELOG_PATH) $(CHANGELOG_URL); \ fi - pdm run $(PDM_GLOBAL) git-changelog -ETrio $(CHANGELOG_PATH) -c conventional -s build,chore,ci,doc,feat,fix,perf,refactor,revert,style,test + pdm run git-changelog -ETrio $(CHANGELOG_PATH) -c conventional -s build,chore,ci,doc,feat,fix,perf,refactor,revert,style,test # Generate release notes from changelog. release-notes: - @pdm run $(PDM_GLOBAL) git-changelog --input $(CHANGELOG_PATH) --release-notes + @pdm run git-changelog --input $(CHANGELOG_PATH) --release-notes # Build documentation only from src. doc-gen: - pdm run $(PDM_GLOBAL) python -m sphinx.cmd.build docs $(PUBLIC_DIR) + pdm run python -m sphinx.cmd.build docs $(PUBLIC_DIR) # Generate mypy reports. doc-mypy: doc-gen - pdm run $(PDM_GLOBAL) python -m mypy src tests --html-report $(PUBLIC_DIR)/reports/mypy + pdm run python -m mypy src tests --html-report $(PUBLIC_DIR)/reports/mypy # Generate html coverage reports with badge. doc-coverage: test-run doc-gen - pdm run $(PDM_GLOBAL) python -m coverage html -d $(PUBLIC_DIR)/reports/coverage - pdm run $(PDM_GLOBAL) bash scripts/generate-coverage-badge.sh $(PUBLIC_DIR)/_static/badges + pdm run python -m coverage html -d $(PUBLIC_DIR)/reports/coverage + pdm run bash scripts/generate-coverage-badge.sh $(PUBLIC_DIR)/_static/badges # Generate all documentation with reports. doc: changelog doc-gen doc-mypy doc-coverage diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index 35faa555..bca84308 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -4,7 +4,7 @@ [build-system] build-backend = "pdm.backend" requires = [ - "pdm-backend", + "pdm-backend==2.2.1", ] [project] From 8fe87c4174b732b06436526442fb95e10155a608 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 14:14:30 +0800 Subject: [PATCH 08/16] fix config typo --- .renovaterc.json | 2 +- template/.renovaterc.json.jinja | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.renovaterc.json b/.renovaterc.json index c0b784e0..c22e9277 100644 --- a/.renovaterc.json +++ b/.renovaterc.json @@ -122,7 +122,7 @@ } }, { - "matchManagers": [ + "matchDatasources": [ "pypi" ], "postUpgradeTasks": { diff --git a/template/.renovaterc.json.jinja b/template/.renovaterc.json.jinja index db43fe10..a5656df2 100644 --- a/template/.renovaterc.json.jinja +++ b/template/.renovaterc.json.jinja @@ -132,7 +132,7 @@ } }, { - "matchManagers": [ + "matchDatasources": [ "pypi" ], "postUpgradeTasks": { From d5511a822d9e24c459beb024e41893e23585d40b Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 14:20:33 +0800 Subject: [PATCH 09/16] did the trick --- .readthedocs.yaml | 2 +- template/.readthedocs.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 82339c94..a5e0d9d9 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -26,7 +26,7 @@ build: - asdf install pdm 2.15.0 - asdf global pdm 2.15.0 post_install: - - make dev-doc + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make dev-doc pre_build: - CI_PAGES_URL=https://${READTHEDOCS_PROJECT}.readthedocs.io/${READTHEDOCS_LANGUAGE}/stable make changelog os: ubuntu-22.04 diff --git a/template/.readthedocs.yaml b/template/.readthedocs.yaml index 82339c94..a5e0d9d9 100644 --- a/template/.readthedocs.yaml +++ b/template/.readthedocs.yaml @@ -26,7 +26,7 @@ build: - asdf install pdm 2.15.0 - asdf global pdm 2.15.0 post_install: - - make dev-doc + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make dev-doc pre_build: - CI_PAGES_URL=https://${READTHEDOCS_PROJECT}.readthedocs.io/${READTHEDOCS_LANGUAGE}/stable make changelog os: ubuntu-22.04 From ec47e263478c6ee20915ec4d0651c5886b29c000 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 14:53:51 +0800 Subject: [PATCH 10/16] fix readthedocs build --- .readthedocs.yaml | 2 +- template/.readthedocs.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index a5e0d9d9..9b4c94c4 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -25,7 +25,7 @@ build: - asdf plugin add pdm - asdf install pdm 2.15.0 - asdf global pdm 2.15.0 - post_install: + pre_install: - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make dev-doc pre_build: - CI_PAGES_URL=https://${READTHEDOCS_PROJECT}.readthedocs.io/${READTHEDOCS_LANGUAGE}/stable make changelog diff --git a/template/.readthedocs.yaml b/template/.readthedocs.yaml index a5e0d9d9..9b4c94c4 100644 --- a/template/.readthedocs.yaml +++ b/template/.readthedocs.yaml @@ -25,7 +25,7 @@ build: - asdf plugin add pdm - asdf install pdm 2.15.0 - asdf global pdm 2.15.0 - post_install: + pre_install: - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make dev-doc pre_build: - CI_PAGES_URL=https://${READTHEDOCS_PROJECT}.readthedocs.io/${READTHEDOCS_LANGUAGE}/stable make changelog From d773e6b173bbc58d4ae4312cc5f70d5874f36952 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 15:11:33 +0800 Subject: [PATCH 11/16] test --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a7983da0..e0f774f5 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ ######################################################################################## # Documentation target directory, will be adapted to specific folder for readthedocs. -PUBLIC_DIR := $(shell [ "$$READTHEDOCS" = "True" ] && echo "$$READTHEDOCS_OUTPUT/html" || echo "public") +PUBLIC_DIR := $(shell [ "$$READTHEDOCS" = "True" ] && echo "$${READTHEDOCS_OUTPUT}html" || echo "public") # URL and Path of changelog source code. CHANGELOG_URL := $(shell echo $${CI_PAGES_URL:-https://serious-scaffold.github.io/ss-python}/_sources/changelog.md.txt) @@ -137,11 +137,11 @@ doc-gen: pdm run python -m sphinx.cmd.build docs $(PUBLIC_DIR) # Generate mypy reports. -doc-mypy: doc-gen +doc-mypy: pdm run python -m mypy src tests --html-report $(PUBLIC_DIR)/reports/mypy # Generate html coverage reports with badge. -doc-coverage: test-run doc-gen +doc-coverage: test-run pdm run python -m coverage html -d $(PUBLIC_DIR)/reports/coverage pdm run bash scripts/generate-coverage-badge.sh $(PUBLIC_DIR)/_static/badges From a4e67f2bb403f0cd106572915a15e777e21ea224 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 15:15:03 +0800 Subject: [PATCH 12/16] test again --- .readthedocs.yaml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 9b4c94c4..6e2ac468 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,8 +1,5 @@ build: jobs: - post_build: - - make doc-mypy - - make doc-coverage post_checkout: - env | sort - git fetch --unshallow || true @@ -22,16 +19,24 @@ build: exit 183; fi pre_create_environment: + - env | sort - asdf plugin add pdm - asdf install pdm 2.15.0 - asdf global pdm 2.15.0 - pre_install: - - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make dev-doc + post_install: + - export VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH + - env | sort + - make dev-doc pre_build: + - env | sort - CI_PAGES_URL=https://${READTHEDOCS_PROJECT}.readthedocs.io/${READTHEDOCS_LANGUAGE}/stable make changelog + post_build: + - env | sort + - make doc-mypy + - make doc-coverage os: ubuntu-22.04 tools: - python: '3' + python: "3" sphinx: fail_on_warning: true version: 2 From 45f95a93fe4343ed5fcef1c640a884ba7e8e41fa Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 15:39:19 +0800 Subject: [PATCH 13/16] test test --- .readthedocs.yaml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 6e2ac468..4bca31da 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,7 +1,6 @@ build: jobs: post_checkout: - - env | sort - git fetch --unshallow || true # Cancel building pull requests when there aren't changed in the related files and folders. # If there are no changes (git diff exits with 0) we force the command to return with 183. @@ -18,22 +17,18 @@ build: then exit 183; fi - pre_create_environment: + post_system_dependencies: - env | sort + pre_create_environment: - asdf plugin add pdm - asdf install pdm 2.15.0 - asdf global pdm 2.15.0 post_install: - - export VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH - - env | sort - - make dev-doc + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make dev-doc pre_build: - - env | sort - - CI_PAGES_URL=https://${READTHEDOCS_PROJECT}.readthedocs.io/${READTHEDOCS_LANGUAGE}/stable make changelog + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH CI_PAGES_URL=https://${READTHEDOCS_PROJECT}.readthedocs.io/${READTHEDOCS_LANGUAGE}/stable make changelog post_build: - - env | sort - - make doc-mypy - - make doc-coverage + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make doc-mypy doc-coverage os: ubuntu-22.04 tools: python: "3" From 6f8003b8ffbf2e90e913ea245998ed12b315b5dc Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 16:00:38 +0800 Subject: [PATCH 14/16] update template --- template/.readthedocs.yaml | 14 +++++++------- template/Makefile.jinja | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/template/.readthedocs.yaml b/template/.readthedocs.yaml index 9b4c94c4..4bca31da 100644 --- a/template/.readthedocs.yaml +++ b/template/.readthedocs.yaml @@ -1,10 +1,6 @@ build: jobs: - post_build: - - make doc-mypy - - make doc-coverage post_checkout: - - env | sort - git fetch --unshallow || true # Cancel building pull requests when there aren't changed in the related files and folders. # If there are no changes (git diff exits with 0) we force the command to return with 183. @@ -21,17 +17,21 @@ build: then exit 183; fi + post_system_dependencies: + - env | sort pre_create_environment: - asdf plugin add pdm - asdf install pdm 2.15.0 - asdf global pdm 2.15.0 - pre_install: + post_install: - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make dev-doc pre_build: - - CI_PAGES_URL=https://${READTHEDOCS_PROJECT}.readthedocs.io/${READTHEDOCS_LANGUAGE}/stable make changelog + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH CI_PAGES_URL=https://${READTHEDOCS_PROJECT}.readthedocs.io/${READTHEDOCS_LANGUAGE}/stable make changelog + post_build: + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make doc-mypy doc-coverage os: ubuntu-22.04 tools: - python: '3' + python: "3" sphinx: fail_on_warning: true version: 2 diff --git a/template/Makefile.jinja b/template/Makefile.jinja index 8da7a565..6cc4ac70 100644 --- a/template/Makefile.jinja +++ b/template/Makefile.jinja @@ -7,7 +7,7 @@ ######################################################################################## # Documentation target directory, will be adapted to specific folder for readthedocs. -PUBLIC_DIR := $(shell [ "$$READTHEDOCS" = "True" ] && echo "$$READTHEDOCS_OUTPUT/html" || echo "public") +PUBLIC_DIR := $(shell [ "$$READTHEDOCS" = "True" ] && echo "$${READTHEDOCS_OUTPUT}html" || echo "public") # URL and Path of changelog source code. CHANGELOG_URL := $(shell echo $${CI_PAGES_URL:-https://{{ page_url() }}}/_sources/changelog.md.txt) @@ -139,11 +139,11 @@ doc-gen: pdm run python -m sphinx.cmd.build docs $(PUBLIC_DIR) # Generate mypy reports. -doc-mypy: doc-gen +doc-mypy: pdm run python -m mypy src tests --html-report $(PUBLIC_DIR)/reports/mypy # Generate html coverage reports with badge. -doc-coverage: test-run doc-gen +doc-coverage: test-run pdm run python -m coverage html -d $(PUBLIC_DIR)/reports/coverage pdm run bash scripts/generate-coverage-badge.sh $(PUBLIC_DIR)/_static/badges From a0f27bf618ebdccfabb0cb77225044e3696c5270 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 16:29:21 +0800 Subject: [PATCH 15/16] set python dynamically --- .readthedocs.yaml | 2 +- template/{.readthedocs.yaml => .readthedocs.yaml.jinja} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename template/{.readthedocs.yaml => .readthedocs.yaml.jinja} (97%) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 4bca31da..d612a152 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -31,7 +31,7 @@ build: - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make doc-mypy doc-coverage os: ubuntu-22.04 tools: - python: "3" + python: "3.12" sphinx: fail_on_warning: true version: 2 diff --git a/template/.readthedocs.yaml b/template/.readthedocs.yaml.jinja similarity index 97% rename from template/.readthedocs.yaml rename to template/.readthedocs.yaml.jinja index 4bca31da..49370ec6 100644 --- a/template/.readthedocs.yaml +++ b/template/.readthedocs.yaml.jinja @@ -31,7 +31,7 @@ build: - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH make doc-mypy doc-coverage os: ubuntu-22.04 tools: - python: "3" + python: "{{ default_py }}" sphinx: fail_on_warning: true version: 2 From 4ae672c4cf5f9733c36d88c91776ffb8560e0ba3 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Sun, 28 Apr 2024 18:17:10 +0800 Subject: [PATCH 16/16] minor --- .renovaterc.json | 20 ++++++++++---------- template/.renovaterc.json.jinja | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.renovaterc.json b/.renovaterc.json index c22e9277..6a62e6f7 100644 --- a/.renovaterc.json +++ b/.renovaterc.json @@ -122,26 +122,26 @@ } }, { - "matchDatasources": [ - "pypi" + "matchDepTypes": [ + "container", + "image", + "image-name", + "service-image" ], "postUpgradeTasks": { "commands": [ - "find template -type f -exec sed -i 's|{{{depName}}} {{{currentValue}}}|{{{depName}}} {{{newValue}}}|g' {} +", - "find template -type f -exec sed -i 's|{{{depName}}}=={{{currentValue}}}|{{{depName}}}=={{{newValue}}}|g' {} +" + "find template -type f -exec sed -i 's|{{{depName}}}:{{{currentValue}}}@{{{currentDigest}}}|{{{depName}}}:{{{newValue}}}@{{{newDigest}}}|g' {} +" ] } }, { - "matchDepTypes": [ - "container", - "image", - "image-name", - "service-image" + "matchDatasources": [ + "pypi" ], "postUpgradeTasks": { "commands": [ - "find template -type f -exec sed -i 's|{{{depName}}}:{{{currentValue}}}@{{{currentDigest}}}|{{{depName}}}:{{{newValue}}}@{{{newDigest}}}|g' {} +" + "find template -type f -exec sed -i 's|{{{depName}}} {{{currentValue}}}|{{{depName}}} {{{newValue}}}|g' {} +", + "find template -type f -exec sed -i 's|{{{depName}}}=={{{currentValue}}}|{{{depName}}}=={{{newValue}}}|g' {} +" ] } }, diff --git a/template/.renovaterc.json.jinja b/template/.renovaterc.json.jinja index a5656df2..d733eb53 100644 --- a/template/.renovaterc.json.jinja +++ b/template/.renovaterc.json.jinja @@ -132,26 +132,26 @@ } }, { - "matchDatasources": [ - "pypi" + "matchDepTypes": [ + "container", + "image", + "image-name", + "service-image" ], "postUpgradeTasks": { "commands": [ - "find template -type f -exec sed -i {{ '\'s|{{{depName}}} {{{currentValue}}}|{{{depName}}} {{{newValue}}}|g\' {} +' }}", - "find template -type f -exec sed -i {{ '\'s|{{{depName}}}=={{{currentValue}}}|{{{depName}}}=={{{newValue}}}|g\' {} +' }}" + "find template -type f -exec sed -i {{ '\'s|{{{depName}}}:{{{currentValue}}}@{{{currentDigest}}}|{{{depName}}}:{{{newValue}}}@{{{newDigest}}}|g\' {} +' }}" ] } }, { - "matchDepTypes": [ - "container", - "image", - "image-name", - "service-image" + "matchDatasources": [ + "pypi" ], "postUpgradeTasks": { "commands": [ - "find template -type f -exec sed -i {{ '\'s|{{{depName}}}:{{{currentValue}}}@{{{currentDigest}}}|{{{depName}}}:{{{newValue}}}@{{{newDigest}}}|g\' {} +' }}" + "find template -type f -exec sed -i {{ '\'s|{{{depName}}} {{{currentValue}}}|{{{depName}}} {{{newValue}}}|g\' {} +' }}", + "find template -type f -exec sed -i {{ '\'s|{{{depName}}}=={{{currentValue}}}|{{{depName}}}=={{{newValue}}}|g\' {} +' }}" ] } },