Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update packaging tools #51

Merged
merged 4 commits into from
Feb 7, 2024
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
49 changes: 27 additions & 22 deletions .github/workflows/distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,47 @@ name: distribute

on:
workflow_dispatch:
pull_request:
push:
tags: "v*"
branches:
- main
release:
types:
- published

jobs:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FORCE_COLOR: 3

jobs:
dist:
name: Distribution build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build SDist and wheel
run: pipx run build

- uses: actions/upload-artifact@v4
with:
path: dist/*
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check metadata
run: pipx run twine check dist/*
- uses: hynek/build-and-inspect-python-package@v2

publish:
needs: [dist]
name: Publish to PyPI
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'

steps:
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist

- uses: pypa/[email protected]
with:
password: ${{ secrets.pypi_password }}
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist

- uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'release' && github.event.action == 'published'
53 changes: 29 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,78 @@
name: legend-geom-optics
name: legendoptics

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- 'releases/**'
pull_request:
release:
- "releases/**"

jobs:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FORCE_COLOR: 3

jobs:
build-and-test:
name: Test legendoptics with Python
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11']
python-version: ["3.9", "3.10", "3.11"]
os: [ubuntu-latest, macOS-latest]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Get dependencies and install the legendoptics
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install --upgrade .[test]
- name: Run unit tests
run: |
pytest
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Get dependencies and install legendoptics
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install --upgrade .[test]
- name: Run unit tests
run: |
python -m pytest

test-coverage:
name: Calculate and upload test coverage
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: "3.10"

- name: Generate Report
run: |
python -m pip install --upgrade pip wheel setuptools
python -m pip install --upgrade .[test]
pytest --cov=legendoptics --cov-report=xml
python -m pytest --cov=legendoptics --cov-report=xml
- name: Upload Coverage to codecov.io
uses: codecov/codecov-action@v4

build-docs:
name: Build documentation
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: "3.10"
- name: Setup build environment
run: |
sudo apt-get install -y pandoc
python -m pip install --upgrade pip wheel setuptools
python -m pip install --upgrade .[docs]
python -m pip install --upgrade .[all]
- name: Build docs for current ref
run: |
cd docs
Expand Down
166 changes: 73 additions & 93 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,108 +1,88 @@
ci:
autoupdate_commit_msg: "chore: update pre-commit hooks"
autoupdate_schedule: "monthly"
autoupdate_schedule: "quarterly"
autofix_commit_msg: "style: pre-commit fixes"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: check-json
- id: check-toml
- id: check-docstring-first
- id: debug-statements
- id: end-of-file-fixer
- id: forbid-new-submodules
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==23.*]

- repo: https://github.com/asottile/setup-cfg-fmt
rev: "v2.5.0"
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: forbid-new-submodules
- id: mixed-line-ending
- id: name-tests-test
args: ["--pytest-test-first"]
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/PyCQA/isort
rev: "5.13.2"
hooks:
- id: isort
- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/asottile/pyupgrade
rev: "v3.15.0"
hooks:
- id: pyupgrade
args: ["--py36-plus"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
types_or: [yaml, markdown, json]
args: [--prose-wrap=always]

- repo: https://github.com/psf/black
rev: "24.1.1"
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.2.1"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.8.0"
hooks:
- id: mypy
files: src
stages: [manual]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.8.0"
hooks:
- id: mypy
files: src|tests
stages: [manual]
additional_dependencies:
- pytest

- repo: https://github.com/hadialqattan/pycln
rev: "v2.4.0"
hooks:
- id: pycln
args: ["--all"]
- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
hooks:
- id: codespell

- repo: https://github.com/PyCQA/flake8
rev: "7.0.0"
hooks:
- id: flake8
additional_dependencies: [
flake8-bugbear,
flake8-print,
flake8-docstrings,
pep8-naming
]
args: ["--docstring-convention", "numpy"] # or google, change me
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.9.0.6"
hooks:
- id: shellcheck

- repo: https://github.com/kynan/nbstripout
rev: "0.7.1"
hooks:
- id: nbstripout
args: ["--strip-empty-cells",
"--extra-keys", "metadata.kernelspec metadata.language_info"]
- repo: local
hooks:
- id: disallow-caps
name: Disallow improper capitalization
language: pygrep
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
exclude: .pre-commit-config.yaml

- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
hooks:
- id: check-manifest
stages: [manual]
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.16
hooks:
- id: validate-pyproject

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
hooks:
- id: codespell
args: ["-L", "nd,unparseable,compiletime,tre"]

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: "v0.9.0.6"
hooks:
- id: shellcheck

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: python-no-log-warn
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
types_or: [json]
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.0
hooks:
- id: check-dependabot
- id: check-github-workflows
- id: check-readthedocs
9 changes: 2 additions & 7 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ build:
jobs:
pre_build:
- rm -rf docs/source/api
- sphinx-apidoc
--private
--module-first
--force
--output-dir docs/source/api
src/legendoptics
src/legendoptics/_version.py
- sphinx-apidoc --private --module-first --force --output-dir
docs/source/api src/legendoptics src/legendoptics/_version.py

python:
install:
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@
![License](https://img.shields.io/github/license/legend-exp/legend-pygeom-optics)
[![Read the Docs](https://img.shields.io/readthedocs/legend-pygeom-optics?logo=readthedocs)](https://legend-pygeom-optics.readthedocs.io)

This package contains a collection of optical properties of materials used in the LEGEND experiment.
This package contains a collection of optical properties of materials used in
the LEGEND experiment.

As a common interface, each optical property gets its own defining function in the material's module. Those functions can be used directly to just retrieve the value(s) of the property. Most property definitions contain unit information via the `pint` package. For a full list of defined properties refer to the [package documentation](https://legend-pygeom-optics.readthedocs.io).
As a common interface, each optical property gets its own defining function in
the material's module. Those functions can be used directly to just retrieve the
value(s) of the property. Most property definitions contain unit information via
the `pint` package. For a full list of defined properties refer to the
[package documentation](https://legend-pygeom-optics.readthedocs.io).

To ease the use in Geant4-based simulations, every module also provides functions to be used with [`pyg4ometry`](https://pyg4ometry.readthedocs.io).
To ease the use in Geant4-based simulations, every module also provides
functions to be used with [`pyg4ometry`](https://pyg4ometry.readthedocs.io).
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ coverage:
patch: false

github_checks:
annotations: false
annotations: false

ignore:
- tests
Expand Down
Loading
Loading