6
0

Python tests

This commit is contained in:
Jon Michael Aanes 2024-05-04 23:19:09 +02:00
parent e113cdf54d
commit c489457f36
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
2 changed files with 35 additions and 15 deletions

View File

@ -3,9 +3,6 @@ name: Python Package
on: on:
workflow_call: workflow_call:
inputs: inputs:
PUBLISH:
required: false
type: boolean
secrets: secrets:
PIPY_REPO_USER: PIPY_REPO_USER:
required: true required: true
@ -15,7 +12,7 @@ on:
type: string type: string
jobs: jobs:
test-and-publish: publish:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: node:21-bookworm image: node:21-bookworm
@ -30,19 +27,10 @@ jobs:
- name: Installing Python Dependencies - name: Installing Python Dependencies
if: success() if: success()
run: python3 -m pip install --upgrade pip setuptools wheel build twine pytest --break-system-packages run: python3 -m pip install --upgrade pip setuptools wheel build twine pytest --break-system-packages
- name: Installing Python Test Dependencies
if: success() && hashFiles('requirements_test.txt') != ''
run: python3 -m pip install --upgrade -r requirements_test.txt --break-system-packages
- name: Installing package
if: success()
run: python3 -m pip install .[test] --break-system-packages
- name: Test Python Code
if: success()
run: python3 -m pytest test
- name: Build - name: Build
if: success() && inputs.PUBLISH if: success()
run: python3 -m build run: python3 -m build
- name: Publish - name: Publish
if: success() && inputs.PUBLISH if: success()
run: python3 -m twine upload --repository-url "https://gitfub.space/api/packages/${{ secrets.PIPY_REPO_USER }}/pypi" -u ${{ secrets.PIPY_REPO_USER }} -p ${{ secrets.PIPY_REPO_PASS }} dist/* run: python3 -m twine upload --repository-url "https://gitfub.space/api/packages/${{ secrets.PIPY_REPO_USER }}/pypi" -u ${{ secrets.PIPY_REPO_USER }} -p ${{ secrets.PIPY_REPO_PASS }} dist/*

View File

@ -0,0 +1,32 @@
name: Python Test
on:
workflow_call:
inputs:
secrets:
jobs:
test:
runs-on: ubuntu-latest
container:
image: node:21-bookworm
steps:
- name: Setting up Python ${{ env.PYTHON_VERSION }} for ${{runner.arch}} ${{runner.os}}
run: |
apt-get update
apt-get install -y python3 python3-pip
- name: Check out repository code
if: success()
uses: actions/checkout@v3
- name: Installing Python Dependencies
if: success()
run: python3 -m pip install --upgrade pip setuptools wheel build twine pytest --break-system-packages
- name: Installing Python Test Dependencies
if: success() && hashFiles('requirements_test.txt') != ''
run: python3 -m pip install --upgrade -r requirements_test.txt --break-system-packages
- name: Installing package
if: success()
run: python3 -m pip install .[test] --break-system-packages
- name: Test Python Code
if: success()
run: python3 -m pytest test