Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Build and Package

on:
push:
branches: [ main ]
tags: [ 'v*' ]
workflow_dispatch:
inputs:
publish_to_testpypi:
description: 'Publish to TestPyPI'
required: false
default: false
type: boolean
publish_to_pypi:
description: 'Publish to PyPI'
required: false
default: false
type: boolean

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine

- name: Install pipenv
run: |
pip install pipenv

- name: Install dependencies
run: |
pipenv install --dev --deploy

- name: Run tests
run: |
pipenv run test

- name: Build package
run: |
python -m build

- name: Check package
run: |
twine check dist/*

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-testpypi:
name: Publish to TestPyPI
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_to_testpypi == 'true')
needs: build
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/p/retraction-check
permissions:
id-token: write

steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

publish-to-pypi:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/v') || (github.event_name == 'workflow_dispatch' && github.event.inputs.publish_to_pypi == 'true')
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/retraction-check
permissions:
id-token: write

steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
45 changes: 45 additions & 0 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Code Quality

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
code-quality:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install pipenv
run: |
python -m pip install --upgrade pip
pip install pipenv

- name: Install dependencies
run: |
pipenv install --dev --deploy

- name: Check code formatting
run: |
pipenv run format-check

- name: Run linting
run: |
pipenv run lint

- name: Run type checking
run: |
pipenv run type-check

- name: Run security check (if bandit is available)
run: |
pipenv run python -m pip list | grep bandit || echo "Bandit not installed, skipping security check"
continue-on-error: true
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Tests

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install pipenv
run: |
python -m pip install --upgrade pip
pip install pipenv

- name: Install dependencies
run: |
pipenv install --dev --deploy

- name: Run linting
run: |
pipenv run lint

- name: Run type checking
run: |
pipenv run type-check

- name: Run tests with coverage
run: |
pipenv run test-cov

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
17 changes: 17 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ bibtexparser = "*"
requests = "*"

[dev-packages]
pytest = "*"
pytest-cov = "*"
pytest-mock = "*"
black = "*"
flake8 = "*"
mypy = "*"
types-requests = "*"

[requires]
python_version = "3.12"

[scripts]
test = "pytest tests/ -v"
test-cov = "pytest tests/ --cov=retraction_check --cov-report=html --cov-report=term --cov-report=xml"
test-watch = "pytest tests/ -v --tb=short -x"
lint = "flake8 retraction_check/ tests/ --max-line-length=88 --extend-ignore=E203,W503"
format = "black retraction_check/ tests/"
format-check = "black --check retraction_check/ tests/"
type-check = "mypy retraction_check/"
check-all = "bash -c 'pipenv run format-check && pipenv run lint && pipenv run type-check && pipenv run test-cov'"
Loading