.gitlab-ci.yml 1.83 KB
Newer Older
1 2 3
stages:
  - checks
  - tests
4
  - publish
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
  - coverage

variables:
  DOCKER_IMAGE: "registry.duniter.org/docker/python3/poetry"
  PYTHON_VERSION: "3.7"

image: $DOCKER_IMAGE/$PYTHON_VERSION:latest

.code_changes:
  only:
    changes:
      - silkaj/*.py
      - tests/*.py

.changes:
  only:
    changes:
22 23
      - silkaj/*.py
      - tests/*.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
      - .gitlab-ci.yml
      - pyproject.toml
      - poetry.lock

build:
  extends: .changes
  stage: checks
  script:
    - poetry build

format:
  extends: .code_changes
  stage: checks
  image: $DOCKER_IMAGE/3.8:latest
  script:
39
    - black --check silkaj tests
40 41 42 43 44 45 46 47 48 49 50

.tests:
  extends: .changes
  stage: tests
  image: $DOCKER_IMAGE/$PYTHON_VERSION:latest
  script:
    - poetry install
    - poetry run pytest

tests-3.5:
  extends: .tests
51
  tags: [poetry-56]
52 53 54 55 56
  variables:
    PYTHON_VERSION: "3.5"

tests-3.6:
  extends: .tests
57
  tags: [poetry-56]
58 59 60 61 62
  variables:
    PYTHON_VERSION: "3.6"

tests-3.7-coverage:
  extends: .tests
63
  tags: [poetry-78]
64 65
  script:
    - poetry install
66 67
    - poetry run pytest --cov silkaj --cov-report html:cov_html
    - poetry run coverage-badge -o cov_html/coverage.svg
68 69 70
  artifacts:
    paths:
      - cov_html
71
    expire_in: 2 days
72 73 74

tests-3.8:
  extends: .tests
75
  tags: [poetry-78]
76 77 78
  variables:
    PYTHON_VERSION: "3.8"

79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
pypi_test:
  stage: publish
  only: [tags]
  when: manual
  script:
    - poetry config repositories.pypi_test https://test.pypi.org/legacy/
    - poetry publish --build --username $PYPI_TEST_LOGIN --password $PYPI_TEST_PASSWORD --repository pypi_test

pypi:
  stage: publish
  only: [tags]
  when: manual
  script:
    - poetry publish --build --username $PYPI_LOGIN --password $PYPI_PASSWORD

94
pages:
95
  extends: .changes
96
  needs: [tests-3.7-coverage]
97
  only: [dev]
98 99 100 101 102 103
  stage: coverage
  script: mv cov_html/ public/
  artifacts:
    paths:
      - public
    expire_in: 2 days