Skip to content

Commit

Permalink
chore: Use rules instead of only in GitLab CI/CD. (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan committed Jan 13, 2024
1 parent cb2f0fc commit 5626341
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .gitlab/ci/ci.yml
Expand Up @@ -7,9 +7,6 @@ ci:
coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/
image: ${CI_REGISTRY_IMAGE}:dev-py${PYTHON_VERSION}
interruptible: true
only:
- main
- merge_requests
parallel:
matrix:
- PYTHON_VERSION:
Expand All @@ -18,6 +15,9 @@ ci:
- '3.10'
- '3.11'
- '3.12'
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
script:
- env | sort
- make dev
Expand Down
6 changes: 4 additions & 2 deletions .gitlab/ci/devcontainer.yml
@@ -1,8 +1,6 @@
devcontainer-prebuild:
image: docker:latest
interruptible: true
only:
- main
parallel:
matrix:
- PYTHON_VERSION:
Expand All @@ -11,6 +9,10 @@ devcontainer-prebuild:
- '3.10'
- '3.11'
- '3.12'
rules:
- changes:
- .devcontainer/prebuild/**/*
if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- apk add --update nodejs npm python3 make g++
- npm install -g @devcontainers/cli
Expand Down
4 changes: 2 additions & 2 deletions .gitlab/ci/mr.yml
@@ -1,7 +1,7 @@
lint_title:
interruptible: true
only:
- merge_requests
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
script:
- |
if ! echo "$CI_MERGE_REQUEST_TITLE" | grep -Pq '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*'; then
Expand Down
16 changes: 8 additions & 8 deletions .gitlab/ci/release.yml
Expand Up @@ -4,8 +4,8 @@ docs:
- public
- docs/changelog.md
- release-notes.md
only:
- /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
rules:
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
script:
- env | sort
- make dev-docs
Expand All @@ -15,8 +15,8 @@ docs:
package:
needs:
- release
only:
- /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
rules:
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
script:
- env | sort
- make publish
Expand All @@ -28,20 +28,20 @@ pages:
needs:
- release
- docs
only:
- /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
rules:
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
script:
- env | sort
stage: release
release:
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- docs
only:
- /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
release:
description: release-notes.md
tag_name: $CI_COMMIT_TAG
rules:
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
script:
- env | sort
stage: release
Expand Up @@ -8,9 +8,6 @@ ci:
coverage: /(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/
image: ${CI_REGISTRY_IMAGE}:dev-py${PYTHON_VERSION}
interruptible: true
only:
- main
- merge_requests
parallel:
matrix:
- PYTHON_VERSION:
Expand All @@ -29,6 +26,9 @@ ci:
[%- if version_between("3.12", min_py, max_py) %]
- '3.12'
[%- endif %]
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
script:
- env | sort
- make dev
Expand Down
@@ -1,8 +1,6 @@
devcontainer-prebuild:
image: docker:latest
interruptible: true
only:
- main
parallel:
matrix:
- PYTHON_VERSION:
Expand All @@ -11,6 +9,10 @@ devcontainer-prebuild:
- '3.10'
- '3.11'
- '3.12'
rules:
- changes:
- .devcontainer/prebuild/**/*
if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- apk add --update nodejs npm python3 make g++
- npm install -g @devcontainers/cli
Expand Down
@@ -1,7 +1,7 @@
lint_title:
interruptible: true
only:
- merge_requests
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
script:
- |
if ! echo "$CI_MERGE_REQUEST_TITLE" | grep -Pq '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!?:\s.*'; then
Expand Down
Expand Up @@ -4,8 +4,8 @@ docs:
- public
- docs/changelog.md
- release-notes.md
only:
- /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
rules:
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
script:
- env | sort
- make dev-docs
Expand All @@ -15,8 +15,8 @@ docs:
package:
needs:
- release
only:
- /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
rules:
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
script:
- env | sort
- make publish
Expand All @@ -28,20 +28,20 @@ pages:
needs:
- release
- docs
only:
- /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
rules:
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
script:
- env | sort
stage: release
release:
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- docs
only:
- /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
release:
description: release-notes.md
tag_name: $CI_COMMIT_TAG
rules:
- if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/
script:
- env | sort
stage: release

0 comments on commit 5626341

Please sign in to comment.