-
Notifications
You must be signed in to change notification settings - Fork 10
148 lines (125 loc) · 4.41 KB
/
build.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
name: luna build and deploy
run-name: ${{ github.actor }} build
on: [push]
jobs:
build:
runs-on: ubuntu-20.04
services:
localstack:
image: localstack/localstack
ports:
- "4566:4566"
- "4510-4559:4510-4559"
container:
image: mambaorg/micromamba:1.0.0
options: --user root
steps:
- name: Install required packages
run: |
apt-get update
apt-get install -y build-essential libgdal-dev liblapack-dev libblas-dev gfortran libgl1 git curl make python3-pip
git config --system --add safe.directory *
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache
with:
path: ./venv
key: ${{ runner.os }}-${{ hashFiles('environment.yml', 'poetry.lock', 'pyproject.toml')}}
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
micromamba create -y -p ./venv -f environment.yml
. ./venv/bin/activate
poetry export --without-hashes -f requirements.txt --dev | SETUPTOOLS_USE_DISTUTILS=stdlib pip install --no-deps -r /dev/stdin
- name: Build project
run: |
. ./venv/bin/activate
poetry config virtualenvs.create false
poetry build
pip install --no-deps --force-reinstall dist/*.whl
- name: Lint with flake8
run: |
. ./venv/bin/activate
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
. ./venv/bin/activate
export LUNA_HOME=$PWD
export LOCALSTACK_ENDPOINT_URL=http://localstack:4566
pytest -v --capture=tee-sys --show-capture=all tests --cov-report=xml --junitxml=./luna-tests/results.xml
- name: Build mkdocs
run: |
. ./venv/bin/activate
export LUNA_HOME=$PWD
mkdocs build
- name: Deploy mkdocs
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
run: |
. ./venv/bin/activate
export LUNA_HOME=$PWD
mkdocs gh-deploy --force
deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-20.04
container:
image: mambaorg/micromamba:1.0.0
options: --user root
steps:
- name: Install required packages
run: |
apt-get update
apt-get install -y git
- uses: actions/checkout@v3
- name: Build project
run: |
micromamba create -y -p ./venv -f environment.yml
. ./venv/bin/activate
poetry config virtualenvs.create false
poetry build
# temporarily turn branch protection off for semantic release
- name: Branch protection OFF
uses: octokit/[email protected]
with:
route: PUT /repos/msk-mind/luna/branches/master/protection
repository: ${{ github.repository }}
required_status_checks: |
null
enforce_admins: |
null
required_pull_request_reviews: |
null
restrictions: |
null
env:
GITHUB_TOKEN: ${{ secrets.GIT_ADMIN_TOKEN }}
# create a git release
- name: Release pyluna
uses: relekang/python-semantic-release@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
pypi_token: ${{ secrets.PYPI_TOKEN }}
# turn branch protection back on
- name: Branch protection ON
uses: octokit/[email protected]
with:
route: PUT /repos/msk-mind/luna/branches/master/protection
repository: ${{ github.repository }}
required_status_checks: |
null
enforce_admins: |
null
required_pull_request_reviews: |
required_approving_review_count: 1
restrictions: |
null
env:
GITHUB_TOKEN: ${{ secrets.GIT_ADMIN_TOKEN }}
- name: Publish pyluna to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
packages_dir: ./dist