Skip to content

debug CI

debug CI #3

# This workflow will for a variety of Python versions
# - install the code base
# - lint the code base
# - test the code base
# - upload the test coverage to codecov
#
# It will also
# - build the package
# - check the package
#
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Test code and package
on: [push, pull_request]
jobs:
# Job 1
code-consistency:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Ensure repository stays clean
uses: astral-sh/ruff-action@v1
- name: Suggestion to fix issues
if: ${{ failure() }}
run: |
echo "::notice::In project root run 'python -m ruff check . --fix' and commit changes to fix issues."
exit 1
# Job 2
code-testing:
needs: code-consistency # previous job 'code-consistency' need to be finished first
# current job matrix. if modified, remember to UPDATE the strategy in the next job
strategy:
fail-fast: false
matrix:
python-version: ['3.11'] # ['3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest] # [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade package installer for Python
run: pip install --upgrade pip
- name: Install Python dependencies
run: pip install '.[dev]'
#- name: Test with tox
# run: |
# pip install tox tox-gh-actions coverage
# tox --colored yes
#- name: Upload coverage
# uses: codecov/codecov-action@v4.0.1
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# name: Pytest coverage
# env_vars: OS,PYTHON,GITHUB_ACTIONS,GITHUB_ACTION,GITHUB_REF,GITHUB_REPOSITORY,GITHUB_HEAD_REF,GITHUB_RUN_ID,GITHUB_SHA,COVERAGE_FILE
# env:
# OS: ${{ matrix.os }}
# PYTHON: ${{ matrix.python-version }}
- name: Create Python package # dist/*.whl
run: python -m build
- name: Upload zipped Python package for next job
uses: actions/upload-artifact@v4
with:
name: EasyCrystallography - Python ${{ matrix.python-version }}
path: |
dist/*.whl
tests/
if-no-files-found: "error"
compression-level: 0
# Job 3
package-testing:
needs: code-testing # previous job 'code-testing' need to be finished first
strategy:
fail-fast: false
matrix:
python-version: ['3.11'] # ['3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest] # [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Upgrade package installer for Python
run: pip install --upgrade pip
- name: Download zipped Python package from previous job
uses: actions/download-artifact@v4
with: # name or path are taken from the upload step of the previous job
name: EasyCrystallography - Python ${{ matrix.python-version }} # name (without .zip) of the zipped artifact uploaded on the previous jobs
path: . # directory to extract downloaded zipped artifacts
- name: Install Python package from previous job
run: pip install dist/*.whl
- name: Run tests
run: |
pip install pytest
pytest tests/ --color=yes