Skip to content

Commit

Permalink
Merge pull request 'feature/setup-tests' (#20) from feature/setup-tes…
Browse files Browse the repository at this point in the history
  • Loading branch information
kafetzakid committed Dec 13, 2024
2 parents 3a6469b + 7a17e10 commit 2678a7e
Show file tree
Hide file tree
Showing 23 changed files with 338 additions and 1,604 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# Some changes have been made: different OS
# Copied from kuleuven/mango-mdschema

name: Python package

run-name: Build triggered via ${{ github.event_name }} by ${{ github.actor }}

on:
# push won't trigger this because you cannot push without PR anyways
pull_request:
branches: ["main"]

jobs:
test:
strategy:
fail-fast: false
matrix:
# test in multiple python versions and OS
# results in 12 (4x3) jobs
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}

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
python -m pip install pytest pytest-cov
pip install -r requirements.txt
- name: Test with pytest
run: |
pytest tests --doctest-modules --junitxml=junit/test-results-${{ matrix.python-version }}-${{ matrix.os }}.xml --cov --cov-report=xml --cov-report=html
- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: pytest-results-${{ matrix.python-version }}-${{ matrix.os }}
path: junit/test-results-${{ matrix.python-version }}-${{ matrix.os }}.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
lint:
# only run one linting job on ubuntu and the latest Python
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pylint
pip install -r requirements.txt
- name: Lint with pylint
run: |
# fail only if there are errors
pylint src/irods2dataverse tests --fail-under=6
82 changes: 82 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# Lots taken from https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
# Copied from kuleuven/mango-mdschema

name: Upload Python Package

run-name: Deploy triggered by ${{ github.actor }}

on:
release:
types: [published]
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest # only build this distribution for now
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: package-distribution
path: dist/
pypi-publish:
name: Upload release to PyPI
# only upload to PyPI on releases and tagged branches
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/irods2dataverse
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download dists
uses: actions/download-artifact@v4
with:
name: package-distribution
path: dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
testpypi-publish:
name: Upload release to TestPyPI
# upload to TestPyPI on every push to main, not with tags
if: (!startsWith(github.ref, 'refs/tags/'))
needs:
- build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/irods2dataverse
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download dists
uses: actions/download-artifact@v4
with:
name: package-distribution
path: dist/
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/src/.ipynb_checkpoints/
/venv/
src/__pycache__/
src/tests/__pycache__/
tests/__pycache__/
src/irods2dataverse/__pycache__/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 KU Leuven

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 2678a7e

Please sign in to comment.