-
Notifications
You must be signed in to change notification settings - Fork 33
160 lines (151 loc) · 4.85 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
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.8', '3.10']
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_ENV: 0
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TOKEN_DIGIKEY: ${{ secrets.TOKEN_DIGIKEY }}
strategy:
matrix:
python-version: ['3.8', '3.10']
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
- name: InvenTree setup
run: |
git clone https://github.com/inventree/InvenTree/
cp tests/files/inventree_default_db.sqlite3 InvenTree/
cd InvenTree/ && 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_test.yaml ~/.config/kintree/user/
cp tests/files/results.tgz ~/.config/kintree/cache/search/
cd ~/.config/kintree/cache/search/ && tar xvf results.tgz && cd -
- name: Digi-Key API setup
run: |
git clone https://[email protected]/eeintech/digikey-token.git
cp digikey-token/token_storage.json ~/.config/kintree/cache/
cat ~/.config/kintree/cache/token_storage.json
- name: Run tests
run: |
invoke test
env:
DIGIKEY_CLIENT_ID: ${{ secrets.DIGIKEY_CLIENT_ID }}
DIGIKEY_CLIENT_SECRET: ${{ secrets.DIGIKEY_CLIENT_SECRET }}
MOUSER_PART_API_KEY: ${{ secrets.MOUSER_PART_API_KEY }}
- name: Coveralls
run: |
coveralls --version
coveralls
- name: Run build
run: |
invoke build
- name: Push Digi-Key Token
run: |
cd digikey-token/
git pull
cp ~/.config/kintree/cache/token_storage.json .
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 "Updated token"
git push origin master
cd ..
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 }}