From b895d26c3a88fae627a6f6a607f6cdbd9e13c5be Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 25 Apr 2024 19:46:41 +0800 Subject: [PATCH 1/6] chore: support windows and macos for ci --- .github/workflows/ci.yml | 22 +++++++++++++++++++++- .renovaterc.json | 15 ++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f90f796..159cd15a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ concurrency: jobs: ci: if: ${{ !cancelled() && ! failure() }} - runs-on: ubuntu-22.04 + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: @@ -26,12 +26,32 @@ jobs: - run: make build strategy: matrix: + os: + # renovate: github-runner + - macos-14 + # renovate: github-runner + - ubuntu-22.04 + # renovate: github-runner + - windows-2022 python-version: - "3.8" - "3.9" - "3.10" - "3.11" - "3.12" + # Python 3.8 and 3.9 do not run on macos-14 which is using arm64 hardware. + exclude: + # renovate: github-runner + - os: macos-14 + python-version: "3.8" + # renovate: github-runner + - os: macos-14 + python-version: "3.9" + include: + - os: macos-13 + python-version: "3.8" + - os: macos-13 + python-version: "3.9" consistency: if: ${{ !cancelled() && ! failure() }} runs-on: ubuntu-22.04 diff --git a/.renovaterc.json b/.renovaterc.json index 8df96bfc..7102896c 100644 --- a/.renovaterc.json +++ b/.renovaterc.json @@ -47,10 +47,23 @@ "^template/.*\\.github.*/workflows/.+\\.yml(\\.jinja)?$" ], "matchStrings": [ - "uses: pdm-project/setup-pdm[\\s\\S]+?\\sversion: (?.*)\\n" + "uses: pdm-project/setup-pdm[\\s\\S]+?\\sversion: (?.*)\n" ], "versioningTemplate": "semver" }, + { + "customType": "regex", + "datasourceTemplate": "github-runners", + "depTypeTemplate": "github-runner", + "fileMatch": [ + "^\\.github/workflows/.+\\.yml$", + "^template/.*\\.github.*/workflows/.+\\.yml(\\.jinja)?$" + ], + "matchStrings": [ + "# renovate: github-runner\n\\s+- (os: )?(?.*?)-(?.*)\n" + ], + "versioningTemplate": "docker" + }, { "customType": "regex", "datasourceTemplate": "git-tags", From 66d345cea196fb50c3504a1fd03b509064365e2d Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 25 Apr 2024 19:51:25 +0800 Subject: [PATCH 2/6] update template --- template/.renovaterc.json.jinja | 15 ++++++++- .../workflows/ci.yml.jinja | 32 ++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/template/.renovaterc.json.jinja b/template/.renovaterc.json.jinja index 5335d07a..bb857081 100644 --- a/template/.renovaterc.json.jinja +++ b/template/.renovaterc.json.jinja @@ -54,10 +54,23 @@ [%- endif %] ], "matchStrings": [ - "uses: pdm-project/setup-pdm[\\s\\S]+?\\sversion: (?.*)\\n" + "uses: pdm-project/setup-pdm[\\s\\S]+?\\sversion: (?.*)\n" ], "versioningTemplate": "semver" }, + { + "customType": "regex", + "datasourceTemplate": "github-runners", + "depTypeTemplate": "github-runner", + "fileMatch": [ + "^\\.github/workflows/.+\\.yml$", + "^template/.*\\.github.*/workflows/.+\\.yml(\\.jinja)?$" + ], + "matchStrings": [ + "# renovate: github-runner\n\\s+- (os: )?(?.*?)-(?.*)\n" + ], + "versioningTemplate": "docker" + }, { "customType": "regex", "datasourceTemplate": "git-tags", diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja index ed5f4d90..8632ff0e 100644 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja @@ -6,7 +6,7 @@ concurrency: jobs: ci: if: {{ '${{ !cancelled() && ! failure() }}' }} - runs-on: ubuntu-22.04 + runs-on: {{ '${{ matrix.os }}' }} steps: - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: @@ -27,6 +27,13 @@ jobs: - run: make build strategy: matrix: + os: + # renovate: github-runner + - macos-14 + # renovate: github-runner + - ubuntu-22.04 + # renovate: github-runner + - windows-2022 python-version: [%- if version_between("3.8", min_py, max_py) %] - "3.8" @@ -44,6 +51,29 @@ jobs: - "3.12" [%- endif %] [%- if project_name == "Serious Scaffold Python" %] +[%- if version_between("3.8", min_py, max_py) or version_between("3.9", min_py, max_py) %] + # Python 3.8 and 3.9 do not run on macos-14 which is using arm64 hardware. + exclude: +[%- if version_between("3.8", min_py, max_py) %] + # renovate: github-runner + - os: macos-14 + python-version: "3.8" +[%- endif %] +[%- if version_between("3.9", min_py, max_py) %] + # renovate: github-runner + - os: macos-14 + python-version: "3.9" + include: +[%- endif %] +[%- if version_between("3.8", min_py, max_py) %] + - os: macos-13 + python-version: "3.8" +[%- endif %] +[%- if version_between("3.9", min_py, max_py) %] + - os: macos-13 + python-version: "3.9" +[%- endif %] +[%- endif %] consistency: if: {{ '${{ !cancelled() && ! failure() }}' }} runs-on: ubuntu-22.04 From 9025f698292e36ac6e4a1950b23ffb13eaefe8f1 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 25 Apr 2024 20:15:05 +0800 Subject: [PATCH 3/6] add option in copier.yml --- copier.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/copier.yaml b/copier.yaml index 153116a0..2cd7ad4c 100644 --- a/copier.yaml +++ b/copier.yaml @@ -120,7 +120,16 @@ coverage_threshold: default: 100 help: 'Set the threshold for test coverage, ranging from 0 to 100:' type: int - validator: '[% if not 0 <= coverage_threshold <= 100 %]Test Coverage threshold should be between 0 and 100[% endif %]' + validator: "[% if not 0 <= coverage_threshold <= 100 %]Test Coverage threshold should be between 0 and 100[% endif %]" +platforms: + default: ["macos", "ubuntu", "windows"] + choices: + - macos + - ubuntu + - windows + help: "Set the supported platforms for the project:" + multiselect: true + type: str min_py: default: '3.8' choices: From 610b420c4e394e007ee3e71d456f1f30acfb9a98 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 25 Apr 2024 20:30:41 +0800 Subject: [PATCH 4/6] fix invalid path on windows --- ...name == 'Serious Scaffold Python' %]logo.json[% endif %].jinja | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "template/docs/_static/badges/[% if project_name == \"Serious Scaffold Python\" %]logo.json[% endif %].jinja" => template/docs/_static/badges/[% if project_name == 'Serious Scaffold Python' %]logo.json[% endif %].jinja (100%) diff --git "a/template/docs/_static/badges/[% if project_name == \"Serious Scaffold Python\" %]logo.json[% endif %].jinja" b/template/docs/_static/badges/[% if project_name == 'Serious Scaffold Python' %]logo.json[% endif %].jinja similarity index 100% rename from "template/docs/_static/badges/[% if project_name == \"Serious Scaffold Python\" %]logo.json[% endif %].jinja" rename to template/docs/_static/badges/[% if project_name == 'Serious Scaffold Python' %]logo.json[% endif %].jinja From edac7c5c38f1243a4fd1763ba0c47a957a636703 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 25 Apr 2024 20:46:54 +0800 Subject: [PATCH 5/6] more windows compatibility --- .github/workflows/ci.yml | 4 +++- .github/workflows/release.yml | 8 ++++++-- .../workflows/ci.yml.jinja | 4 +++- .../workflows/release.yml.jinja | 8 ++++++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 159cd15a..53e7c9cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,9 @@ jobs: - run: make dev - run: make lint - run: make test - - run: CI_PAGES_URL=${{ steps.pages.outputs.base_url }} make doc + - run: make doc + env: + CI_PAGES_URL: ${{ steps.pages.outputs.base_url }} - run: make build strategy: matrix: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e762e54d..e1909bda 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,8 +15,12 @@ jobs: name: Setup pages uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 - run: env | sort - - run: PDM_NO_EDITABLE=true make dev-doc - - run: CI_PAGES_URL=${{ steps.pages.outputs.base_url }} make doc + - run: make dev-doc + env: + PDM_NO_EDITABLE: true + - run: make doc + env: + CI_PAGES_URL: ${{ steps.pages.outputs.base_url }} - name: Generate release notes run: make release-notes > release-notes.md - name: Upload release notes diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja index 8632ff0e..5efe2407 100644 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja @@ -23,7 +23,9 @@ jobs: - run: make dev - run: make lint - run: make test - - run: CI_PAGES_URL={{ '${{ steps.pages.outputs.base_url }}' }} make doc + - run: make doc + env: + CI_PAGES_URL: {{ '${{ steps.pages.outputs.base_url }}' }} - run: make build strategy: matrix: 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 4932b126..f356ad25 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 @@ -16,8 +16,12 @@ jobs: name: Setup pages uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 - run: env | sort - - run: PDM_NO_EDITABLE=true make dev-doc - - run: CI_PAGES_URL={{ '${{ steps.pages.outputs.base_url }}' }} make doc + - run: make dev-doc + env: + PDM_NO_EDITABLE: true + - run: make doc + env: + CI_PAGES_URL: {{ '${{ steps.pages.outputs.base_url }}' }} - name: Generate release notes run: make release-notes > release-notes.md - name: Upload release notes From c58153e21d72f2bf81ce57b7af9d68cb081f6d19 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Thu, 25 Apr 2024 20:54:16 +0800 Subject: [PATCH 6/6] make platform as configuration --- includes/copier-answers-sample.yml | 7 ++++++- .../workflows/ci.yml.jinja | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/includes/copier-answers-sample.yml b/includes/copier-answers-sample.yml index caa0bf92..d6043bb7 100644 --- a/includes/copier-answers-sample.yml +++ b/includes/copier-answers-sample.yml @@ -11,7 +11,12 @@ min_py: '3.8' module_name: ss_python organization_name: Serious Scaffold package_name: ss-python -project_description: An evolving Python project template that covers the full development +platforms: + - macos + - ubuntu + - windows +project_description: + An evolving Python project template that covers the full development lifecycle. project_name: Serious Scaffold Python repo_host_type: github.com diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja index 5efe2407..49354d8c 100644 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/ci.yml.jinja @@ -30,12 +30,18 @@ jobs: strategy: matrix: os: +[%- if "macos" in platforms %] # renovate: github-runner - macos-14 +[%- endif %] +[%- if "ubuntu" in platforms %] # renovate: github-runner - ubuntu-22.04 +[%- endif %] +[%- if "windows" in platforms %] # renovate: github-runner - windows-2022 +[%- endif %] python-version: [%- if version_between("3.8", min_py, max_py) %] - "3.8" @@ -53,7 +59,7 @@ jobs: - "3.12" [%- endif %] [%- if project_name == "Serious Scaffold Python" %] -[%- if version_between("3.8", min_py, max_py) or version_between("3.9", min_py, max_py) %] +[%- if "macos" in platforms and (version_between("3.8", min_py, max_py) or version_between("3.9", min_py, max_py)) %] # Python 3.8 and 3.9 do not run on macos-14 which is using arm64 hardware. exclude: [%- if version_between("3.8", min_py, max_py) %]