.gitlab-ci.yml 1.82 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 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
  - coverage

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

image: $DOCKER_IMAGE/$PYTHON_VERSION:latest

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

.changes:
  extends: .code_changes
  only:
    changes:
      - .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:
    - black --check bin silkaj tests

.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 66
  script:
    - poetry install
    - poetry run pytest --cov silkaj --cov-report html:cov_html
67
    - poetry run coverage-badge -o cov_html/coverage.svg
68 69 70 71 72 73
  artifacts:
    paths:
      - cov_html

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

78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
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

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