FAQ | This is a LIVE service | Changelog

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
  • uis/devops/continuous-delivery/gitlab-triage
1 result
Show changes
Commits on Source (28)
[flake8]
max-line-length = 99
exclude = venv,env,.tox,build/*,.venv
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
wheelhouse/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
*.db
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Ruby vendor artifacts
vendor/bundle
.bundle
# This file pulls in the GitLab AutoDevOps configuration via an include
# directive and then overrides bits. The rationale for this is we'd like this
# file to eventually have zero local overrides so that we can use the AutoDevOps
# pipeline as-is.
include:
- local: "/.gitlab/webapp.gitlab-ci.yml"
include:
- project: "uis/devops/continuous-delivery/ci-templates"
file: "/auto-devops/common-pipeline.yml"
ref: v6.7.3
- project: "uis/devops/continuous-delivery/ci-templates"
file: "/auto-devops/artifact-registry.yml"
ref: v6.7.3
- project: "uis/devops/continuous-delivery/ci-templates"
file: "/commitlint.yml"
ref: v6.7.3
variables:
DAST_DISABLED: "1"
TEST_DISABLED: "1"
PYTHON_BUILD_DIST_DISABLED: "1"
PUBLISH_PYTHON_PACKAGE_DISABLED: "1"
USE_MERGE_REQUEST_RELEASE_FLOW: "1"
OPENAPI_GENERATOR_PYTHON_URLLIB3_DISABLED: "1"
# Set CI_APPLICATION_REPOSITORY so that we always publish images to the same container registry
# repository. This helps ensure that we don't get an explosion of container registry repositories
# with a single tag in for every branch which ever existed.
CI_APPLICATION_REPOSITORY: $CI_REGISTRY_IMAGE
# RuboCop currently compatible with Ruby 2.6 https://docs.rubocop.org/rubocop/1.74/compatibility.html
# and below and required for code quality, so disable code quality check for now.
CODE_QUALITY_DISABLED: "1"
pre-commit:
rules:
- !reference [build, rules]
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
args:
- --unsafe
- id: check-json
- id: check-toml
- id: check-xml
- id: check-added-large-files
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: detect-private-key
- id: mixed-line-ending
- id: pretty-format-json
args:
- --autofix
- --no-sort-keys
- id: debug-statements
{
"git": {
"commitMessage": "chore(release): ${version}"
},
"gitlab": {
"release": true,
"releaseName": "${version}"
},
"plugins": {
"@release-it/conventional-changelog": {
"infile": "CHANGELOG.md",
"header": "# Changelog",
"preset": {
"name": "conventionalcommits"
}
},
"@release-it/bumper": {
"out": {
"file": "VERSION",
"type": "plain-text"
}
}
}
}
# Changelog
## [0.1.0](https://gitlab.developers.cam.ac.uk/uis/devops/continuous-delivery/gitlab-triage/compare/0.0.0...0.1.0) (2025-03-25)
### Features
* **ci:** add release-it, pre-commit and gitlab ci config ([b29b89b](https://gitlab.developers.cam.ac.uk/uis/devops/continuous-delivery/gitlab-triage/commit/b29b89b0ae03b1d99dd1be966f16c3439da09ff8))
* **image:** add image that wraps the gitlab triage gem ([93044ce](https://gitlab.developers.cam.ac.uk/uis/devops/continuous-delivery/gitlab-triage/commit/93044ceea2dfdd5bafdaaa6d9ef27b43990d8c15))
* **image:** install gitlab-triage gem from Gemfile ([99b4168](https://gitlab.developers.cam.ac.uk/uis/devops/continuous-delivery/gitlab-triage/commit/99b4168a7d5b06b4364dd77f18e79fa746ef9d87))
* initial --dry-run release ([12d82a2](https://gitlab.developers.cam.ac.uk/uis/devops/continuous-delivery/gitlab-triage/commit/12d82a27923928740e1b413ae7fddc6cf49a0210))
* **policy:** add holberton triage policy ([44b6fe7](https://gitlab.developers.cam.ac.uk/uis/devops/continuous-delivery/gitlab-triage/commit/44b6fe74d6587ea6153a5e4093ae263463e3e49f))
###############################################################################
# `base` image for all downstream images to build upon.
# Make sure the ruby version matches the version in the Gemfile.
FROM ruby:3.4.2-slim AS base
RUN set -eux; \
apt-get -q update; \
DEBIAN_FRONTEND=noninteractive apt-get -qy install ruby-dev build-essential
RUN gem install bundler
WORKDIR /usr/src/app
###############################################################################
# `install-deps` image inside which the gitlab-triage gem is installed. The `install-deps` image is
# separate from the `base` image so the `base` image can be used to regenerate the `Gemfile.lock` file.
FROM base AS install-deps
# Install `gitlab-triage` from a `Gemfile` to allow Renovate-it to keep the gem fresh.
COPY Gemfile Gemfile.lock ./
RUN bundle install --path vendor/bundle
ENV GITLAB_TOKEN=""
ENV GITLAB_URL=""
ENV TRIAGE_SOURCE_ID=""
ENV TRIAGE_SOURCE_TYPE=""
ENV TRIAGE_POLICY_FILE=""
###############################################################################
# A development focused image that does not include the triage policies since these are mounted
# as a volume.
FROM install-deps AS development
CMD ["sh", "-c", "bundle exec gitlab-triage --dry-run --token ${GITLAB_TOKEN} --host-url ${GITLAB_URL} --source ${TRIAGE_SOURCE_TYPE} --source-id ${TRIAGE_SOURCE_ID} --policies-file ${TRIAGE_POLICY_FILE}"]
###############################################################################
# The last target is the "default" one and in our case the `production` image that includes all
# triage policies copied from `triage-policies/`.
FROM install-deps AS production
COPY triage-policies/ triage-policies/
CMD ["sh", "-c", "bundle exec gitlab-triage --dry-run --token ${GITLAB_TOKEN} --host-url ${GITLAB_URL} --source ${TRIAGE_SOURCE_TYPE} --source-id ${TRIAGE_SOURCE_ID} --policies-file ${TRIAGE_POLICY_FILE}"]
source 'https://rubygems.org'
# Make sure the ruby version matches the version in the Dockerfile.
ruby '3.4.2'
gem 'gitlab-triage', '~> 1.44', '>= 1.44.3'
gem 'csv'
gem 'racc'
GEM
remote: https://rubygems.org/
specs:
activesupport (8.0.2)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.9)
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
csv (3.3.3)
drb (2.2.1)
gitlab-triage (1.44.4)
activesupport (>= 5.1)
globalid (~> 1.0, >= 1.0.1)
graphql (< 2.1.0)
graphql-client (~> 0.16)
httparty (~> 0.20.0)
globalid (1.2.1)
activesupport (>= 6.1)
graphql (2.0.32)
base64
graphql-client (0.25.0)
activesupport (>= 3.0)
graphql (>= 1.13.0)
httparty (0.20.0)
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
logger (1.6.6)
mime-types (3.6.2)
logger
mime-types-data (~> 3.2015)
mime-types-data (3.2025.0318)
minitest (5.25.5)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
racc (1.8.1)
securerandom (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uri (1.0.3)
PLATFORMS
aarch64-linux
ruby
DEPENDENCIES
csv
gitlab-triage (~> 1.44, >= 1.44.3)
racc
RUBY VERSION
ruby 3.4.2p28
BUNDLED WITH
2.5.23
MIT License
Copyright (c) 2025 University of Cambridge Information Services
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# Gitlab Triage
# GitLab Triage
Gitlab Triage provides a wrapper for the `gitlab-triage` gem, enabling automated
triage of issues, merge requests and epics based on the triage policy.
GitLab Triage provides a wrapper for the [`gitlab-triage`](https://gitlab.com/gitlab-org/ruby/gems/gitlab-triage) gem, enabling automated triage of issues, merge requests and epics based on a triage policy.
## Settings
The following settings are used to configure the `gitlab-triage` tool:
* `GITLAB_TOKEN` a valid GitLab API token. When running in local development, generate your own [GitLab Personal Access Token](https://docs.gitlab.com/user/profile/personal_access_tokens/).
* `GITLAB_URL` a valid GitLab host URL. For UIS DevOps the host is `https://gitlab.developers.cam.ac.uk/`
* `TRIAGE_SOURCE_ID` the id of the target GitLab `project` or `group`.
* `TRIAGE_SOURCE_TYPE` can be either `projects` or `groups` corresponding to the associated `TRIAGE_SOURCE_ID`.
* `TRIAGE_POLICY_FILE` a YAML file containing a valid triage policy.
## Local Development
We use pre-commit to check linting locally and in the CI pipeline. Before you can run pre-commit hooks locally, you need to have the pre-commit package manager installed:
```sh
pip install pre-commit
```
Following this, install the pre-commit hooks locally by running:
```sh
pre-commit install
```
The local development environment uses the settings loaded from `local-dev-settings.env`. You will need to generate your own [GitLab Personal Access Token](https://docs.gitlab.com/user/profile/personal_access_tokens/) store this new token in your own 1Password vault and update `GITLAB_TOKEN` in `local-dev-settings.env` to the 1Password secret reference pointing to the new token.
We include a working example triage policy `./triage-policies/example-triage-policy.yml` that operates on project `uis/devops/experiments/av603/misc`. When developing you own triage policy, refer to the field names defined in [`gitlab-triage`](https://gitlab.com/gitlab-org/ruby/gems/gitlab-triage) and ensure the policy only affects the intended `TRIAGE_SOURCE_ID` by limiting the project path. For example:
```yaml
ruby:
"project_path.include?('uis/devops/experiments/av603/misc')"
```
If the `gitlab-triage` gem becomes stale, the version can be refreshed by updating the target version inside the `Gemfile` and regenerating the `Gemfile.lock`. To update the `Gemfile.lock` you can either install the target version of `Ruby` and `bundler` on your local machine and run `bundle install`:
```sh
brew install ruby@3.0
gem install bundler --user-install
bundle install --path vendor/bundle
```
OR by building an image from the `base` target, mount the working directory containing the `Gemfile` inside a container and running `bundle install` from within the container:
```sh
docker build --target base -t gitlab-triage-base:latest .
docker run -it -v "$(pwd):/usr/src/app" -w /usr/src/app gitlab-triage-base:latest /bin/bash
bundle install --path vendor/bundle
bundle update
```
0.1.0
name: gitlab-triage
services:
bot:
build:
context: .
target: development
dockerfile: Dockerfile
environment:
- GITLAB_TOKEN=${GITLAB_TOKEN}
- GITLAB_URL=${GITLAB_URL}
- TRIAGE_SOURCE_ID=${TRIAGE_SOURCE_ID}
- TRIAGE_SOURCE_TYPE=${TRIAGE_SOURCE_TYPE}
- TRIAGE_POLICY_FILE=${TRIAGE_POLICY_FILE}
volumes:
- ./triage-policies/:/usr/src/app/triage-policies/:ro
# local-dev-settings.env defines the non-secret and secret settings used in local development.
######## DO NOT ADD LIVE SECRETS TO THIS FILE ########
## Non-secret settings used for local development.
GITLAB_URL=https://gitlab.developers.cam.ac.uk/
TRIAGE_POLICY_FILE=/usr/src/app/triage-policies/example-triage-policy.yml
TRIAGE_SOURCE_TYPE=projects
TRIAGE_SOURCE_ID=8102
## Secret setting fetched via secret reference from 1Password vault
GITLAB_TOKEN=op://45sjtta2zimlwdnsbbrnabsjqy/hpeubzrp556f27oamxqoakfrdq/credential
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>uis/devops/renovate-config"
]
}
#!/bin/bash
# run-gitlab-triage.sh starts the GitLab Triage docker stack. Reads environmental variables and
# 1Password secret references defined in `local-dev-settings.env` and injects them into the running
# container.
eval $(op signin --account=uis-devops.1password.eu)
op run --no-masking --env-file "./local-dev-settings.env" -- ${@:-docker compose up --build}
# example-triage-policies.yml contains example gitlab triage policies targeting Gitlab repository
# `uis/devops/experiments/av603/misc`
resource_rules:
issues:
rules:
# Add the `team::Holberton` label if no other `team::` scoped label is present.
- name: Add default `team::` label
conditions:
state: opened
forbidden_labels:
- team::Authentication
- team::Cloud
- team::DevOps
- team::Drupal
- team::Hamilton
- team::Holberton
- team::Identity
- team::Jackson
- team::Johnson
- team::Lovelace
ruby:
"project_path.include?('uis/devops/experiments/av603/misc')"
actions:
labels:
- team::Holberton
# Add default `priority::2 Medium` label if no other `priority::` scoped label is present.
- name: Add default `priority::` label
conditions:
state: opened
forbidden_labels:
- priority::0 Highest
- priority::1 High
- priority::2 Medium
- priority::3 Low
- priority::4 Lowest
ruby:
"project_path.include?('uis/devops/experiments/av603/misc')"
actions:
labels:
- priority::2 Medium
# Add default `issuetype::Task` label if no other `issuetype::` scoped label is present.
# All `issuetype::` scoped labels not listed in `forbidden_labels` are specifically excluded
# and default to `issuetype::Task`.
- name: Add default `issuetype::` label
conditions:
state: opened
forbidden_labels:
- issuetype::Bug
- issuetype::Incident
- issuetype::SubTask
- issuetype::Task
- issuetype::User Story
ruby:
"project_path.include?('uis/devops/experiments/av603/misc')"
actions:
labels:
- issuetype::Task
# holberton-triage-policy.yml contains the default gitlab triage policy used for the Holberton team.
resource_rules:
issues:
rules:
# Add the `team::Holberton` label if no other `team::` scoped label is present.
- name: Add default `team::` label
conditions:
state: opened
forbidden_labels:
- team::Authentication
- team::Cloud
- team::DevOps
- team::Drupal
- team::Hamilton
- team::Holberton
- team::Identity
- team::Jackson
- team::Johnson
- team::Lovelace
ruby:
"project_path.include?('uis/devops/hr') || project_path.include?('uis/devops/finance')"
actions:
labels:
- team::Holberton
# Add default `priority::2 Medium` label if no other `priority::` scoped label is present.
- name: Add default `priority::` label
conditions:
state: opened
forbidden_labels:
- priority::0 Highest
- priority::1 High
- priority::2 Medium
- priority::3 Low
- priority::4 Lowest
ruby:
"project_path.include?('uis/devops/hr') || project_path.include?('uis/devops/finance')"
actions:
labels:
- priority::2 Medium
# Add default `issuetype::Task` label if no other `issuetype::` scoped label is present.
# All `issuetype::` scoped labels not listed in `forbidden_labels` are specifically excluded
# and default to `issuetype::Task`.
- name: Add default `issuetype::` label
conditions:
state: opened
forbidden_labels:
- issuetype::Bug
- issuetype::Incident
- issuetype::SubTask
- issuetype::Task
- issuetype::User Story
ruby:
"project_path.include?('uis/devops/hr') || project_path.include?('uis/devops/finance')"
actions:
labels:
- issuetype::Task