~sumner/sublime-music

ref: 3976bffe81fe91280cbc507b76b156e332eaab49 sublime-music/.gitlab-ci.yml -rw-r--r-- 3.3 KiB
3976bffeSumner Evans contributing: commit message format spec 6 months ago
                                                                                
1
2
3
4
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
stages:
  - build-containers
  - test
  - build
  - deploy
  - verify
  - release

variables:
  GIT_SUBMODULE_STRATEGY: recursive
  LC_ALL: "C.UTF-8"
  LANG: "C.UTF-8"

cache:
  paths:
    - .venv/

image: registry.gitlab.com/sublime-music/sublime-music/python-build:latest

lint:
  stage: test
  before_script:
    - ./cicd/install-project-deps.sh
  script:
    - poetry check
    - poetry run black --check .
    - poetry run flake8
    - poetry run mypy sublime_music tests/**/*.py
    - poetry run cicd/custom_style_check.py

test:
  stage: test
  before_script:
    - ./cicd/install-project-deps.sh
    - ./cicd/start-dbus.sh
    - apt install xvfb
    - Xvfb :119 -screen 0 1024x768x16 &
    - export DISPLAY=:119
  script:
    - poetry run ./cicd/pytest.sh
  artifacts:
    paths:
      - htmlcov

build:
  stage: build
  before_script:
    - ./cicd/install-project-deps.sh
  script:
    - poetry build
  artifacts:
    paths:
      - dist/*
    expire_in: 7 days

build_flatpak:
  image: registry.gitlab.com/sublime-music/sublime-music/flatpak-build:latest
  stage: build
  script:
    - cd flatpak
    - ./flatpak_build.sh
  artifacts:
    paths:
      - flatpak/sublime-music.flatpak

# Deploy documenation and code coverage to GitLab Pages
pages:
  only:
    - master
  stage: deploy
  before_script:
    - ./cicd/install-project-deps.sh
    - ./cicd/start-dbus.sh
  script:
    - ./cicd/pages-build.sh
  artifacts:
    paths:
      - public

deploy_pypi:
  image: python:3.8-alpine
  stage: deploy
  cache: {}
  only:
    variables:
      # Only do a deploy if it's a version tag.
      - $CI_COMMIT_TAG =~ /^v.*/
  before_script:
    - apk add gcc musl-dev libffi-dev openssl-dev
    - pip install twine
    - './cicd/create-pypirc.sh'
  script:
    # Upload to the test PyPi instance, then upload to the real one.
    - twine upload -r pypi_test dist/*
    - twine upload dist/*
  after_script:
    - echo "" > ~/.pypirc && rm -f ~/.pypirc

verify_deploy:
  stage: verify
  cache: {}
  only:
    variables:
      # Only verify the deploy if it's a version tag.
      - $CI_COMMIT_TAG =~ /^v.*/
  script:
    - pip3 install sublime-music

publish_release:
  stage: release
  only:
    variables:
      # Only verify the deploy if it's a version tag.
      - $CI_COMMIT_TAG =~ /^v.*/
  before_script:
    - ./cicd/install-project-deps.sh
  script:
    - poetry run ./cicd/publish-gitlab-release.sh

# Scheduled Jobs
# =============================================================================

# Create the Docker image for Flatpak builds.
flatpak_docker:
  image: docker:1.13
  stage: build-containers
  only:
    variables:
      - $REBUILD_FLATPAK_DOCKER == "True"
  services:
    - docker:dind
  script:
    - docker version
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build -t $CI_REGISTRY_IMAGE/flatpak-build:latest ./cicd/flatpak-build
    - docker push $CI_REGISTRY_IMAGE/flatpak-build

# Create the Docker image for Python testing/builds.
python_docker:
  image: docker:1.13
  stage: build-containers
  only:
    variables:
      - $REBUILD_PYTHON_DOCKER == "True"
  services:
    - docker:dind
  script:
    - docker version
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker build -t $CI_REGISTRY_IMAGE/python-build:latest ./cicd/python-build
    - docker push $CI_REGISTRY_IMAGE/python-build:latest