Digikey v4 + Python3.12 + Digikey Localization #536
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', '3.12'] | |
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', '3.12'] | |
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 pip 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.ref == 'refs/heads/main' || 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.ref == 'refs/heads/main' || 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.ref != 'refs/heads/main' && github.event.pull_request.head.repo.full_name != 'sparkmicro/Ki-nTree' }} | |
run: | | |
invoke test -e 0 | |
- name: Coveralls | |
if: ${{ github.ref == 'refs/heads/main' || 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 }} |