feat: add initial python test file #1
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: 'Python' | ||
on: | ||
workflow_call: | ||
secrets: | ||
WORKFLOW_TOKEN: | ||
description: "token to clone with" | ||
required: true | ||
jobs: | ||
lint: | ||
name: Lint | ||
if: ${{ false }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Create lint job | ||
shell: bash | ||
run: | | ||
echo "Job does not exists as it needs to be created." | ||
unit-test: | ||
name: Unit Test | ||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 4 | ||
matrix: | ||
python-version: ['3.10', '3.11', '3.12'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install -r requirements_test.txt | ||
- name: Run Tests | ||
shell: bash | ||
run: | | ||
cd app; | ||
pytest --cov --cov-report term --cov-report xml:../coverage.xml --cov-report html:../coverage/ --junit-xml=../unit.JUnit.xml **/tests/unit; | ||
- name: Upload Test Report | ||
uses: actions/upload-artifact@v4 | ||
if: success() || failure() | ||
with: | ||
name: unit-test-results-${{ matrix.python-version }} | ||
path: unit.JUnit.xml | ||
- name: Upload Coverage Report | ||
uses: actions/upload-artifact@v4 | ||
if: success() || failure() | ||
with: | ||
name: coverage-report-${{ matrix.python-version }} | ||
path: coverage.xml | ||
- name: Upload Coverage | ||
uses: actions/upload-artifact@v4 | ||
if: success() || failure() | ||
with: | ||
name: coverage-${{ matrix.python-version }} | ||
path: coverage/* | ||
# should only run on dev/master and tag | ||
report: | ||
name: Create Test Reports | ||
needs: | ||
- unit-test | ||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 4 | ||
matrix: | ||
python-version: ['3.10', '3.11', '3.12'] | ||
steps: | ||
- name: Test Report | ||
if: success() || failure() | ||
uses: dorny/test-reporter@v1 | ||
id: test-report | ||
with: | ||
artifact: unit-test-results-${{ matrix.python-version }} | ||
name: Unit Test Report [Python ${{ matrix.python-version }}] | ||
path: '*.xml' | ||
reporter: java-junit | ||
- name: Create Shields.io Endpoint.json | ||
if: success() || failure() | ||
shell: bash | ||
run: | | ||
echo ' | ||
{ | ||
"schemaVersion": 1, | ||
"label": "Unit Test", | ||
"message": "${{ steps.test-report.outputs.passed }} passed | ${{ steps.test-report.outputs.skipped }} skipped", | ||
"namedLogo": "github", | ||
"color": "#000", | ||
"style": "plastic" | ||
}' > endpoint_${{ matrix.python-version }}.json | ||
- name: Upload Badge Endpoint json | ||
uses: actions/upload-artifact@v4 | ||
if: success() || failure() | ||
with: | ||
name: unit-test-shield-endpoint-${{ matrix.python-version }} | ||
path: endpoint_${{ matrix.python-version }}.json | ||
coverage-report: | ||
name: Create Coverage report | ||
needs: | ||
- unit-test | ||
runs-on: ubuntu-latest | ||
strategy: | ||
max-parallel: 4 | ||
matrix: | ||
python-version: ['3.12'] | ||
name: Coverage | ||
steps: | ||
- name: Run Tests | ||
shell: bash | ||
run: | | ||
ls -l; | ||
- name: Download Coverage Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: coverage-report-${{ matrix.python-version }} | ||
github-token: ${{ github.token }} | ||
- name: ls | ||
shell: bash | ||
if: success() || failure() | ||
run: | | ||
ls -l; | ||
- name: Code Coverage Report | ||
uses: irongut/[email protected] | ||
with: | ||
filename: coverage.xml | ||
badge: true | ||
fail_below_min: true | ||
format: markdown | ||
hide_branch_rate: false | ||
hide_complexity: false | ||
indicators: true | ||
output: both | ||
thresholds: '60 85' | ||
- name: ls | ||
shell: bash | ||
if: success() || failure() | ||
run: | | ||
ls -l; | ||
- name: create status check/comment for code coverage results | ||
id: jest_coverage_check | ||
uses: im-open/[email protected] | ||
with: | ||
github-token: ${{ github.token }} | ||
summary-file: code-coverage-results.md | ||
create-pr-comment: true | ||
update-comment-if-one-exists: true | ||
update-comment-key: "${{ env.GITHUB-JOB }}_${{ env.GITHUB-ACTION }}" | ||
- name: Upload Coverage Summary | ||
uses: actions/upload-artifact@v4 | ||
if: success() || failure() | ||
with: | ||
name: code-coverage-results-${{ matrix.python-version }} | ||
path: code-coverage-results.md | ||
badge-endpoint: | ||
name: Publish Badge endpoint files | ||
if: ${{ github.ref_name == 'master' || github.ref_name == 'development' }} | ||
needs: | ||
- report | ||
strategy: | ||
max-parallel: 4 | ||
matrix: | ||
python-version: ['3.12'] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Endpoint Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: 'nofusscomputing/.github' | ||
ref: 'master' | ||
token: ${{ secrets.WORKFLOW_TOKEN }} | ||
path: 'endpoint_publish' | ||
fetch-depth: '1' | ||
show-progress: true | ||
submodules: false | ||
- name: Create Publish Directories | ||
shell: bash | ||
run: | | ||
echo "[Debug] PWD[${PWD}]"; | ||
cd endpoint_publish; | ||
echo "[Debug] PWD[${PWD}]"; | ||
mkdir -p repositories/${{ github.repository }}/${{ github.ref_name }}; | ||
ls -la; | ||
- name: Create Publish Directories | ||
shell: bash | ||
run: | | ||
echo "[Debug] PWD[${PWD}]"; | ||
# cd repositories/${{ github.repository }}/${{ github.ref_name }}; | ||
echo "[Debug] PWD[${PWD}]"; | ||
- name: Download Badge Endpoint json | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: unit-test-shield-endpoint-${{ matrix.python-version }} | ||
- name: Add endpoint file | ||
shell: bash | ||
run: | | ||
echo "[Debug] PWD[${PWD}]"; | ||
echo "[Debug] **************************** - cd endpoint_publish"; | ||
cd endpoint_publish; | ||
echo "[Debug] **************************** - ls -la"; | ||
ls -la | ||
echo "[Debug] ****************************"; | ||
echo "[Debug] PWD[${PWD}]"; | ||
echo "[Debug] **************************** - ls -la ../"; | ||
ls -la ../ | ||
echo "[Debug] **************************** - cp ../endpoint_${{ matrix.python-version }}.json repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_unit_test.json"; | ||
cp ../endpoint_${{ matrix.python-version }}.json repositories/${{ github.repository }}/${{ github.ref_name }}/badge_endpoint_unit_test.json; | ||
echo "[Debug] **************************** - ls -la repositories/${{ github.repository }}/${{ github.ref_name }}/"; | ||
ls -la repositories/${{ github.repository }}/${{ github.ref_name }}/; | ||
- name: Configure git | ||
shell: bash | ||
run: | | ||
git config --global user.email "[email protected]"; | ||
git config --global user.name "nfc-bot"; | ||
- name: Git add | ||
shell: bash | ||
run: | | ||
echo "[Debug] PWD[${PWD}]"; | ||
echo "[Debug] ****************************"; | ||
cd endpoint_publish; | ||
echo "[Debug] ****************************"; | ||
ls -la | ||
echo "[Debug] ****************************"; | ||
echo "[Debug] PWD[${PWD}]"; | ||
echo "[Debug] ****************************"; | ||
git status; | ||
echo "[Debug] ****************************"; | ||
git add . | ||
- name: Git commit | ||
shell: bash | ||
run: | | ||
echo "[Debug] PWD[${PWD}]"; | ||
echo "[Debug] ****************************"; | ||
cd endpoint_publish; | ||
echo "[Debug] ****************************"; | ||
ls -la | ||
echo "[Debug] ****************************"; | ||
echo "[Debug] PWD[${PWD}]"; | ||
echo "[Debug] ****************************"; | ||
git commit -m "chore: add badge endpount file ${{ github.repository }}/${{ github.ref_name }}" | ||
- name: git push | ||
shell: bash | ||
run: | | ||
echo "[Debug] PWD[${PWD}]"; | ||
echo "[Debug] ****************************"; | ||
cd endpoint_publish; | ||
echo "[Debug] ****************************"; | ||
ls -la | ||
echo "[Debug] ****************************"; | ||
echo "[Debug] PWD[${PWD}]"; | ||
echo "[Debug] ****************************"; | ||
git push |