Skip to content

Commit fd50de6

Browse files
Create project structure. (#1)
2 parents 089e645 + a3b810c commit fd50de6

26 files changed

+711
-1
lines changed

.github/workflows/pull-request.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Verify
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
verify:
8+
name: Success
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout source
12+
uses: actions/checkout@v4
13+
14+
- name: Setup buildx
15+
uses: docker/setup-buildx-action@v3
16+
17+
- name: Build container image
18+
uses: docker/build-push-action@v5
19+
with:
20+
context: .
21+
file: Dockerfile
22+
load: true
23+
provenance: false
24+
push: false
25+
tags: github-bot-signed-commit:${{ github.sha }}
26+
target: verify
27+
28+
- name: Verify container image
29+
shell: bash
30+
run: |
31+
docker run --rm github-bot-signed-commit:${{ github.sha }}

.gitignore

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/#use-with-ide
110+
.pdm.toml
111+
112+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113+
__pypackages__/
114+
115+
# Celery stuff
116+
celerybeat-schedule
117+
celerybeat.pid
118+
119+
# SageMath parsed files
120+
*.sage.py
121+
122+
# Environments
123+
.env
124+
.venv
125+
env/
126+
venv/
127+
ENV/
128+
env.bak/
129+
venv.bak/
130+
131+
# Spyder project settings
132+
.spyderproject
133+
.spyproject
134+
135+
# Rope project settings
136+
.ropeproject
137+
138+
# mkdocs documentation
139+
/site
140+
141+
# mypy
142+
.mypy_cache/
143+
.dmypy.json
144+
dmypy.json
145+
146+
# Pyre type checker
147+
.pyre/
148+
149+
# pytype static type analyzer
150+
.pytype/
151+
152+
# Cython debug symbols
153+
cython_debug/
154+
155+
# PyCharm
156+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158+
# and can be added to the global gitignore or merged into this file. For a more nuclear
159+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160+
#.idea/
161+
162+
*.pem

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11

.version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
### Use an appropriate version of Python
2+
FROM python:3.12-slim-bullseye@sha256:832f8341da133d603b3141b57a55943e2fe00d431cbb89b8ca04925f3a798ee8 AS python
3+
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
6+
RUN apt-get -qq update -y && \
7+
apt-get -qq install -y git >/dev/null
8+
9+
### Install requirements
10+
FROM python AS requirements
11+
12+
COPY requirements.txt /opt/project/
13+
WORKDIR /opt/project
14+
RUN --mount=type=cache,target=/root/.cache \
15+
pip install --disable-pip-version-check --requirement requirements.txt
16+
17+
### Install source and its dependencies
18+
FROM requirements AS source
19+
20+
COPY pyproject.toml /opt/project/
21+
COPY src /opt/project/src
22+
23+
24+
### Define verify command
25+
FROM source AS verify
26+
27+
ENV CI=1
28+
29+
RUN --mount=type=cache,target=/root/.cache \
30+
pip install --quiet --disable-pip-version-check --editable .[style,types,test]
31+
COPY bin/verify* /opt/project/bin/
32+
33+
CMD ["/opt/project/bin/verify"]

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
# empty
1+
# Signed Commits for GitHub Bots
2+
3+
GitHub users can (and should) signed their commits using normal git operations; GitHub bots cannot
4+
because when they perform git operations, they do not have access to their signing key. GitHub
5+
ensures that commits created by bots through their API will be signed, but constructing these
6+
commits requires either managing lower level objects (trees, blobs) or using the GraphQL API,
7+
which has challenging ergonomics from the CLI and can be extremely slow (e.g. over an hour) when
8+
creating commits.
9+
10+
This project uses [GitPython](https://github.com/gitpython-developers/GitPython) to inspect a
11+
local commit and recreate it remotely using [PyGitHub](https://github.com/PyGithub/PyGithub).
12+
13+
14+
15+
## Docker
16+
17+
### Verification (CI)
18+
19+
1. Build:
20+
21+
```sh
22+
docker build -t verify --target verify .
23+
```
24+
25+
2. Verify:
26+
27+
```sh
28+
docker run -it --rm verify
29+
```

bin/build

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
PROJECT_ROOT=$(dirname $(dirname $(realpath $0)))
6+
7+
pushd ${PROJECT_ROOT} > /dev/null
8+
9+
if [ -z "${VIRTUAL_ENV}" ] && [ -r .venv ]; then
10+
source .venv/bin/activate
11+
fi
12+
13+
python -m build

bin/install

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
PROJECT_ROOT=$(dirname $(dirname $(realpath $0)))
6+
PROJECT_NAME=$(basename ${PROJECT_ROOT})
7+
8+
pushd ${PROJECT_ROOT} > /dev/null
9+
10+
# Installation defaults to using a local virtualenv (`.env`) but may use other tooling
11+
# (e.g. `virtualenvwrapper`) to externalize the installation location.
12+
13+
if [ -z "${VIRTUAL_ENV}" ]; then
14+
# Create a local virtualenv if one does not exist
15+
test -d .venv || python3 -m venv .venv --prompt ${PROJECT_NAME}
16+
source .venv/bin/activate
17+
fi
18+
19+
# We need wheel to install any binary packagess
20+
pip3 install --disable-pip-version-check wheel
21+
22+
# Install dependencies in editable mode
23+
pip3 install --disable-pip-version-check --editable '.[dist,style,test,types]'

bin/update-requirements

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash -eo pipefail
2+
3+
PROJECT_ROOT=$(dirname $(dirname $(realpath $0)))
4+
5+
pushd ${PROJECT_ROOT} > /dev/null
6+
7+
WORKDIR=$(mktemp -d)
8+
9+
trap "rm -rf ${WORKDIR}" EXIT
10+
11+
python3 -m venv ${WORKDIR}
12+
${WORKDIR}/bin/pip install --disable-pip-version-check --quiet --editable .
13+
${WORKDIR}/bin/pip freeze --disable-pip-version-check --quiet --exclude-editable > requirements.txt

bin/verify

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
PARENT=$(dirname $(realpath $0))
6+
7+
${PARENT}/verify-style
8+
${PARENT}/verify-types
9+
${PARENT}/verify-tests

0 commit comments

Comments
 (0)