-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# This file is a template, and might need editing before it works on your project. | ||
|
||
stages: | ||
- prepare | ||
- test | ||
- finalize | ||
- release | ||
|
||
variables: | ||
# Change cache dirs to be inside the project (can only cache local items) | ||
PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip | ||
PIPX_HOME: $CI_PROJECT_DIR/.cache/pipx | ||
PRE_COMMIT_HOME: $CI_PROJECT_DIR/.cache/pre-commit | ||
# Coveralls configuration | ||
CI_NAME: gitlab-ci | ||
CI_BRANCH: $CI_COMMIT_REF_NAME | ||
CI_BUILD_NUMBER: $CI_PIPELINE_ID | ||
CI_BUILD_URL: $CI_PIPELINE_URL | ||
|
||
workflow: | ||
rules: | ||
# Restrict the number of times the pipeline runs to save resources/limits | ||
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' | ||
variables: | ||
# Specific merge request configurations for coveralls | ||
CI_BRANCH: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME | ||
CI_PULL_REQUEST: $CI_MERGE_REQUEST_IID | ||
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == 'push' | ||
when: never # Avoid running the pipeline twice (push + merge request) | ||
- if: $CI_COMMIT_BRANCH || $CI_COMMIT_TAG | ||
# You can also set recurring execution of the pipeline, see: | ||
# https://docs.gitlab.com/ee/ci/pipelines/schedules.html | ||
|
||
cache: | ||
key: pip-pipx-pre-commit-$CI_JOB_IMAGE | ||
paths: | ||
- .cache/pip | ||
- .cache/pipx | ||
- .cache/pre-commit | ||
|
||
default: | ||
before_script: | ||
- python --version # useful for debugging | ||
# Setup git (used for setuptools-scm) | ||
- git config --global user.email "you@example.com" | ||
- git config --global user.name "Your Name" | ||
# Install dependencies for the testing environment | ||
- pip install -U pip tox pipx | ||
|
||
check: | ||
stage: prepare | ||
image: "python:3.10" | ||
script: pipx run pre-commit run --all-files --show-diff-on-failure | ||
|
||
build: | ||
stage: prepare | ||
image: "python:3.10" | ||
script: tox -e clean,build | ||
variables: | ||
GIT_DEPTH: "0" # deep-clone | ||
artifacts: | ||
expire_in: 1 day | ||
paths: [dist] | ||
|
||
.test_script: &test_script | ||
dependencies: [build] | ||
variables: | ||
COVERALLS_PARALLEL: "true" | ||
COVERALLS_FLAG_NAME: $CI_JOB_NAME | ||
script: | ||
- tox --installpkg dist/*.whl -- -rFEx --durations 10 --color yes | ||
- pipx run coverage lcov -o coverage.lcov | ||
- pipx run coveralls --submit coverage.lcov | ||
|
||
py37: | ||
stage: test | ||
image: "python:3.7" | ||
<<: *test_script | ||
|
||
py38: | ||
stage: test | ||
image: "python:3.8" | ||
<<: *test_script | ||
|
||
py39: | ||
stage: test | ||
image: "python:3.9" | ||
<<: *test_script | ||
|
||
py310: | ||
stage: test | ||
image: "python:3.10" | ||
<<: *test_script | ||
|
||
mamba: | ||
stage: test | ||
image: "condaforge/mambaforge" | ||
before_script: mamba install -y pip tox pipx | ||
<<: *test_script | ||
|
||
upload-coverage: | ||
stage: finalize | ||
image: "python:3.10" | ||
script: pipx run coveralls --finish | ||
|
||
publish: | ||
stage: release | ||
dependencies: [build] | ||
image: "python:3.10" | ||
rules: [if: $CI_COMMIT_TAG] | ||
variables: | ||
# See: https://pypi.org/help/#apitoken | ||
# Needs a PYPI_TOKEN protected variable to be configured for `v*` tags, see: | ||
# https://docs.gitlab.com/ee/ci/variables/#add-a-cicd-variable-to-a-project | ||
# https://docs.gitlab.com/ee/user/project/protected_tags.html | ||
TWINE_REPOSITORY: testpypi | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: $PYPI_TOKEN | ||
script: tox -e publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,5 +123,6 @@ version = 4.1.5 | |
package = ci_tester | ||
extensions = | ||
cirrus | ||
gitlab | ||
pre_commit | ||
github_actions |