Skip to content

Commit

Permalink
[ci] Add retries for scheduled jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
JanEbbing committed Feb 20, 2023
1 parent 24ab267 commit a827c0a
Showing 1 changed file with 70 additions and 9 deletions.
79 changes: 70 additions & 9 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include:

# Global --------------------------

image: python:3.11
image: ${CI_REGISTRY_IMAGE}/python:3.11

variables:
PIP_CACHE_DIR: "${CI_PROJECT_DIR}/.cache/pip"
Expand All @@ -27,6 +27,12 @@ cache:
- .cache/pip
- .venv

workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_TAG
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'

stages:
- check
- build
Expand All @@ -47,20 +53,53 @@ before_script:

# stage: check ----------------------

black:
.black_base:
stage: check
script: poetry run black --check .

flake8:
black_scheduled:
extends: .black_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2

black_manual:
extends: .black_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"

.flake8_base:
stage: check
script: poetry run flake8 deepl tests

licenseCheck:
flake8_scheduled:
extends: .flake8_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2

flake8_manual:
extends: .flake8_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"

.license_check_base:
stage: check
script:
- ./license_checker.sh '*.py' | tee license_check_output.txt
- '[ ! -s license_check_output.txt ]'

license_check_scheduled:
extends: .license_check_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2

license_check_manual:
extends: .license_check_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"

# stage: build ----------------------

package:
Expand All @@ -73,10 +112,9 @@ package:

# stage: test -------------------------

test:
.test_base:
stage: test
extends: .test
retry: 1
parallel:
matrix:
- DOCKER_IMAGE: "python:3.11"
Expand All @@ -102,7 +140,7 @@ test:
# Set minimum possible requests and urllib3 versions to work with Python 3.11
EXTRA_POETRY_ADD_ARGUMENT: "[email protected] [email protected]"
USE_MOCK_SERVER: "use mock server"
image: ${DOCKER_IMAGE}
image: ${CI_REGISTRY_IMAGE}/${DOCKER_IMAGE}
script:
- >
if [[ ! -z "${EXTRA_POETRY_ADD_ARGUMENT}" ]]; then
Expand All @@ -129,10 +167,21 @@ test:
- test_report.xml
when: always

mustache example:
test_scheduled:
extends: .test_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2

test_manual:
stage: test
extends: .test_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"

.mustache_example_base:
stage: test
extends: .test
retry: 1
script:
- cd examples/mustache
- pip install deepl
Expand All @@ -142,6 +191,18 @@ mustache example:
- grep -q "{{user}}" mustache_result.txt
- grep -q "{{{balance}}}" mustache_result.txt

mustache_example_scheduled:
extends: .mustache_example_base
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
retry: 2

mustache_example_manual:
stage: test
extends: .mustache_example_base
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"

# stage: publish -------------------------

pypi upload:
Expand Down

0 comments on commit a827c0a

Please sign in to comment.