Skip to content

Commit

Permalink
Merge pull request #95 from Lightmatter/develop
Browse files Browse the repository at this point in the history
v0.1.2
  • Loading branch information
samamorgan authored Feb 28, 2024
2 parents a25c464 + 0c0eb5b commit 6142068
Show file tree
Hide file tree
Showing 54 changed files with 3,894 additions and 1,279 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Publish Python 🐍 package 📦 to PyPI

on:
push:
branches:
- master
workflow_dispatch:

jobs:
get-package-version:
name: Get ${{ github.ref_name }} package version
runs-on: ubuntu-latest
outputs:
package-version: ${{ steps.package-version.outputs.package-version }}
version-compairson: ${{ steps.semver.outputs.comparison-result}}
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Get package version
id: package-version
run: echo "package-version=v$(poetry version --short)" >> $GITHUB_OUTPUT

- name: Get release version
id: release-version
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}

- name: Analyze semver
id: semver
uses: madhead/semver-utils@latest
with:
lenient: false
version: ${{ steps.package-version.outputs.package-version }}
compare-to: ${{ steps.release-version.outputs.release }}

- name: Check pre-release
if: ${{ steps.semver.outputs.prerelease != '' }}
run: |
echo "Checking if version is a pre-release"
echo "::error::Skipping pre-release version: ${{ steps.package-version.outputs.package-version}}"
exit 1
deploy:
name: Deploy Python 🐍 distributions 📦 to PyPI
needs: [get-package-version]
runs-on: ubuntu-latest
if: ${{ needs.get-package-version.outputs.version-compairson != '=' }}

steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v3

- name: Build and publish to PyPI
uses: JRubics/poetry-publish@v1.13
with:
pypi_token: ${{ secrets.PYPI_API_TOKEN }}

- name: Create release ${{ needs.get-package-version.outputs.package-version }}
uses: ncipollo/release-action@v1
with:
commit: ${{ github.ref_name }}
tag: ${{ needs.get-package-version.outputs.package-version }}
generateReleaseNotes: true
artifacts: |
dist/*.whl
dist/*.tar.gz
77 changes: 77 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CI

on: [pull_request, workflow_dispatch]

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

jobs:
get-python-versions:
name: Get Python versions
runs-on: ubuntu-latest
outputs:
python-matrix: ${{ steps.get-python-versions-action.outputs.latest-python-versions }}
steps:
- name: Get Python version matrix
uses: snok/latest-python-versions@v1
id: get-python-versions-action
with:
min-version: 3.8

ci:
name: CI
needs: [get-python-versions]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJson(needs.get-python-versions.outputs.python-matrix) }}

steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load cached environment
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
id: poetry-install
run: poetry install --no-interaction --no-root

- name: Run pre-commit
run: poetry run pre-commit run --all-files

- name: Run Tests
run: |
poetry run pytest \
--junitxml=pytest.xml \
--cov-report=term-missing:skip-covered \
--cov=welkin | tee pytest-coverage.txt
- name: Add coverage comment
uses: MishaKav/pytest-coverage-comment@main
continue-on-error: true
with:
pytest-coverage-path: ./pytest-coverage.txt
junitxml-path: ./pytest.xml
report-only-changed-files: true
title: Coverage Report (Python ${{ matrix.python-version }})
unique-id-for-comment: ${{ matrix.python-version }}
remove-link-from-badge: true
26 changes: 26 additions & 0 deletions .github/workflows/pre-commit-autoupdate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Pre-commit auto-update

on:
# every day at midnight
schedule:
- cron: "0 0 * * *"
# on demand
workflow_dispatch:

jobs:
auto-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2

- uses: browniebroke/pre-commit-autoupdate-action@main

- uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: update/pre-commit-hooks
title: Update pre-commit hooks
commit-message: "chore: update pre-commit hooks"
body: Update versions of pre-commit hooks to latest version.
18 changes: 0 additions & 18 deletions .github/workflows/publish.yaml

This file was deleted.

56 changes: 0 additions & 56 deletions .github/workflows/test.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
pytest-coverage.txt
pytest.xml

# Translations
*.mo
Expand Down
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
args: [--unsafe]
- id: debug-statements
- id: mixed-line-ending

## Python
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
types: [python]

- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
types: [python]
10 changes: 5 additions & 5 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
version: 2

build:
os: ubuntu-20.04
os: ubuntu-22.04
tools:
python: "3"
python: "3.8"
jobs:
post_install:
post_create_environment:
- pip install poetry
- poetry config virtualenvs.create false
- poetry install --with docs
post_install:
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install

sphinx:
configuration: docs/conf.py
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
}
},
"editor.formatOnSave": true,
Expand Down
Loading

0 comments on commit 6142068

Please sign in to comment.