From 6bfd4f8b96a138b2d31d0ed2d4f148b99190f97e Mon Sep 17 00:00:00 2001 From: "Xuan (Sean) Hu" Date: Mon, 11 Sep 2023 16:21:37 +0800 Subject: [PATCH] ci: Merge CI pipeline for both GitHub Actions and GitLab CI/CD. (#142) --- .github/workflows/ci.yml | 26 +++--------- .gitlab-ci.yml | 32 +++------------ .vscode/settings.json | 8 ++-- Makefile | 6 +-- template/.vscode/settings.json | 8 ++-- template/Makefile.jinja | 6 +-- .../workflows/ci.yml.jinja | 34 +++------------- ...managed' %].gitlab-ci.yml[% endif %].jinja | 40 +++---------------- 8 files changed, 32 insertions(+), 128 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc0bbc75..bebf894e 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 @@ -9,27 +9,11 @@ jobs: 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 dev + - run: make lint - run: make test + - run: make docs + - 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/.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", 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..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 @@ -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 @@ -10,35 +10,11 @@ jobs: 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 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 == '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: