Skip to content

Commit b787a5b

Browse files
authored
Feat: reimplement in Python (#2)
2 parents 391abb6 + a33caa6 commit b787a5b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2002
-405
lines changed

.devcontainer/Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM python:3.11
2+
3+
RUN apt-get update && apt-get -y install swig libpcsclite-dev
4+
5+
ENV PYTHONDONTWRITEBYTECODE=1 \
6+
PYTHONUNBUFFERED=1 \
7+
USER=compiler
8+
9+
RUN useradd --create-home --shell /bin/bash $USER && \
10+
chown -R $USER /home/$USER
11+
12+
USER $USER
13+
ENV PATH "$PATH:/home/$USER/.local/bin"
14+
WORKDIR /home/$USER/admin
15+
16+
RUN python -m pip install --upgrade pip
17+
18+
COPY compiler_admin compiler_admin
19+
COPY pyproject.toml pyproject.toml
20+
RUN pip install -e .[dev,test]
21+
22+
# install pre-commit environments in throwaway Git repository
23+
# https://stackoverflow.com/a/68758943
24+
COPY .pre-commit-config.yaml .
25+
RUN git init . && \
26+
pre-commit install-hooks && \
27+
rm -rf .git
28+
29+
CMD ["sleep", "infinity"]

.devcontainer/devcontainer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "compilerla/admin",
3+
"dockerComposeFile": ["../compose.yaml"],
4+
"service": "dev",
5+
"workspaceFolder": "/home/compiler/admin",
6+
"customizations": {
7+
"vscode": {
8+
// Set *default* container specific settings.json values on container create.
9+
"settings": {
10+
"terminal.integrated.defaultProfile.linux": "bash",
11+
"terminal.integrated.profiles.linux": {
12+
"bash": {
13+
"path": "/bin/bash"
14+
}
15+
}
16+
},
17+
// Add the IDs of extensions you want installed when the container is created.
18+
"extensions": [
19+
"eamodio.gitlens",
20+
"esbenp.prettier-vscode",
21+
"mhutchie.git-graph",
22+
"ms-python.python",
23+
"ms-python.black-formatter",
24+
"ms-python.flake8",
25+
"tamasfe.even-better-toml"
26+
]
27+
}
28+
}
29+
}

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GYB-GMail-Backup-*
2+
*.csv

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 127

.github/dependabot.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "pip"
9+
directory: "/" # pyproject.toml
10+
schedule:
11+
interval: "daily"
12+
commit-message:
13+
prefix: "chore"
14+
include: "scope"
15+
labels:
16+
- "dependencies"
17+
- package-ecosystem: "github-actions"
18+
# Workflow files stored in the
19+
# default location of `.github/workflows`
20+
directory: "/"
21+
schedule:
22+
interval: "daily"
23+
commit-message:
24+
prefix: "chore"
25+
include: "scope"
26+
labels:
27+
- "dependencies"

.github/workflows/.python-version

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

.github/workflows/pytest.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Pytest
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
pytest:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out code
12+
uses: actions/checkout@v3
13+
14+
- name: Install system packages
15+
run: |
16+
sudo apt-get update -y
17+
sudo apt-get install -y swig libpcsclite-dev
18+
19+
- uses: actions/setup-python@v4
20+
with:
21+
python-version-file: .github/workflows/.python-version
22+
cache: pip
23+
cache-dependency-path: "**/pyproject.toml"
24+
25+
- name: Install Python dependencies
26+
run: pip install -e .[test]
27+
28+
- name: Run tests
29+
run: ./tests/run.sh
30+
31+
- name: Upload coverage report
32+
uses: actions/upload-artifact@v3
33+
with:
34+
name: coverage-report
35+
path: ./tests/coverage

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
GYB-GMail-Backup-*
1+
GYB-GMail-Backup-*/
2+
__pycache__
3+
.config
4+
.coverage
5+
.downloads
6+
.pytest_cache
27
*.csv
8+
*.egg-info

.pre-commit-config.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
ci:
2+
autofix_commit_msg: "chore(pre-commit): autofix run"
3+
autoupdate_commit_msg: "chore(pre-commit): autoupdate hooks"
4+
5+
repos:
6+
- repo: https://github.com/compilerla/conventional-pre-commit
7+
rev: v2.3.0
8+
hooks:
9+
- id: conventional-pre-commit
10+
stages: [commit-msg]
11+
12+
- repo: https://github.com/pre-commit/pre-commit-hooks
13+
rev: v4.4.0
14+
hooks:
15+
- id: trailing-whitespace
16+
- id: mixed-line-ending
17+
- id: end-of-file-fixer
18+
- id: check-yaml
19+
args: ["--unsafe"]
20+
- id: check-added-large-files
21+
22+
- repo: https://github.com/psf/black
23+
rev: 23.7.0
24+
hooks:
25+
- id: black
26+
types:
27+
- python
28+
29+
- repo: https://github.com/PyCQA/flake8
30+
rev: 6.1.0
31+
hooks:
32+
- id: flake8
33+
types:
34+
- python
35+
36+
- repo: https://github.com/pycqa/bandit
37+
rev: 1.7.5
38+
hooks:
39+
- id: bandit
40+
args: ["-ll"]
41+
files: .py$

.vscode/settings.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnSave": true,
4+
"files.encoding": "utf8",
5+
"files.eol": "\n",
6+
"files.insertFinalNewline": true,
7+
"files.trimFinalNewlines": true,
8+
"files.trimTrailingWhitespace": true,
9+
"[python]": {
10+
"editor.defaultFormatter": "ms-python.black-formatter"
11+
},
12+
"python.formatting.provider": "none",
13+
"python.languageServer": "Pylance",
14+
"python.linting.enabled": true,
15+
"python.linting.flake8Enabled": true,
16+
"python.testing.pytestArgs": ["tests"],
17+
"python.testing.pytestEnabled": true,
18+
"python.testing.unittestEnabled": false
19+
}

0 commit comments

Comments
 (0)