Skip to content

Commit 2f41b7b

Browse files
feat: Poetry rework (#19)
* 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
1 parent 82d2207 commit 2f41b7b

39 files changed

+2444
-280
lines changed

.dockerignore

Lines changed: 109 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,114 @@
1-
.mypy_cache/
2-
/.coverage
3-
/.coverage.*
1+
2+
3+
# C extensions
4+
*.so
5+
6+
# Distribution / packaging
7+
.Python
8+
build/
9+
develop-eggs/
10+
dist/
11+
downloads/
12+
eggs/
13+
.eggs/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
pip-wheel-metadata/
20+
share/python-wheels/
21+
*.egg-info/
22+
.installed.cfg
23+
*.egg
24+
MANIFEST
25+
26+
# PyInstaller
27+
# Usually these files are written by a python script from a template
28+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
29+
*.manifest
30+
*.spec
31+
32+
# Installer logs
33+
pip-log.txt
34+
pip-delete-this-directory.txt
35+
36+
# Unit test / coverage reports
37+
htmlcov/
38+
.tox/
39+
.nox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
444
coverage.xml
5-
/.nox/
6-
/.python-version
7-
/.pytype/
8-
/dist/
9-
/docs/_build/
10-
/src/*.egg-info/
45+
*.cover
46+
*.py,cover
47+
.hypothesis/
48+
.pytest_cache/
49+
.ruff_cache/
50+
51+
# Translations
52+
*.mo
53+
*.pot
54+
55+
# Sphinx documentation
56+
docs/
57+
# PyBuilder
58+
target/
59+
60+
# Jupyter Notebook
61+
.ipynb_checkpoints
62+
63+
# IPython
64+
profile_default/
65+
ipython_config.py
66+
67+
# pyenv
68+
.python-version
69+
70+
# pipenv
71+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
72+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
73+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
74+
# install all needed dependencies.
75+
#Pipfile.lock
76+
77+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
78+
__pypackages__/
79+
80+
# Pycache
1181
__pycache__/
12-
.idea
13-
requirements-dev.txt
82+
83+
# Environments
84+
.env
85+
.venv
86+
env/
87+
venv/
88+
ENV/
89+
env.bak/
90+
venv.bak/
91+
92+
# mypy
93+
.mypy_cache/
94+
.dmypy.json
95+
dmypy.json
96+
97+
# Pyre type checker
98+
.pyre/
99+
100+
Docker/Dockerfile
101+
Docker/ActionDockerfile.j2
102+
noxfile.py
103+
action.yml
104+
.prettierignore
105+
.pre-commit-config.yaml
106+
.git
107+
.github
108+
.gitignore
109+
tests/
110+
14111
Makefile
112+
DEVELOPER.md
15113
LICENSE
16-
README.md
17114
.pre-commit-config.yaml

.flake8

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/scripts/replace_inputs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

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

77
NEW_INIT=$(.github/scripts/replace.sed $INPUT_FILE | envsubst)

.github/workflows/integration.yml renamed to .github/workflows/action-integration.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
name: Integration Test
1+
# Tests athe github action on each push
2+
name: Action Integration Test
23
on:
34
push:
45
jobs:
5-
integration-testing:
6-
name: Integration Testing
6+
action-integration-testing:
7+
name: Action Integration Testing
78
runs-on: ubuntu-latest
89
steps:
910
- uses: actions/checkout@v3
1011
name: Checkout
11-
with:
12-
token: ${{ secrets.GITHUB_TOKEN }}
13-
- name: Copy in Dockerfile
14-
run: cp Docker/Dockerfile Dockerfile
1512
- name: Set up Docker Buildx
1613
uses: docker/setup-buildx-action@v2
14+
- name: Update action.yml to use dockerfile
15+
uses: rmeneely/update-yaml@v1
16+
with:
17+
infile: action.yml
18+
varlist: "runs.image=Dockerfile"
1719
- name: Test action
1820
id: test-action
1921
# test with the local checkout of the action

.github/workflows/codeql.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: "CodeQL"
22
on:
33
push:
4+
branches:
5+
- main
46
schedule:
57
- cron: "0 0 * * 1"
68
workflow_dispatch:

.github/workflows/lint.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/python-ci.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Python CI
2+
3+
on:
4+
- push
5+
6+
jobs:
7+
python-ci:
8+
name: ${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }}
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
include:
14+
- { python: "3.11", os: "ubuntu-latest", session: "pre-commit" }
15+
- { python: "3.11", os: "ubuntu-latest", session: "safety" }
16+
# - { python: "3.11", os: "ubuntu-latest", session: "mypy" }
17+
- { python: "3.11", os: "ubuntu-latest", session: "tests" }
18+
19+
env:
20+
NOXSESSION: ${{ matrix.session }}
21+
FORCE_COLOR: "1"
22+
PRE_COMMIT_COLOR: "always"
23+
24+
steps:
25+
- name: Check out the repository
26+
uses: actions/[email protected]
27+
28+
- name: Set up Python ${{ matrix.python }}
29+
uses: actions/[email protected]
30+
with:
31+
python-version: ${{ matrix.python }}
32+
33+
- name: Upgrade pip
34+
run: |
35+
pip install --constraint=package-requirements.txt pip
36+
pip --version
37+
38+
- name: Upgrade pip in virtual environments
39+
shell: python
40+
run: |
41+
import os
42+
import pip
43+
44+
with open(os.environ["GITHUB_ENV"], mode="a") as io:
45+
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
46+
47+
- name: Install package-requirements
48+
run: |
49+
pip install --upgrade -r package-requirements.txt
50+
poetry --version
51+
nox --version
52+
53+
- name: Compute pre-commit cache key
54+
if: matrix.session == 'pre-commit'
55+
id: pre-commit-cache
56+
shell: python
57+
run: |
58+
import hashlib
59+
import sys
60+
import os
61+
62+
python = "py{}.{}".format(*sys.version_info[:2])
63+
payload = sys.version.encode() + sys.executable.encode()
64+
digest = hashlib.sha256(payload).hexdigest()
65+
result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])
66+
67+
with open(os.environ['GITHUB_OUTPUT'], 'a') as fh:
68+
fh.write(f"result={result}\n")
69+
70+
- name: Restore pre-commit cache
71+
uses: actions/[email protected]
72+
if: matrix.session == 'pre-commit'
73+
with:
74+
path: ~/.cache/pre-commit
75+
key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
76+
restore-keys: |
77+
${{ steps.pre-commit-cache.outputs.result }}-
78+
79+
- name: Run Nox
80+
run: |
81+
nox --force-color --python=${{ matrix.python }}
82+
83+
- name: Upload coverage data
84+
if: always() && matrix.session == 'tests'
85+
uses: "actions/[email protected]"
86+
with:
87+
name: coverage-data
88+
path: ".coverage.*"
89+
90+
- name: Upload documentation
91+
if: matrix.session == 'docs-build'
92+
uses: actions/[email protected]
93+
with:
94+
name: docs
95+
path: docs/_build
96+
97+
coverage:
98+
runs-on: ubuntu-latest
99+
needs: python-ci
100+
steps:
101+
- name: Download coverage data
102+
uses: actions/[email protected]
103+
with:
104+
name: coverage-data
105+
106+
- name: Upload coverage report
107+
uses: codecov/[email protected]
108+
with:
109+
files: .coverage.xml
110+
verbose: true
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Runs after release-please creates a new release
2+
# Builds and pushes the docker images for the release
3+
name: Release Docker Images
4+
on:
5+
release:
6+
types: [released]
7+
8+
jobs:
9+
build-and-push-dockerimage:
10+
name: Buld and push dockerimage
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up QEMU
15+
uses: docker/setup-qemu-action@v2
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v2
18+
- name: Login to DockerHub
19+
uses: docker/login-action@v2
20+
with:
21+
username: ${{ secrets.DOCKERHUB_USERNAME }}
22+
password: ${{ secrets.DOCKERHUB_TOKEN }}
23+
- name: Log in to the Container registry
24+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.THIS_PAT }}
29+
- name: Docker metadata
30+
uses: docker/metadata-action@v4
31+
id: meta
32+
with:
33+
images: |
34+
${{ github.repository }}
35+
ghcr.io/${{ github.repository }}
36+
tags: |
37+
type=raw,value=${{ github.ref_name }}
38+
# minimal (short sha)
39+
type=sha,prefix=
40+
# full length sha
41+
type=sha,format=long,prefix=
42+
- name: Build and push
43+
id: docker_build
44+
uses: docker/build-push-action@v3
45+
with:
46+
context: .
47+
file: Dockerfile
48+
push: true
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
platforms: linux/amd64,linux/arm64
52+
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#registry-cache
53+
cache-from: type=gha
54+
cache-to: type=gha,mode=max
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Updates major version tag for GHA ease of use
2+
name: Update Major Version Tag
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
jobs:
10+
update-majorver:
11+
name: Update Major Version Tag
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: nowactions/update-majorver@v1

0 commit comments

Comments
 (0)