Skip to content

Change Github action for automatic tests #55

Change Github action for automatic tests

Change Github action for automatic tests #55

Workflow file for this run

name: Run Tests and Build Package
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
schedule:
- cron: '0 10 5 * *' # Optional scheduled runs
jobs:
test:
name: Run Tests with Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Install Dependencies
run: |
poetry install
- name: Run Tests with Coverage
run: |
poetry run pytest ./tests --cov=./cpm_python --cov-report=xml --cov-report=term
- name: Upload Coverage Report to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
fail_ci_if_error: true # Fails the CI if uploading fails
build:
name: Build and Publish Distribution
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0 # Full depth for versioning or changelog needs
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Install Dependencies
run: |
poetry install
- name: Build Distribution
run: |
poetry build
- name: List Artifacts
run: |
ls -al dist/
- name: Upload Artifacts (optional)
uses: actions/upload-artifact@v3
with:
name: package-dist
path: dist/