Skip to content

Commit

Permalink
ci: Merge CI pipeline for both GitHub Actions and GitLab CI/CD. (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan authored Sep 11, 2023
1 parent 48c2e77 commit 6bfd4f8
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 128 deletions.
26 changes: 5 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
jobs:
lint:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -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:
Expand Down
32 changes: 5 additions & 27 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ lint_title:
exit 1
fi
stage: lint_test
lint:
ci:
image: python:$PYTHON_VERSION
interruptible: true
only:
Expand All @@ -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(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[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:
Expand Down
8 changes: 3 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
"sortJSONValuesReverse": false
},
"vscode-yaml-sort.customSortKeywords_2": [
"stages",
"default",
"lint_title",
"_envops",
"_subdirectory",
"project_name",
Expand All @@ -97,11 +100,6 @@
"max_py",
"default_py",
"choices",
"stages",
"default",
"lint_title",
"lint",
"test",
"package",
"pages",
"release",
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

########################################################################################
Expand Down
8 changes: 3 additions & 5 deletions template/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
"sortJSONValuesReverse": false
},
"vscode-yaml-sort.customSortKeywords_2": [
"stages",
"default",
"lint_title",
"_envops",
"_subdirectory",
"project_name",
Expand All @@ -97,11 +100,6 @@
"max_py",
"default_py",
"choices",
"stages",
"default",
"lint_title",
"lint",
"test",
"package",
"pages",
"release",
Expand Down
6 changes: 3 additions & 3 deletions template/Makefile.jinja
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

########################################################################################
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ lint_title:
exit 1
fi
stage: lint_test
lint:
ci:
image: python:$PYTHON_VERSION
interruptible: true
only:
Expand All @@ -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(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[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:
Expand Down

0 comments on commit 6bfd4f8

Please sign in to comment.