Skip to content

Tests

Tests #110

Workflow file for this run

name: Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '0 0 * * 1'
jobs:
BuildAndTest:
runs-on: ubuntu-latest
strategy:
max-parallel: 2
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
defaults:
run:
shell: bash -l {0}
steps:
- name: 'Checkout'
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: 'Deploying miniconda'
uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
environment-file: recipes/workflow.yaml
mamba-version: "*"
channel-priority: true
use-mamba: true
- name: 'Build pip package'
run: |
pip install --no-deps .
- name: 'Show if it runs properly'
run: |
hmnfusion version
- name: 'Run pytest'
run: |
python -m pytest
Coverage:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8']
outputs:
percent: ${{ steps.coverage.outputs.percent }}
defaults:
run:
shell: bash -l {0}
steps:
- name: 'Checkout'
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: 'Deploying miniconda'
uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
environment-file: recipes/workflow.yaml
mamba-version: "*"
channel-priority: true
use-mamba: true
- name: 'Install Soft'
run: |
pip install --no-deps .
pip install pytest-cov
- name: 'Run coverage'
id: coverage
run: |
coverage run -m pytest
coverage json
percent=$(python -c 'import json; data=json.load(open("coverage.json")); print(data["totals"]["percent_covered_display"])')
echo "percent=${percent}" >> "$GITHUB_OUTPUT"
Badge:
needs: Coverage
runs-on: ubuntu-latest
steps:
- name: 'Badge version'
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: 5b62753442bc7c44ae2995299575af0a
filename: coverage.json
label: CodeCoverage
message: "${{ needs.Coverage.outputs.percent }}%"
color: green