Skip to content

Commit

Permalink
Modernize Package
Browse files Browse the repository at this point in the history
  • Loading branch information
samamorgan committed Mar 18, 2024
1 parent c2aa54c commit e37d153
Show file tree
Hide file tree
Showing 66 changed files with 2,866 additions and 1,473 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/build.yml

This file was deleted.

78 changes: 78 additions & 0 deletions .github/workflows/cd.yml
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/[email protected]
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
79 changes: 79 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
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
echo "django_version=$(poetry run django-admin --version)" >> $GITHUB_OUTPUT
- name: Run pre-commit
run: poetry run pre-commit run --all-files

- name: Run Tests (Django ${{ steps.poetry-install.outputs.django_version }})
run: |
poetry run pytest \
--junitxml=pytest.xml \
--cov-report=term-missing:skip-covered \
--cov=easyaudit | 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
unique-id-for-comment: ${{ matrix.python-version }}
remove-link-from-badge: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ celerybeat-schedule
.env

# virtualenv
.venv/
venv/
ENV/

Expand All @@ -87,3 +88,6 @@ ENV/
# Rope project settings
.ropeproject
.idea

# DB
db.sqlite3
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
hooks:
- id: ruff
- id: ruff-format

- repo: https://github.com/djlint/djLint
rev: v1.34.1
hooks:
- id: djlint-reformat-django
- id: djlint-django
49 changes: 0 additions & 49 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
Loading

0 comments on commit e37d153

Please sign in to comment.