|
1
|
|
-image: python:latest
|
|
|
1
|
+# Éviter les pipelines dupliqués quand on pousse dans une MR
|
|
|
2
|
+# Voir https://docs.gitlab.com/ci/yaml/workflow/#switch-between-branch-pipelines-and-merge-request-pipelines
|
|
|
3
|
+workflow:
|
|
|
4
|
+ rules:
|
|
|
5
|
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
|
6
|
+ - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
|
|
|
7
|
+ when: never
|
|
|
8
|
+ - if: $CI_COMMIT_BRANCH
|
|
|
9
|
+
|
|
|
10
|
+# -----------------------------------------------------------------------------
|
|
2
|
11
|
|
|
3
|
12
|
test:
|
|
4
|
|
- before_script:
|
|
5
|
|
- - python -V
|
|
6
|
|
- - pip install virtualenv
|
|
7
|
|
- - virtualenv venv
|
|
8
|
|
- - source venv/bin/activate
|
|
9
|
|
- - pip install -q -r requirements.txt
|
|
10
|
|
- script:
|
|
11
|
|
- - sphinx-build -nW -b html -d _build/doctrees source _build/html
|
|
|
13
|
+ stage: test
|
|
|
14
|
+ interruptible: true
|
|
|
15
|
+ rules:
|
|
|
16
|
+ - when: always
|
|
|
17
|
+ needs: []
|
|
|
18
|
+
|
|
|
19
|
+ # Utiliser la même version que spécifiée dans .readthedocs.yaml
|
|
|
20
|
+ image: python:3.14-slim
|
|
|
21
|
+
|
|
|
22
|
+ cache: # Pip's cache doesn't store the python packages
|
|
|
23
|
+ paths: # https://pip.pypa.io/en/stable/topics/caching/
|
|
|
24
|
+ - .cache/pip
|
|
|
25
|
+ variables:
|
|
|
26
|
+ PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" # Change pip's cache directory to be inside the project directory since we can only cache local items.
|
|
12
|
27
|
|
|
13
|
|
-pages:
|
|
14
|
|
- stage: build
|
|
15
|
|
- cache:
|
|
16
|
|
- key: gitlab-pages
|
|
17
|
|
- paths: [public]
|
|
18
|
28
|
before_script:
|
|
19
|
29
|
- python -V
|
|
20
|
30
|
- pip install virtualenv
|
|
21
|
31
|
- virtualenv venv
|
|
22
|
32
|
- source venv/bin/activate
|
|
23
|
33
|
- pip install -q -r requirements.txt
|
|
24
|
|
- - mkdir -p public/previews
|
|
25
|
|
- - rm -rf public/previews/$CI_COMMIT_REF_SLUG
|
|
26
|
34
|
script:
|
|
27
|
|
- - sphinx-build -b html source public/previews/$CI_COMMIT_REF_SLUG
|
|
28
|
|
- - cd public/previews/
|
|
29
|
|
- - echo "<html><body><h1>$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME</h1><p>Official build documentation is on readthedocs.org, this page is only here for dev purpose :</p><ul>" > ../index.html
|
|
30
|
|
- - find -type d -mindepth 1 -maxdepth 1 -exec echo "<li><a href='previews/{}'>{}</a></li>" \; >> ../index.html
|
|
31
|
|
- - echo "</ul></body></html>" >> ../index.html
|
|
32
|
|
- environment:
|
|
33
|
|
- name: pages/$CI_COMMIT_BRANCH
|
|
34
|
|
- action: start
|
|
35
|
|
- url: $CI_PAGES_URL/$CURRENT_CONTENT_PATH
|
|
36
|
|
- on_stop: pages-clean-preview
|
|
37
|
|
- resource_group: one-gitlab-pages-for-all-branches
|
|
|
35
|
+ - sphinx-build -nW -b html -d _build/doctrees source public/
|
|
|
36
|
+ after_script:
|
|
|
37
|
+ - echo "PAGES_JOB_ID=$CI_JOB_ID" >> job.env
|
|
|
38
|
+
|
|
38
|
39
|
artifacts:
|
|
39
|
40
|
paths:
|
|
40
|
|
- - public
|
|
|
41
|
+ - public/
|
|
|
42
|
+ reports:
|
|
|
43
|
+ dotenv: job.env
|
|
41
|
44
|
|
|
42
|
|
-pages-clean-preview:
|
|
43
|
|
- stage: build
|
|
44
|
|
- cache:
|
|
45
|
|
- key: gitlab-pages
|
|
46
|
|
- paths: [public]
|
|
47
|
|
- variables:
|
|
48
|
|
- GIT_STRATEGY: none
|
|
49
|
|
- FOLDER_TO_DELETE: previews/$CI_COMMIT_REF_SLUG
|
|
50
|
|
- script:
|
|
51
|
|
- - rm -rf public/$FOLDER_TO_DELETE
|
|
52
|
|
- environment:
|
|
53
|
|
- name: pages/$CI_COMMIT_BRANCH
|
|
54
|
|
- action: stop
|
|
|
45
|
+
|
|
|
46
|
+danger-review:
|
|
|
47
|
+ stage: test
|
|
55
|
48
|
rules:
|
|
56
|
|
- - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
|
|
57
|
|
- when: manual
|
|
58
|
|
- allow_failure: true |
|
|
49
|
+ - if: ($CI_PIPELINE_SOURCE == 'merge_request_event' && $DANGER_GITLAB_API_TOKEN != null)
|
|
|
50
|
+ needs:
|
|
|
51
|
+ - job: test
|
|
|
52
|
+ artifacts: true # pour récupérer le fichier job.env
|
|
|
53
|
+
|
|
|
54
|
+ image: node
|
|
|
55
|
+ before_script:
|
|
|
56
|
+ - npx --package danger@^13.0.5 --call='danger --version'
|
|
|
57
|
+ script:
|
|
|
58
|
+ - npx --package danger@^13.0.5 --call='danger ci --failOnErrors' |