Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • EOLE/infra/ci-tools
  • daniel.dehennin/ci-tools
2 results
Show changes
Commits on Source (5)
# Changelog
## [1.2.1](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/compare/release/1.2.0...release/1.2.1) (2021-12-09)
### Code Refactoring
* **rules:** permit to combine individual rules ([075712a](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/commit/075712a9d7e7d9cac8731debb0312a092bcefbb2)), closes [#3](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/issues/3)
# [1.2.0](https://gitlab.mim-libre.fr/EOLE/infra/ci-tools/compare/release/1.1.0...release/1.2.0) (2021-12-06)
......
......@@ -46,14 +46,13 @@
#
# We can't merge rules with `!reference` until we switch to Gitlab >= 14.3
# https://gitlab.com/gitlab-org/gitlab/-/issues/322992
# Use a `.rules-map` as a workaround
.on-stable-with-semantic-release-config:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
# Exclude semantic-release commits on $STABLE_BRANCH
- if: $CI_COMMIT_BRANCH == $STABLE_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
exists:
- release.config.js
......
......@@ -37,6 +37,7 @@
# - `wip foo`
# - `foo (draft)`
# - `foo [WIP]`
# - message generated by `semantic-release`
---
variables:
STABLE_BRANCH: stable
......@@ -47,97 +48,110 @@ variables:
BUGFIX_PREFIX: bugfix/
FEATURE_PREFIX: feature/
# This rules template should be used as the default rules.
# It select all branches except the stable one.
# We always exclude schedules.
.not-on-stable:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
when: never
# Exclude `Draft` or `WIP` messages
- if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
- if: $CI_COMMIT_BRANCH
when: on_success
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-stable]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- !reference [.rules-map, on-branch]
# Select only branches that are not stable, testing or development.
# We always exclude schedules.
.on-branches:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
when: never
- if: $CI_COMMIT_BRANCH == $TESTING_BRANCH
when: never
- if: $CI_COMMIT_BRANCH == $DEV_BRANCH
when: never
# Exclude `Draft` or `WIP` messages
- if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
- if: $CI_COMMIT_BRANCH
when: on_success
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-tag]
- !reference [.rules-map, not-on-stable]
- !reference [.rules-map, not-on-testing]
- !reference [.rules-map, not-on-dev]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- !reference [.rules-map, on-branch]
# Select the developpment branch except for commits comming from `semantic-release`
# We always exclude schedules.
# Select the developpment branch
.on-dev:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
# Exclude `Draft` or `WIP` messages
- if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
- if: $CI_COMMIT_BRANCH == $DEV_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
- if: $CI_COMMIT_BRANCH == $DEV_BRANCH
when: on_success
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- !reference [.rules-map, on-dev]
# Select the pre-release testing branch except for commits comming from `semantic-release`
# We always exclude schedules.
# Select the pre-release testing branch
.on-testing:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
# Exclude `Draft` or `WIP` messages
- if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
- if: $CI_COMMIT_BRANCH == $TESTING_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
- if: $CI_COMMIT_BRANCH == $TESTING_BRANCH
when: on_success
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- !reference [.rules-map, on-testing]
# Select the stable branch except for commits comming from `semantic-release`
# We always exclude schedules.
# Select the stable branch
.on-stable:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
# Exclude `Draft` or `WIP` messages
- if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
- if: $CI_COMMIT_BRANCH == $STABLE_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
- if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
when: on_success
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, not-on-semantic-release-commit]
- !reference [.rules-map, on-stable]
# Select the protected release tags
# We always exclude schedules.
.on-release-tag:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- !reference [.rules-map, not-on-schedule]
- !reference [.rules-map, not-on-draft]
- !reference [.rules-map, on-release-tag]
# We use a single rules hash to be referenced as array elements by
# individual rules templates above.
# This avoid the duplication of rules conditions
#
# SEE ALSO
# ========
#
# - https://forum.gitlab.com/t/add-conditions-to-rules-array-merged-with-reference/62600
# - https://gitlab.com/gitlab-org/gitlab/-/issues/322992
# - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67922
# - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67922
.rules-map:
not-on-schedule:
if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
not-on-tag:
if: $CI_COMMIT_TAG
when: never
not-on-stable:
if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
when: never
not-on-testing:
if: $CI_COMMIT_BRANCH == $TESTING_BRANCH
when: never
not-on-dev:
if: $CI_COMMIT_BRANCH == $DEV_BRANCH
when: never
not-on-draft:
# Exclude `Draft` or `WIP` messages
- if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
# Only for protected release tags
- if: $CI_COMMIT_TAG =~ /^release\// && $CI_COMMIT_REF_PROTECTED
when: on_success
if: $CI_COMMIT_MESSAGE =~ /(?:draft|wip):|\[(?:draft|wip)\]|\((?:draft|wip)\)/i
when: never
not-on-semantic-release-commit:
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
if: $CI_COMMIT_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
on-branch:
if: $CI_COMMIT_BRANCH
when: on_success
on-stable:
if: $CI_COMMIT_BRANCH == $STABLE_BRANCH
when: on_success
on-testing:
if: $CI_COMMIT_BRANCH == $TESTING_BRANCH
when: on_success
on-dev:
if: $CI_COMMIT_BRANCH == $DEV_BRANCH
when: on_success
on-tag:
if: $CI_COMMIT_TAG
when: on_success
on-release-tag:
if: $CI_COMMIT_TAG =~ /^release\// && $CI_COMMIT_REF_PROTECTED
when: on_success
...