Skip to content

Commit 66eaa25

Browse files
committed
clean
1 parent 23ce0c8 commit 66eaa25

18 files changed

Lines changed: 398 additions & 159 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
name: CI
1+
name: ci
22

33
on:
44
pull_request: # Start the job on all PRs
5+
push:
6+
branches:
7+
- master
8+
- main
59

610
jobs:
711
precommit:
@@ -10,18 +14,14 @@ jobs:
1014
steps:
1115
- name: Checkout code
1216
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
1319

1420
- name: Set up Python
1521
uses: actions/setup-python@v4
1622
with:
1723
python-version: "3.10"
1824

19-
- name: Install Rust Toolchain
20-
uses: dtolnay/rust-toolchain@nightly
21-
22-
- name: Set shfmt version environment variable
23-
run: echo "SHFMT_VERSION=v3.7.0" >> $GITHUB_ENV
24-
2525
- name: Cache pip dependencies
2626
uses: actions/cache@v3
2727
with:
@@ -34,9 +34,8 @@ jobs:
3434
uses: actions/cache@v3
3535
with:
3636
path: /usr/local/bin/shfmt
37-
key: ${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
37+
key: ${{ runner.os }}-shfmt-
3838
restore-keys: |
39-
${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
4039
${{ runner.os }}-shfmt-
4140
4241
- name: Cache Pre-Commit environments
@@ -50,38 +49,15 @@ jobs:
5049
5150
- name: Install dependencies
5251
run: |
53-
python -m pip install pre-commit
54-
pre-commit install
55-
56-
- name: Install shfmt
57-
run: |
58-
SHFMT_VERSION=${{ env.SHFMT_VERSION }}
59-
SHFMT_BIN="shfmt_${SHFMT_VERSION}_linux_amd64"
60-
if [[ ! -f /usr/local/bin/shfmt ]]; then
61-
wget -O shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/${SHFMT_BIN}"
62-
chmod +x shfmt
63-
sudo mv shfmt /usr/local/bin/
64-
fi
65-
sudo apt-get install shellcheck
66-
rustup component add clippy
67-
rustup component add rustfmt
52+
make setuppc
6853
6954
- name: Run pre-commits
7055
env:
7156
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7257
run: |
73-
REPO_NAME=$(echo $GITHUB_REPOSITORY | sed 's/^.*\///')
74-
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
75-
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
76-
77-
git fetch
78-
CUR_SHA=$(git log --pretty=tformat:"%H" -n1 . | tail -n1)
58+
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
7959
80-
echo "Default branch is $DEFAULT_BRANCH"
81-
echo "Current SHA is $CUR_SHA"
60+
echo "Default branch = $DEFAULT_BRANCH"
61+
echo "Current SHA = ${{ github. sha }}"
8262
83-
if [[ $GITHUB_REF == "refs/heads/$DEFAULT_BRANCH" ]]; then
84-
pre-commit run --all
85-
else
86-
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref $CUR_SHA
87-
fi
63+
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref "${{ github. sha }}"

.vscode/extensions.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"recommendations": [
3+
"ms-python.python",
4+
"ms-python.vscode-pylance",
5+
"ms-python.isort",
6+
"ms-python.black-formatter",
7+
"ms-python.flake8"
8+
]
9+
}

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"[python]": {
3+
"editor.formatOnType": true,
4+
"editor.formatOnSave": true,
5+
"editor.defaultFormatter": "ms-python.black-formatter"
6+
},
7+
"flake8.args": ["--config=.ci/flake8.cfg"],
8+
"files.insertFinalNewline": true
9+
}

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cpa"
3-
version = "0.1.0"
3+
version = "0.1.5"
44
edition = "2021"
55

66
[dependencies]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ endif
2424

2525
.PHONY: reqtxt
2626
reqtxt:
27-
poetry export -f requirements.txt --output requirements.txt --without-hashes
27+
poetry export -f requirements.txt --output requirements.txt
2828

2929
.PHONY: pcao
3030
pcao:
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: ci
2+
3+
on:
4+
pull_request: # Start the job on all PRs
5+
push:
6+
branches:
7+
- master
8+
- main
9+
10+
jobs:
11+
precommit:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: "3.10"
24+
25+
- name: Cache pip dependencies
26+
uses: actions/cache@v3
27+
with:
28+
path: ~/.cache/pip
29+
key: ${{ runner.os }}-pip-
30+
restore-keys: |
31+
${{ runner.os }}-pip-
32+
33+
- name: Cache shfmt binary
34+
uses: actions/cache@v3
35+
with:
36+
path: /usr/local/bin/shfmt
37+
key: ${{ runner.os }}-shfmt-
38+
restore-keys: |
39+
${{ runner.os }}-shfmt-
40+
41+
- name: Cache Pre-Commit environments
42+
uses: actions/cache@v3
43+
with:
44+
path: ~/.cache/pre-commit
45+
key: ${{ runner.os }}-pc-${{ hashFiles('.pre-commit-config.yaml') }}
46+
restore-keys: |
47+
${{ runner.os }}-pc-${{ hashFiles('.pre-commit-config.yaml') }}
48+
${{ runner.os }}-pc-
49+
50+
- name: Install dependencies
51+
run: |
52+
make setuppc
53+
54+
- name: Run pre-commits
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
run: |
58+
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
59+
60+
echo "Default branch = $DEFAULT_BRANCH"
61+
echo "Current SHA = ${{ github. sha }}"
62+
63+
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref "${{ github. sha }}"

example/base/.gitignore

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

0 commit comments

Comments
 (0)