-
Notifications
You must be signed in to change notification settings - Fork 33
181 lines (172 loc) · 5.99 KB
/
test_deploy.yaml
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
name: tests | linting | publishing
on:
push:
branches:
- main
tags:
- "*.*.*"
paths-ignore:
- README.md
- images/**
pull_request:
branches:
- main
jobs:
style:
name: Style checks
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -U flake8 invoke
- name: PEP checks
run: >
invoke style
tests:
name: Integration tests
runs-on: ubuntu-latest
env:
INVENTREE_DB_ENGINE: django.db.backends.sqlite3
INVENTREE_DB_NAME: ${{ github.workspace }}/InvenTree/inventree_default_db.sqlite3
INVENTREE_MEDIA_ROOT: ${{ github.workspace }}/InvenTree
INVENTREE_STATIC_ROOT: ${{ github.workspace }}/InvenTree/static
INVENTREE_BACKUP_DIR: ${{ github.workspace }}/InvenTree/backup
INVENTREE_ENV: 0
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TOKEN_DIGIKEY: ${{ secrets.TOKEN_DIGIKEY }}
DIGIKEY_CLIENT_ID: ${{ secrets.DIGIKEY_CLIENT_ID }}
DIGIKEY_CLIENT_SECRET: ${{ secrets.DIGIKEY_CLIENT_SECRET }}
TME_API_TOKEN: ${{ secrets.TME_API_TOKEN }}
TME_API_SECRET: ${{ secrets.TME_API_SECRET }}
continue-on-error: true
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt install sqlite3
pip install -U invoke coveralls
- name: InvenTree setup
run: |
git clone https://github.com/inventree/InvenTree/
mkdir InvenTree/static
cp tests/files/inventree_default_db.sqlite3 InvenTree/
cd InvenTree/ && git switch stable && invoke install && invoke migrate && cd -
- name: Ki-nTree setup
run: |
invoke install
mkdir -p ~/.config/kintree/user/ && mkdir -p ~/.config/kintree/cache/search/
cp tests/files/inventree_dev.yaml ~/.config/kintree/user/
cp tests/files/kicad_map.yaml ~/.config/kintree/user/
cp tests/files/digikey_config.yaml ~/.config/kintree/user/
cp tests/files/results.tgz ~/.config/kintree/cache/search/
cd ~/.config/kintree/cache/search/ && tar xvf results.tgz && cd -
- name: GUI test
run: |
python kintree_gui.py b > gui.log 2>&1 &
sleep 2
cat gui.log
export len_log=$(cat gui.log | wc -l)
[[ ${len_log} -eq 0 ]] && true || false
- name: Setup Digi-Key token
if: github.event.pull_request.head.repo.full_name == 'sparkmicro/Ki-nTree'
run: |
git clone https://[email protected]/eeintech/digikey-token.git
cd digikey-token/
python digikey_token_refresh.py
git config --global user.email "[email protected]"
git config --global user.name "Ki-nTree Github Actions"
git add -u
git diff-index --quiet HEAD || git commit -m "Update token"
git push origin master
cp token_storage.json ~/.config/kintree/cache/
dk_token=$(cat ~/.config/kintree/cache/token_storage.json)
echo -e "Digi-Key Token: $dk_token\n"
cd ..
- name: Run tests
if: github.event.pull_request.head.repo.full_name == 'sparkmicro/Ki-nTree'
run: |
invoke test -e 1
env:
MOUSER_PART_API_KEY: ${{ secrets.MOUSER_PART_API_KEY }}
ELEMENT14_PART_API_KEY: ${{ secrets.ELEMENT14_PART_API_KEY }}
- name: Run tests (skip APIs)
if: github.event.pull_request.head.repo.full_name != 'sparkmicro/Ki-nTree'
run: |
invoke test -e 0
- name: Coveralls
if: github.event.pull_request.head.repo.full_name == 'sparkmicro/Ki-nTree'
run: |
coveralls --version
coveralls --service=github
- name: Run build
run: |
invoke build
test-publish:
name: Publish to Test PyPI, then PyPI
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs:
- style
- tests
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Alter the version in pyproject.toml and overwrite __version__
run: >
GTAG=$(echo $REF | sed -e 's#.*/##') &&
sed
--in-place
--expression
"s/version = \".*\" # placeholder/version = \"$GTAG\"/g"
pyproject.toml
&& echo "__version__ = '$GTAG'" > kintree/__init__.py
env:
REF: ${{ github.ref }}
- name: Display the inferred version
run: |
head pyproject.toml
head kintree/__init__.py
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: pip install -U poetry
- name: Install poetry dependencies
run: poetry install --no-root --no-dev --no-interaction
- name: Build the package
run: poetry build --no-interaction
- name: Set up TestPyPI repo in poetry
run: poetry config repositories.test https://test.pypi.org/legacy/
- name: Publish to Test PyPI
run: >
poetry publish
--repository "test"
--username "__token__"
--password "$TOKEN_TEST_PYPI"
env:
TOKEN_TEST_PYPI: ${{ secrets.TOKEN_TEST_PYPI }}
- name: Publish to PyPI
run: >
poetry publish
--username "__token__"
--password "$TOKEN_PYPI"
env:
TOKEN_PYPI: ${{ secrets.TOKEN_PYPI }}