Skip to content

Commit

Permalink
feat: Poetry rework (#19)
Browse files Browse the repository at this point in the history
* feat: initial commit of move to poetry

* fix: fix all ruff issues

Also splits the INPUTS dict into its own file that has line length
ignored

* docs: automated doc update

* fix: fix pre-commit and ci

* fix: update action.yml and remove old integration

* ci: move codeql to run on main only

* ci: update noxfile

* docs: doc cleanup

* docs: automated doc update
  • Loading branch information
andrewthetechie authored May 21, 2023
1 parent 82d2207 commit 2f41b7b
Show file tree
Hide file tree
Showing 39 changed files with 2,444 additions and 280 deletions.
121 changes: 109 additions & 12 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,114 @@
.mypy_cache/
/.coverage
/.coverage.*


# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
/.nox/
/.python-version
/.pytype/
/dist/
/docs/_build/
/src/*.egg-info/
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
.ruff_cache/

# Translations
*.mo
*.pot

# Sphinx documentation
docs/
# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Pycache
__pycache__/
.idea
requirements-dev.txt

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

Docker/Dockerfile
Docker/ActionDockerfile.j2
noxfile.py
action.yml
.prettierignore
.pre-commit-config.yaml
.git
.github
.gitignore
tests/

Makefile
DEVELOPER.md
LICENSE
README.md
.pre-commit-config.yaml
10 changes: 0 additions & 10 deletions .flake8

This file was deleted.

2 changes: 1 addition & 1 deletion .github/scripts/replace_inputs.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

mytmpdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
export INPUT_FILE="repo_manager/utils/__init__.py"
export INPUT_FILE="repo_manager/utils/_inputs.py"
export REPLACEMENT=$(python .github/scripts/generate_inputs.py)

NEW_INIT=$(.github/scripts/replace.sed $INPUT_FILE | envsubst)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
name: Integration Test
# Tests athe github action on each push
name: Action Integration Test
on:
push:
jobs:
integration-testing:
name: Integration Testing
action-integration-testing:
name: Action Integration Testing
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Copy in Dockerfile
run: cp Docker/Dockerfile Dockerfile
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Update action.yml to use dockerfile
uses: rmeneely/update-yaml@v1
with:
infile: action.yml
varlist: "runs.image=Dockerfile"
- name: Test action
id: test-action
# test with the local checkout of the action
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: "CodeQL"
on:
push:
branches:
- main
schedule:
- cron: "0 0 * * 1"
workflow_dispatch:
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/lint.yml

This file was deleted.

110 changes: 110 additions & 0 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Python CI

on:
- push

jobs:
python-ci:
name: ${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { python: "3.11", os: "ubuntu-latest", session: "pre-commit" }
- { python: "3.11", os: "ubuntu-latest", session: "safety" }
# - { python: "3.11", os: "ubuntu-latest", session: "mypy" }
- { python: "3.11", os: "ubuntu-latest", session: "tests" }

env:
NOXSESSION: ${{ matrix.session }}
FORCE_COLOR: "1"
PRE_COMMIT_COLOR: "always"

steps:
- name: Check out the repository
uses: actions/[email protected]

- name: Set up Python ${{ matrix.python }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python }}

- name: Upgrade pip
run: |
pip install --constraint=package-requirements.txt pip
pip --version
- name: Upgrade pip in virtual environments
shell: python
run: |
import os
import pip
with open(os.environ["GITHUB_ENV"], mode="a") as io:
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
- name: Install package-requirements
run: |
pip install --upgrade -r package-requirements.txt
poetry --version
nox --version
- name: Compute pre-commit cache key
if: matrix.session == 'pre-commit'
id: pre-commit-cache
shell: python
run: |
import hashlib
import sys
import os
python = "py{}.{}".format(*sys.version_info[:2])
payload = sys.version.encode() + sys.executable.encode()
digest = hashlib.sha256(payload).hexdigest()
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
fh.write(f"result={result}\n")
- name: Restore pre-commit cache
uses: actions/[email protected]
if: matrix.session == 'pre-commit'
with:
path: ~/.cache/pre-commit
key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
${{ steps.pre-commit-cache.outputs.result }}-
- name: Run Nox
run: |
nox --force-color --python=${{ matrix.python }}
- name: Upload coverage data
if: always() && matrix.session == 'tests'
uses: "actions/[email protected]"
with:
name: coverage-data
path: ".coverage.*"

- name: Upload documentation
if: matrix.session == 'docs-build'
uses: actions/[email protected]
with:
name: docs
path: docs/_build

coverage:
runs-on: ubuntu-latest
needs: python-ci
steps:
- name: Download coverage data
uses: actions/[email protected]
with:
name: coverage-data

- name: Upload coverage report
uses: codecov/[email protected]
with:
files: .coverage.xml
verbose: true
54 changes: 54 additions & 0 deletions .github/workflows/release-docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Runs after release-please creates a new release
# Builds and pushes the docker images for the release
name: Release Docker Images
on:
release:
types: [released]

jobs:
build-and-push-dockerimage:
name: Buld and push dockerimage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.THIS_PAT }}
- name: Docker metadata
uses: docker/metadata-action@v4
id: meta
with:
images: |
${{ github.repository }}
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ github.ref_name }}
# minimal (short sha)
type=sha,prefix=
# full length sha
type=sha,format=long,prefix=
- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#registry-cache
cache-from: type=gha
cache-to: type=gha,mode=max
14 changes: 14 additions & 0 deletions .github/workflows/release-major-version-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Updates major version tag for GHA ease of use
name: Update Major Version Tag

on:
push:
tags:
- "v*"

jobs:
update-majorver:
name: Update Major Version Tag
runs-on: ubuntu-latest
steps:
- uses: nowactions/update-majorver@v1
Loading

0 comments on commit 2f41b7b

Please sign in to comment.