-
Notifications
You must be signed in to change notification settings - Fork 8
182 lines (156 loc) · 4.82 KB
/
simod.yml
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Build, Test, Release
on:
workflow_dispatch:
push:
branches: [ master ]
paths:
- 'src/simod/**'
- 'tests/**'
- '.github/workflows/**'
- 'Dockerfile'
- 'pyproject.toml'
pull_request:
branches: [ master ]
paths:
- 'src/simod/**'
- 'tests/**'
- '.github/workflows/**'
- 'Dockerfile'
env:
DOCKERHUB_USERNAME: nokal
DOCKERHUB_REPO: nokal/simod
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 120
strategy:
matrix:
python-version: [ '3.9' ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '8'
- name: Install
shell: bash
run: |
pip install poetry
poetry install
- name: Test
shell: bash
run: poetry run pytest --cov=. --cov-report=xml --durations=0 -v -x -k "not test_build_fuzzy_calendars and not test_bpic15 and not test_missing_activities_repaired" -m "not benchmark"
- name: PyLint
shell: bash
run: poetry run pylint -j 0 --exit-zero src/simod > pylint.txt
- name: Upload PyLint output
uses: actions/upload-artifact@v3
with:
name: pylint.txt
path: ./pylint.txt
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
env_vars: OS,PYTHON
fail_ci_if_error: false
name: codecov-umbrella
verbose: true
build-and-publish-images:
runs-on: ubuntu-latest
needs: [ test ]
timeout-minutes: 120
if: github.ref == 'refs/heads/master'
outputs:
version: ${{ steps.versioning.outputs.version }}
docker_image: ${{ env.DOCKERHUB_REPO }}:${{ steps.versioning.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- 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
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get the version
id: versioning
run: |
pip install poetry
echo "version=$(poetry version --short)" >> "$GITHUB_OUTPUT"
- name: Build and push to DockerHub
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ env.DOCKERHUB_REPO }}:latest,${{ env.DOCKERHUB_REPO }}:${{ steps.versioning.outputs.version }}
file: Dockerfile
context: .
platforms: linux/amd64,linux/arm64
release-pypi:
needs: [ test ]
runs-on: ubuntu-latest
outputs:
version: ${{ steps.versioning.outputs.version }}
if: github.ref == 'refs/heads/master'
environment:
name: PyPI
url: https://pypi.org/p/simod
permissions:
id-token: write
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install poetry
run: pip install poetry
- name: Build
run: poetry install && poetry build
- name: Generate licenses.md
run: |
poetry run pip install pip-licenses
poetry run pip-licenses --with-system --with-urls --format=markdown --output-file=licenses.md
- name: Upload licenses.md
uses: actions/upload-artifact@v3
with:
name: licenses.md
path: licenses.md
- name: Generate changelog
run: |
echo "# Changelog" > CHANGELOG.md
echo "" >> CHANGELOG.md
echo "\`\`\`" >> CHANGELOG.md
git log --pretty=format:"%h - %s (%an)" $(git describe --tags --abbrev=0)..HEAD >> CHANGELOG.md
echo "" >> CHANGELOG.md
echo "\`\`\`" >> CHANGELOG.md
- name: Get the version
id: versioning
run: echo "version=$(poetry version --short)" >> "$GITHUB_OUTPUT"
- name: Assign a version tag if not present
run: |
if ! git rev-parse ${{ steps.versioning.outputs.version }}; then
git tag ${{ steps.versioning.outputs.version }}
git push --tags
fi
- name: Create a release if needed
uses: softprops/action-gh-release@v1
with:
files: |
dist/*
tag_name: ${{ steps.versioning.outputs.version }}
body_path: CHANGELOG.md
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1