Skip to content
.gitlab-ci.yml 1.88 KiB
Newer Older
nimrod's avatar
nimrod committed
---
stages:
  - lint
  - test
nimrod's avatar
nimrod committed
  - release
nimrod's avatar
nimrod committed

pre-commit:
  stage: lint
  image: adarnimrod/ci-images:pre-commit
  variables: &variables
    XDG_CACHE_HOME: "$CI_PROJECT_DIR/.cache"
    PIPENV_VENV_IN_PROJECT: "1"
    LANG: C.UTF-8
  before_script:
    - apt-get update
    - apt-get install -y libdbus-1-dev
    - pipenv install --dev && rm pyproject.toml
  script:
    - pipenv run lint
  cache: &cache
    key: "$CI_JOB_NAME"
    paths:
      - .cache/
      - .venv/

test:
  stage: test
  image: $project:$version-slim
nimrod's avatar
nimrod committed
  before_script: &before_script
nimrod's avatar
nimrod committed
    - apt-get update
    - >-
      apt-get install -y
      bats
      build-essential
      git
      libdbus-1-dev
      libffi-dev
      libglib2.0-dev
      libssl-dev
    - |-
      if [ "$project" = 'pypy' ]
      then
        ln -sf /opt/pypy/bin/pypy "/usr/local/bin/python$version"
      fi
    - pip install pipenv
    - pipenv install --dev --python=$version
  script:
    - pipenv run bats
    - pipenv run check
    - pipenv run doctest
    - pipenv run build
  variables:
    <<: *variables
    PIPENV_SKIP_LOCK: 1
  cache: *cache
  parallel:
    matrix:
      - project: python
        version:
          - "2.7"
          - "3.6"
          - "3.7"
          - "3.8"
          - "3.9"
      - project: pypy
        version:
          - "2.7"
          - "3.6"
          - "3.7"
nimrod's avatar
nimrod committed

upload:
  stage: release
  image: python:3.6
  before_script: *before_script
  script:
    - mv pypirc $HOME/.pypirc
    - pipenv run build
    - pipenv run upload
  variables: *variables
  cache: *cache
  rules:
    - if: $CI_COMMIT_TAG
  artifacts:
    paths:
      - dist/*.whl

release:
  stage: release
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  script:
    - echo GitLab release
  rules:
    - if: $CI_COMMIT_TAG
  release:
    name: Release $CI_COMMIT_TAG
    tag_name: $CI_COMMIT_TAG
    ref: $CI_COMMIT_TAG
    description: GitLab release $CI_COMMIT_TAG