Skip to content

Commit abdfc95

Browse files
author
a.pirogov
committed
fix GitLab CI (prevent pages deployment triggered by MR events)
1 parent 8323f9f commit abdfc95

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

  • src/fair_python_cookiecutter/template/{{ cookiecutter.project_slug }}

src/fair_python_cookiecutter/template/{{ cookiecutter.project_slug }}/.gitlab-ci.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,17 @@ run-pre-commit:
6969

7070
# ----
7171

72-
# Test job template (combine with image(s) containing a specific Python version):
72+
# test building docs
73+
test-docs-build:
74+
image: python:latest
75+
stage: test
76+
variables:
77+
<<: *prepare-env
78+
script:
79+
- poetry install --with docs
80+
- poetry run poe docs --verbose
81+
82+
# pytest job template (combine with image(s) containing a specific Python version):
7383
#
7484
# NOTE: it is not possible to easily test against a specific operation system,
7585
# using GitLab CI, as this depends on the used runner (which is usually Linux-based).
@@ -84,7 +94,7 @@ run-pre-commit:
8494
reports:
8595
junit: report.xml # for Gitlab integration of test results
8696

87-
# Tests, instantiated with different Python versions:
97+
# Run tests, using different Python versions:
8898
run-pytest-3.8:
8999
image: python:3.8
90100
<<: *run-pytest
@@ -106,7 +116,7 @@ pages:
106116
image: python:latest
107117
stage: docs
108118
rules:
109-
- if: "$release_docs_pages == 'true' || $release_docs_pages == '1'"
119+
- if: "($release_docs_pages == 'true' || $release_docs_pages == '1') && $CI_PIPELINE_SOURCE != 'merge_request_event'"
110120
variables:
111121
PAGES_BRANCH: gl-pages
112122
HTTPS_REMOTE: https://gitlab-ci-token:${PAGES_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git
@@ -118,14 +128,6 @@ pages:
118128
exit 1
119129
fi
120130
- poetry install --with docs
121-
- |
122-
echo "Checking that docs build successfully for branch..."
123-
if poetry run poe docs --verbose; then
124-
echo "Docs built successfully, proceeding with docs deployment."
125-
else
126-
echo "Docs building failed! Aborting docs deployment..."
127-
exit 1
128-
fi
129131
- git config user.name $GITLAB_USER_NAME
130132
- git config user.email $GITLAB_USER_EMAIL
131133
- git fetch origin $PAGES_BRANCH && git -b checkout $PAGES_BRANCH origin/$PAGES_BRANCH || git checkout $PAGES_BRANCH || echo "Pages branch not deployed yet."

0 commit comments

Comments
 (0)