-
Notifications
You must be signed in to change notification settings - Fork 5
121 lines (115 loc) · 3.32 KB
/
cicd.yml
File metadata and controls
121 lines (115 loc) · 3.32 KB
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
name: CI/CD
on:
push:
branches:
- master
tags:
- '*'
paths-ignore:
- 'docs/**'
- 'examples/**'
pull_request:
branches:
- '*'
jobs:
cleanup-runs:
name: Cleanup previous runs
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install Tox
run: pip install tox
- name: Run linter
run: make lint
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Tox
run: pip install tox
- name: Run tests
run: tox -e py
- name: Publish Test Report
uses: mikepenz/action-junit-report@v1
if: ${{ github.event.pull_request && matrix.python-version == '3.8' }}
with:
report_paths: './out_report.xml'
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Report coverage
uses: codecov/codecov-action@v1
env:
PYTHON_VERSION: ${{ matrix.python-version }}
with:
file: ./coverage.xml
flags: unittest
env_vars: PYTHON_VERSION
fail_ci_if_error: false
build:
name: Build and publish to PyPi
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Build Python package
run: make build
- name: Publish package
if: contains(github.ref, 'refs/tags/')
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: make publish
docker:
name: Build and push Docker image
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'refs/tags/') }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Docker metadata
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: hoffmannlaroche/gcasc
tag-semver: |
{{major}}
{{major}}.{{minor}}
{{major}}.{{minor}}.{{patch}}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'refs/tags/') }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}