-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bebc46
commit 68d49cf
Showing
2 changed files
with
121 additions
and
76 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# 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: 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: 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 easycrystallography --no-index --find-links=dist/ | ||
|
||
- name: Run tests | ||
run: pytest tests/ --color=yes |