Skip to content

Commit

Permalink
initial github project setup
Browse files Browse the repository at this point in the history
  • Loading branch information
varisd committed Jun 24, 2024
1 parent 326fa54 commit 25f686b
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build and upload to PyPI

on:
push:
release:
types:
- published

jobs:
run_tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3

- name: Install
run: python3 -m pip install .

- name: Run runtime pytest
run: pytest tests

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3

- name: Set version number
if: startsWith(github.ref, 'refs/tags/v')
run: echo "VERSION = \"${GITHUB_REF_NAME:1}\"" > opuscleaner/__about__.py

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
name: sdist
path: dist/opuscleaner-*.tar.gz

build_wheels:
name: Build wheels
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3

- name: Set version number
if: startsWith(github.ref, 'refs/tags/v')
run: echo "VERSION = \"${GITHUB_REF_NAME:1}\"" > opuscleaner/__about__.py

- name: Build wheels
run: python -m pip wheel -w wheelhouse .

- uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/opuscleaner-*.whl

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
path: dist

- uses: actions/download-artifact@v3
with:
name: sdist
path: dist

- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
44 changes: 44 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Testing (CI/CD)

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

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip

- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Install requirements
run: |
python -m pip install --upgrade pip setuptools
pip install pre-commit ruff pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with pre-commit
run: pre-commit run --all-files

- name: Test with pytest
run: pytest tests/
78 changes: 78 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[build-system]
requires = ["hatchling", "hatch-requirements-txt"]
build-backend = "hatchling.build"

[project]
name = "opuspocus"
description = "Modular NLP pipeline manager."
readme = "README.md"
requires-python = ">=3.7"
license = "MIT"
keywords = ["OPUS", "HPLT", "pipeline manager"]
authors = [
{ name = "Dušan Variš", email = "[email protected]" },
]
classifiers = [
"Development Status :: 3 - Alpha",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dynamic = [
"version",
"dependencies",
"optional-dependencies"
]

[project.scripts]
opuspocus = "go:main_cli"

[project.urls]
Documentation = "https://github.com/hplt-project/opuspocus#readme"
Issues = "https://github.com/hplt-project/opuspocus/issues"
Repository = "https://github.com/hplt-project/OpusPocus.git"

[tool.hatch.version]
path = "opuspocus/__about__.py"

[tool.hatch.envs.default]
dependencies = [
"pytest",
"pytest-cov",
]
[tool.hatch.envs.default.scripts]
cov = "pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=opuspocus --cov=tests {args}"
no-cov = "cov --no-cov {args}"

[[tool.hatch.envs.test.matrix]]
python = ["37", "38", "39", "310", "311"]

[tool.hatch.build]
include = [
"/opuspocus",
]

[tool.hatch.metadata.hooks.requirements_txt]
files = ["requirements.txt"]

[tool.hatch.metadata.hooks.requirements_txt.optional-dependencies]
all = ["requirements-all.txt"]

[tool.coverage.run]
branch = true
parallel = true
omit = [
"opuspocus/__about__.py",
]

[tool.coverage.report]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]

0 comments on commit 25f686b

Please sign in to comment.