Commit 6ae851b7 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Setup GitLab CI

parent c0e4febe
Loading
Loading
Loading
Loading

.dockerignore

0 → 100644
+1 −0
Original line number Diff line number Diff line
.eggs/

.gitlab-ci.yml

0 → 100644
+89 −0
Original line number Diff line number Diff line
stages:
  - acceptance
  - build
  - publish
  - deploy

variables: &global
  BUILD_TAG: ${CI_REGISTRY_IMAGE}/build/${CI_COMMIT_REF_SLUG}:${CI_PIPELINE_IID}
  LATEST_TAG: ${CI_REGISTRY_IMAGE}/build/${CI_COMMIT_REF_SLUG}:latest

.python:
  image: python:slim
  variables:
    <<: *global
    PYTHONPATH: .
    PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
  cache:
    key: all
    paths:
      - .cache/
      - .eggs/

lint:
  stage: acceptance
  extends: .python
  before_script:
    - pip install -e .
  script:
    - pylint pylint_reporter
      --rcfile setup.cfg
      --load-plugins=pylint_reporter.reporter
      --exit-zero
    - pylint-reporter score lint.json --minimum 8.0
  artifacts:
    when: always
    paths:
      - lint.json

lint:publish:
  stage: publish
  extends: .python
  when: always
  dependencies: [lint]
  needs: [lint]
  before_script: 
    - pip install -e '.[badges]' pylint-json2html
  script:
    - mkdir -p lint
    - pylint-json2html lint.json -f jsonextended -o lint/index.html
    - pylint-reporter badge lint.json lint/lint.svg
  artifacts:
    when: always
    paths:
      - lint

.docker:
  image: docker:stable
  variables:
    <<: *global
    DOCKER_HOST: "tcp://docker:2375/"
    DOCKER_DRIVER: overlay2
    DOCKER_TLS_CERTDIR: ""
    DOCKER_BUILDKIT: "1"
  services:
    - docker:dind
  before_script:
    - docker info
    - docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"

build:
  stage: build
  extends: .docker
  script:
    - docker build . --pull=true --tag=${BUILD_TAG}
    - docker tag ${BUILD_TAG} ${LATEST_TAG}
    - docker push ${BUILD_TAG}
    - docker push ${LATEST_TAG}

deploy:
  stage: deploy
  extends: .docker
  only: [ tag ]
  except:
    - /^[^v]/
    - /^v[^0-9]/
  script:
    - docker pull ${BUILD_TAG}
    - docker tag ${BUILD_TAG} ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
    - docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}

Dockerfile

0 → 100644
+6 −0
Original line number Diff line number Diff line
# syntax = docker/dockerfile:1.0-experimental

ARG PY_VERSION=3.7
FROM python:$PY_VERSION
RUN --mount=type=bind,rw,target=/src \
    pip install -e /src[badges]