-
Notifications
You must be signed in to change notification settings - Fork 10
/
.gitlab-ci.yml
88 lines (80 loc) · 3.11 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
# This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml
# Note that the Gitlab Runner machine is configured to use MITRE repo
image: python:3
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
- venv/
before_script:
- python -V
- python -m venv venv
- source venv/bin/activate
- pip install --progress-bar off -r tools/requirements.txt
lint yaml:
stage: test
script:
- pip install --progress-bar off -r tests/requirements.txt
- yamllint -c tests/.yamllint .
rules:
- changes:
- "*.yaml"
- "*.yml"
check spelling and syntax:
stage: test
script:
- pip install --progress-bar off -r tests/requirements.txt
# Run tests with minimal console output, produce report, and error on warnings
- pytest tests/test_syntax.py --tb=line --junitxml=report.xml -W error::UserWarning
allow_failure:
exit_codes:
- 1 # Tests were collected and run but some tests failed https://docs.pytest.org/en/latest/reference/exit-codes.html
rules:
- changes:
- data/*.yaml # Source data was updated
- tests/*.py # Any tests changed
- tests/custom_words.txt # Exclusion words updated
- conftest.py # Any test fixtures changed
validate data:
stage: test
script:
- pip install --progress-bar off -r tests/requirements.txt
# Run tests with minimal console output, produce report, and output warnings
- pytest --tb=line --junitxml=report.xml -W default::UserWarning
- yamllint -c tests/.yamllint .
artifacts:
when: always
reports:
junit: report.xml
rules:
- changes:
- data/*.yaml # Source data was updated
- tests/*.py # Any tests changed
- conftest.py # Any test fixtures changed
# Checks that a generated ATLAS.yaml matches the one commited to this project.
# Fails if they are different, only runs on merge requests or protected branches
check ATLAS.yaml up-to-date:
stage: test
script:
- python tools/create_matrix.py
- git diff --exit-code dist/ATLAS.yaml || exit_code=$?
- if [[ $exit_code -ne 0 ]]; then echo 'Runner-generated dist/ATLAS.yaml is different from remote repository version - run tools/create_matrix.py to update and commit the result.'; exit 123; fi;
rules:
# Default branch, main, tags, and all types of merge request pipelines.
- if: $CI_MERGE_REQUEST_IID
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: '$CI_COMMIT_BRANCH == "main"'