Skip to content

Commit

Permalink
ci: Align GitLab CI/CD config with GitHub Actions. (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan committed Sep 17, 2023
1 parent df7c7cf commit c74c5e5
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 161 deletions.
File renamed without changes.
77 changes: 1 addition & 76 deletions .gitlab-ci.yml
Expand Up @@ -3,79 +3,4 @@ stages:
- release
default:
image: python:3.11
ci:
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
- make lint test docs build
stage: ci
lint_title:
interruptible: true
only:
- merge_requests
script:
- |
if ! echo "$CI_MERGE_REQUEST_TITLE" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*"; then
echo "The title does not conform to the Conventional Commit."
echo "Please refer to 'https://www.conventionalcommits.org/'"
exit 1
fi
stage: ci
package:
only:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
script:
- env | sort
- make dev-package
- make build
- make upload
stage: release
variables:
TWINE_NON_INTERACTIVE: 'true'
pages:
artifacts:
paths:
- public
except:
refs:
- schedules
only:
changes:
- docs/**/*
refs:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
script:
- env | sort
- make dev-docs
- make docs
stage: release
release:
image: registry.gitlab.com/gitlab-org/release-cli:latest
only:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
release:
description: $CI_COMMIT_TAG_MESSAGE
name: $CI_COMMIT_TAG
tag_name: $CI_COMMIT_TAG
script:
- env | sort
stage: release
include: .gitlab/ci/**.yml
25 changes: 25 additions & 0 deletions .gitlab/ci/ci.yml
@@ -0,0 +1,25 @@
ci:
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
- make lint test docs build
stage: ci
12 changes: 12 additions & 0 deletions .gitlab/ci/mr.yml
@@ -0,0 +1,12 @@
lint_title:
interruptible: true
only:
- merge_requests
script:
- |
if ! echo "$CI_MERGE_REQUEST_TITLE" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*"; then
echo "The title does not conform to the Conventional Commit."
echo "Please refer to 'https://www.conventionalcommits.org/'"
exit 1
fi
stage: ci
51 changes: 51 additions & 0 deletions .gitlab/ci/release.yml
@@ -0,0 +1,51 @@
docs:
artifacts:
paths:
- public
- docs/changelog.md
- release-notes.md
only:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
script:
- env | sort
- make dev-docs
- make docs
- make release-notes > release-notes.md
stage: release
package:
needs:
- release
only:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
script:
- env | sort
- make dev-package
- make build
- make upload
stage: release
variables:
TWINE_NON_INTERACTIVE: 'true'
pages:
artifacts:
paths:
- public
needs:
- release
- docs
only:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
script:
- env | sort
stage: release
release:
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- docs
only:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
release:
description: release-notes.md
tag_name: $CI_COMMIT_TAG
script:
- env | sort
stage: release
@@ -1,90 +1,6 @@
[% from pathjoin("includes", "version_compare.jinja") import version_between -%]
stages:
- ci
- release
default:
image: python:{{ default_py }}
ci:
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
- make lint test docs build
stage: ci
lint_title:
interruptible: true
only:
- merge_requests
script:
- |
if ! echo "$CI_MERGE_REQUEST_TITLE" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*"; then
echo "The title does not conform to the Conventional Commit."
echo "Please refer to 'https://www.conventionalcommits.org/'"
exit 1
fi
stage: ci
package:
only:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
script:
- env | sort
- make dev-package
- make build
- make upload
stage: release
variables:
TWINE_NON_INTERACTIVE: 'true'
pages:
artifacts:
paths:
- public
except:
refs:
- schedules
only:
changes:
- docs/**/*
refs:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
script:
- env | sort
- make dev-docs
- make docs
stage: release
release:
image: registry.gitlab.com/gitlab-org/release-cli:latest
only:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
release:
description: $CI_COMMIT_TAG_MESSAGE
name: $CI_COMMIT_TAG
tag_name: $CI_COMMIT_TAG
script:
- env | sort
stage: release
include: .gitlab/ci/**.yml
@@ -0,0 +1,34 @@
[% from pathjoin("includes", "version_compare.jinja") import version_between -%]
ci:
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
- make lint test docs build
stage: ci
@@ -0,0 +1,12 @@
lint_title:
interruptible: true
only:
- merge_requests
script:
- |
if ! echo "$CI_MERGE_REQUEST_TITLE" | grep -Pq "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*"; then
echo "The title does not conform to the Conventional Commit."
echo "Please refer to 'https://www.conventionalcommits.org/'"
exit 1
fi
stage: ci
@@ -0,0 +1,51 @@
docs:
artifacts:
paths:
- public
- docs/changelog.md
- release-notes.md
only:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
script:
- env | sort
- make dev-docs
- make docs
- make release-notes > release-notes.md
stage: release
package:
needs:
- release
only:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
script:
- env | sort
- make dev-package
- make build
- make upload
stage: release
variables:
TWINE_NON_INTERACTIVE: 'true'
pages:
artifacts:
paths:
- public
needs:
- release
- docs
only:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
script:
- env | sort
stage: release
release:
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- docs
only:
- /^v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)$/
release:
description: release-notes.md
tag_name: $CI_COMMIT_TAG
script:
- env | sort
stage: release

0 comments on commit c74c5e5

Please sign in to comment.