Skip to content

Commit

Permalink
add just package, GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
fritz-astronomer committed Aug 26, 2024
1 parent 882bb7d commit e613c3d
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 4 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Check
on: [pull_request]
permissions:
contents: write
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- uses: extractions/setup-just@v1
- run: just install
- run: |
git fetch origin
pre-commit run --from-ref origin/${{ github.event.pull_request.base.ref }} --to-ref ${{ github.event.pull_request.head.sha }}
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.10", "3.11" ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- uses: extractions/setup-just@v1
- run: just install
- run: just test-with-coverage
- uses: codecov/codecov-action@v4
39 changes: 39 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy
on:
push:
tags:
- "v*.*.*"
workflow_dispatch: {}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- uses: extractions/setup-just@v1
- run: just install
- run: just build
- run: just package
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

release:
needs: build
runs-on: "ubuntu-latest"
steps:
- uses: actions/download-artifact@v4
- run: ls -R
- uses: softprops/action-gh-release@v1
with:
prerelease: true
generate_release_notes: true
files: |
dist/*
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
25 changes: 21 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
set dotenv-load := true
EXTRAS := "dev"
VERSION := `echo $(python -c 'from orbiter_translations import __version__; print(__version__)')`
PYTHON := `which python || which python3`

default:
@just --choose
Expand All @@ -12,7 +13,7 @@ help:

# Install project and python dependencies (incl. pre-commit) locally
install EDITABLE='':
pip install {{EDITABLE}} '.[{{EXTRAS}}]'
{{PYTHON}} -m pip install {{EDITABLE}} '.[{{EXTRAS}}]'

# Install pre-commit to local project
install-precommit: install
Expand All @@ -24,11 +25,11 @@ update-secrets:

# Run pytests with config from pyproject.toml
test:
pytest -c pyproject.toml
{{PYTHON}} -m pytest -c pyproject.toml

# Test and emit a coverage report
test-with-coverage:
pytest -c pyproject.toml --cov=./ --cov-report=xml
{{PYTHON}} -m pytest -c pyproject.toml --cov=./ --cov-report=xml

# Run ruff and black (normally done with pre-commit)
lint:
Expand All @@ -53,4 +54,20 @@ deploy: deploy-tag

# Build the project
build: install clean
python -m build
{{PYTHON}} -m build

# [DO NOT RUN - RUN VIA CICD] Build the project as a .pyz, so it and it's dependencies can be installed and imported with the orbiter binary
package:
# https://docs.python.org/3/library/zipapp.html#creating-standalone-applications-with-zipapp
mkdir -p build
{{PYTHON}} -m pip install '.' --target build
cp -r orbiter_translations build
rm -rf build/*.dist-info/*
rmdir build/*.dist-info
{{PYTHON}} -m zipapp \
--compress \
--main orbiter_translations.__main__:main \
--python "/usr/bin/env python3" \
--output dist/orbiter_translations.pyz \
build

0 comments on commit e613c3d

Please sign in to comment.