-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (174 loc) · 6.17 KB
/
unity-py-python-app.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
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Unity-sds-client Python Build
# Do Run if we push anything changes in /libs/unity-py to the main branch
# Run on an PR if it includes unity-py changes OR if the schema in health are changed.
on:
push:
branches:
- main
paths:
- 'libs/unity-py/**'
pull_request:
branches:
- main
paths:
- 'libs/unity-py/**'
- 'schemas/health-service/health-services.schema.json'
jobs:
build:
defaults:
run:
working-directory: ./libs/unity-py
strategy:
fail-fast: false
max-parallel: 2
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
poetry-version: [ "1.8.3" ]
# os: [ ubuntu-18.04, macos-latest, windows-latest ]
os: [ ubuntu-22.04, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: ${{ matrix.poetry-version }}
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
src:
- 'libs/unity-py/**'
- name: Software Version Check
if: steps.changes.outputs.src == 'true'
run: |
unity_py_proposed_version=`poetry version -s`
echo "curl -s -o /dev/null -w \"%{http_code}\" https://pypi.org/project/unity-sds-client/$unity_py_proposed_version/"
status_code=`curl -s -o /dev/null -w "%{http_code}" https://pypi.org/project/unity-sds-client/$unity_py_proposed_version/`
echo "Received status code of $status_code"
if ((status_code == 200)); then
echo "Version already exists."
exit 1
fi
- name: Install dependencies
run: |
poetry self add poetry-monorepo-dependency-plugin
poetry install
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
UNITY_USER: '${{ secrets.UNITY_TEST_USER }}'
UNITY_PASSWORD: '${{ secrets.UNITY_TEST_PASSWORD }}'
run: |
poetry run pytest --cov-report=lcov --cov=unity_sds_client -m "not regression"
- name: Regression Test with pytest
env:
UNITY_USER: '${{ secrets.UNITY_TEST_USER }}'
UNITY_PASSWORD: '${{ secrets.UNITY_TEST_PASSWORD }}'
run: |
poetry run pytest --cov-report=lcov --cov=unity_sds_client -o log_cli=true --log-cli-level=DEBUG
- name: Coveralls
uses: coverallsapp/[email protected]
version:
needs: build
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./libs/unity-py
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.UNITY_BUILD_PAT }}
- name: Set up Python
uses: actions/setup-python@v2
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: "1.8.3"
# Commented out the version bump code. Will publish new unity-py version to pypi on push to main.
# This means we are always releasing. This will fail if the version already exists in Pypi.
# We must ensure that the version has been updated.
# ADded version check above.
# Future work: set PR test to ensure the version has been updated.
# - name: version-bump
# run: |
# poetry version prerelease
# - name: Commit Version Bump
# run: |
# git config --global user.name 'mdps bot'
# git config --global user.email '[email protected]'
# git commit -am "development version bump. [skip actions]"
# git push
- name: Install dependencies
run: |
poetry self add poetry-monorepo-dependency-plugin
poetry install
- name: build
run: |
poetry build
- name: Get version
id: get-version
run: |
echo "::set-output name=current_version::$(poetry version | awk '{print $2}')"
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: ./libs/unity-py/dist
outputs:
publishedVersion: ${{ steps.get-version.outputs.current_version }}
docs:
needs: build
defaults:
run:
working-directory: ./libs/unity-py
strategy:
fail-fast: false
matrix:
python-version: [ "3.10" ]
poetry-version: [ "1.8.3" ]
os: [ ubuntu-22.04 ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: abatilo/[email protected]
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies
run: |
poetry self add poetry-monorepo-dependency-plugin
poetry install --with docs
- name: build docs
run: |
poetry run sphinx-apidoc -f -o docs/source/ unity_sds_client
poetry run sphinx-build -M html docs/source docs/build/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: html-docs
path: ./libs/unity-py/docs/build/html/
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./libs/unity-py/docs/build/html
destination_dir: docs/unity-sds-client