From 59c1b1e48f5860075c3e65755d9488645ec49b88 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Mon, 11 Sep 2023 16:08:59 +0800 Subject: [PATCH 1/3] ci: Merge CI pipeline for both GitHub Actions and GitLab CI/CD. --- .github/workflows/ci.yml | 36 ++++++--------- .gitlab-ci.yml | 32 +++----------- .vscode/settings.json | 8 ++-- Makefile | 6 +-- template/Makefile.jinja | 6 +-- .../workflows/ci.yml.jinja | 44 ++++++------------- ...managed' %].gitlab-ci.yml[% endif %].jinja | 40 +++-------------- 7 files changed, 45 insertions(+), 127 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc0bbc75..7fbc81f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,5 @@ jobs: - lint: + ci: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -8,28 +8,18 @@ jobs: with: cache: pip python-version: ${{ matrix.python-version }} - - run: env | sort - - run: make dev-lint - - run: make lint-check - strategy: - matrix: - python-version: - - '3.8' - - '3.9' - - '3.10' - - '3.11' - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - cache: pip - python-version: ${{ matrix.python-version }} - - run: env | sort - - run: make dev-test - - run: make test + - name: Show environment variables for potential debug. + run: env | sort + - name: Install the package in editable mode with all dependencies + run: make dev + - name: Run lint + run: make lint + - name: Run test + run: make test + - name: Build the documentation without deployment. + run: make docs + - name: Build the package without deployment. + run: make build strategy: matrix: python-version: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 65d3b64b..ae87e991 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,7 +15,7 @@ lint_title: exit 1 fi stage: lint_test -lint: +ci: image: python:$PYTHON_VERSION interruptible: true only: @@ -31,33 +31,11 @@ lint: - '3.11' script: - env | sort - - make dev-lint - - make lint-check - stage: lint_test -test: - artifacts: - reports: - coverage_report: - coverage_format: cobertura - path: coverage.xml - coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/ - image: python:$PYTHON_VERSION - interruptible: true - only: - - /^v(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)$/ - - main - - merge_requests - parallel: - matrix: - - PYTHON_VERSION: - - '3.8' - - '3.9' - - '3.10' - - '3.11' - script: - - env | sort - - make dev-test + - make dev + - make lint - make test + - make docs + - make build stage: lint_test package: only: diff --git a/.vscode/settings.json b/.vscode/settings.json index 7c95f077..693ee179 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -77,6 +77,9 @@ "sortJSONValuesReverse": false }, "vscode-yaml-sort.customSortKeywords_2": [ + "stages", + "default", + "lint_title", "_envops", "_subdirectory", "project_name", @@ -97,11 +100,6 @@ "max_py", "default_py", "choices", - "stages", - "default", - "lint_title", - "lint", - "test", "package", "pages", "release", diff --git a/Makefile b/Makefile index 61488eaf..4b2ef253 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean deepclean install dev black isort mypy ruff toml-sort lint pre-commit test freeze version build upload docs docs-autobuild docs-coverage reports docs-all +.PHONY: clean deepclean install dev black isort mypy ruff toml-sort lint pre-commit test freeze version build upload docs docs-autobuild docs-mypy docs-coverage reports docs-all ######################################################################################## # Variables @@ -76,10 +76,10 @@ toml-sort: ${PIPRUN} toml-sort --check pyproject.toml # Check lint with all linters. -lint-check: black isort mypy ruff toml-sort +lint: black isort mypy ruff toml-sort # Run pre-commit with autofix against all files. -lint: +pre-commit: pre-commit run --all-files ######################################################################################## diff --git a/template/Makefile.jinja b/template/Makefile.jinja index 6d0bd17b..7d4ee458 100644 --- a/template/Makefile.jinja +++ b/template/Makefile.jinja @@ -1,4 +1,4 @@ -.PHONY: clean deepclean install dev black isort mypy ruff toml-sort lint pre-commit test freeze version build upload docs docs-autobuild docs-coverage reports docs-all +.PHONY: clean deepclean install dev black isort mypy ruff toml-sort lint pre-commit test freeze version build upload docs docs-autobuild docs-mypy docs-coverage reports docs-all ######################################################################################## # Variables @@ -78,10 +78,10 @@ toml-sort: ${PIPRUN} toml-sort --check pyproject.toml # Check lint with all linters. -lint-check: black isort mypy ruff toml-sort +lint: black isort mypy ruff toml-sort # Run pre-commit with autofix against all files. -lint: +pre-commit: pre-commit run --all-files ######################################################################################## 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 345b1847..583e7b15 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 @@ -1,6 +1,6 @@ [% from pathjoin("includes", "version_compare.jinja") import version_between -%] jobs: - lint: + ci: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -9,36 +9,18 @@ jobs: with: cache: pip python-version: {{ '${{ matrix.python-version }}' }} - - run: env | sort - - run: make dev-lint - - run: make lint-check - strategy: - matrix: - python-version: -[%- if version_between("3.8", min_py, max_py) %] - - '3.8' -[%- endif %] -[%- if version_between("3.9", min_py, max_py) %] - - '3.9' -[%- endif %] -[%- if version_between("3.10", min_py, max_py) %] - - '3.10' -[%- endif %] -[%- if version_between("3.11", min_py, max_py) %] - - '3.11' -[%- endif %] - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up Python {{ '${{ matrix.python-version }}' }} - uses: actions/setup-python@v4 - with: - cache: pip - python-version: {{ '${{ matrix.python-version }}' }} - - run: env | sort - - run: make dev-test - - run: make test + - name: Show environment variables for potential debug. + run: env | sort + - name: Install the package in editable mode with all dependencies + run: make dev + - name: Run lint + run: make lint + - name: Run test + run: make test + - name: Build the documentation without deployment. + run: make docs + - name: Build the package without deployment. + run: make build strategy: matrix: python-version: diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja index 2c3bf836..7baee726 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab-ci.yml[% endif %].jinja @@ -16,7 +16,7 @@ lint_title: exit 1 fi stage: lint_test -lint: +ci: image: python:$PYTHON_VERSION interruptible: true only: @@ -40,41 +40,11 @@ lint: [%- endif %] script: - env | sort - - make dev-lint - - make lint-check - stage: lint_test -test: - artifacts: - reports: - coverage_report: - coverage_format: cobertura - path: coverage.xml - coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/ - image: python:$PYTHON_VERSION - interruptible: true - only: - - /^v(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)$/ - - main - - merge_requests - parallel: - matrix: - - PYTHON_VERSION: -[%- if version_between("3.8", min_py, max_py) %] - - '3.8' -[%- endif %] -[%- if version_between("3.9", min_py, max_py) %] - - '3.9' -[%- endif %] -[%- if version_between("3.10", min_py, max_py) %] - - '3.10' -[%- endif %] -[%- if version_between("3.11", min_py, max_py) %] - - '3.11' -[%- endif %] - script: - - env | sort - - make dev-test + - make dev + - make lint - make test + - make docs + - make build stage: lint_test package: only: From 9a8f01403b813a1051a671c496316323206439bd Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Mon, 11 Sep 2023 16:14:34 +0800 Subject: [PATCH 2/3] Fix consistency. --- template/.vscode/settings.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/template/.vscode/settings.json b/template/.vscode/settings.json index 7c95f077..693ee179 100644 --- a/template/.vscode/settings.json +++ b/template/.vscode/settings.json @@ -77,6 +77,9 @@ "sortJSONValuesReverse": false }, "vscode-yaml-sort.customSortKeywords_2": [ + "stages", + "default", + "lint_title", "_envops", "_subdirectory", "project_name", @@ -97,11 +100,6 @@ "max_py", "default_py", "choices", - "stages", - "default", - "lint_title", - "lint", - "test", "package", "pages", "release", From aaef5f75bc6cd235f6d482fe355181ba32f923dc Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Mon, 11 Sep 2023 16:16:42 +0800 Subject: [PATCH 3/3] Minor. --- .github/workflows/ci.yml | 18 ++++++------------ .../workflows/ci.yml.jinja | 18 ++++++------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7fbc81f0..bebf894e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,18 +8,12 @@ jobs: with: cache: pip python-version: ${{ matrix.python-version }} - - name: Show environment variables for potential debug. - run: env | sort - - name: Install the package in editable mode with all dependencies - run: make dev - - name: Run lint - run: make lint - - name: Run test - run: make test - - name: Build the documentation without deployment. - run: make docs - - name: Build the package without deployment. - run: make build + - run: env | sort + - run: make dev + - run: make lint + - run: make test + - run: make docs + - run: make build strategy: matrix: python-version: 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 583e7b15..9d45c0c0 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 @@ -9,18 +9,12 @@ jobs: with: cache: pip python-version: {{ '${{ matrix.python-version }}' }} - - name: Show environment variables for potential debug. - run: env | sort - - name: Install the package in editable mode with all dependencies - run: make dev - - name: Run lint - run: make lint - - name: Run test - run: make test - - name: Build the documentation without deployment. - run: make docs - - name: Build the package without deployment. - run: make build + - run: env | sort + - run: make dev + - run: make lint + - run: make test + - run: make docs + - run: make build strategy: matrix: python-version: