Skip to content

Commit 29a4583

Browse files
committed
clean
1 parent ea0fb0d commit 29a4583

10 files changed

Lines changed: 132 additions & 45 deletions

File tree

.github/workflows/integration.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: integration
2+
3+
on:
4+
pull_request: # Start the job on all PRs
5+
push:
6+
branches:
7+
- master
8+
- main
9+
10+
jobs:
11+
integration:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Install Rust Toolchain
19+
uses: dtolnay/rust-toolchain@nightly
20+
21+
- name: Install dependencies
22+
run: |
23+
sh ./test.sh

example/base/.github/workflows/ci.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ jobs:
5555
env:
5656
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757
run: |
58-
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
58+
REPO_NAME=$(echo $GITHUB_REPOSITORY | sed 's/^.*\///')
59+
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
60+
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
5961
6062
echo "Default branch = $DEFAULT_BRANCH"
6163
echo "Current SHA = ${{ github. sha }}"

example/python/.ci/flake8.cfg

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
[flake8]
2+
ignore =
3+
# C901, # function is too complex. Ignored because max-complexity is set.
4+
D100,
5+
# Missing docstring in public module.
6+
D101,
7+
# Missing docstring in public class.
8+
D102,
9+
# Missing docstring in public method.
10+
D103,
11+
# Missing docstring in public function.
12+
D104,
13+
# Missing docstring in public package.
14+
D105,
15+
# Missing docstring in magic method.
16+
D107,
17+
# Missing docstring in __init__.
18+
D205,
19+
# 1 blank line required between summary line and description.
20+
D400,
21+
# First line should end with a period.
22+
E203,
23+
# whitespace before ':'. Conflicts with how Black formats slicing.
24+
E231,
25+
# missing whitespace after ',', ';', or ':'. Conflicts with Black.
26+
E266,
27+
# too many leading '#' for block comment.
28+
E402,
29+
# module level import not at top of file.
30+
E501,
31+
# line too long (82 > 79 characters). Ignored because max-line-length is set.
32+
F841,
33+
# local variable is assigned to but never used.
34+
I100,
35+
# Import statements are in the wrong order.
36+
I201,
37+
# Missing newline between import groups.
38+
I202,
39+
# Additional newline in a group of imports.
40+
W503
41+
# line break before binary operator. This is no longer PEP 8 compliant.
42+
43+
exclude =
44+
.cache,
45+
.coverage.*,
46+
.env,
47+
.git,
48+
.github,
49+
.gradle,
50+
.hg,
51+
.mypy_cache,
52+
.pytest_cache,
53+
.svn,
54+
.tox,
55+
.venv,
56+
.vscode,
57+
*__pycache__,
58+
*.egg-info,
59+
*.pyc,
60+
build,
61+
dist,
62+
htmlcov.*,
63+
64+
# List of application-specific import names.
65+
application-import-names = flake8
66+
# Import statement format style.
67+
import-order-style = google
68+
# The maximum McCabe complexity allowed.
69+
max-complexity = 18
70+
# The maximum allowed line length.
71+
max-line-length = 120
72+
# per-file-ignores = # Per-file-ignores setting can be used to ignore specific errors in specific files.

example/python/.ci/prettier.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"bracketSpacing": true,
3+
"singleQuote": false,
4+
"useTabs": false,
5+
"tabWidth": 2,
6+
"trailingComma": "all"
7+
}
Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: CI
1+
name: ci
22

33
on:
44
pull_request: # Start the job on all PRs
5-
branches: [master, main]
6-
types: [synchronize, opened, reopened, ready_for_review]
7-
push: # Start the job on all main branch push
8-
branches: [master, main]
5+
push:
6+
branches:
7+
- master
8+
- main
99

1010
jobs:
1111
precommit:
@@ -14,15 +14,14 @@ jobs:
1414
steps:
1515
- name: Checkout code
1616
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
1719

1820
- name: Set up Python
1921
uses: actions/setup-python@v4
2022
with:
2123
python-version: "3.10"
2224

23-
- name: Set shfmt version environment variable
24-
run: echo "SHFMT_VERSION=v3.7.0" >> $GITHUB_ENV
25-
2625
- name: Cache pip dependencies
2726
uses: actions/cache@v3
2827
with:
@@ -35,9 +34,8 @@ jobs:
3534
uses: actions/cache@v3
3635
with:
3736
path: /usr/local/bin/shfmt
38-
key: ${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
37+
key: ${{ runner.os }}-shfmt-
3938
restore-keys: |
40-
${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
4139
${{ runner.os }}-shfmt-
4240
4341
- name: Cache Pre-Commit environments
@@ -51,19 +49,7 @@ jobs:
5149
5250
- name: Install dependencies
5351
run: |
54-
python -m pip install pre-commit
55-
pre-commit install
56-
57-
- name: Install shfmt
58-
run: |
59-
SHFMT_VERSION=${{ env.SHFMT_VERSION }}
60-
SHFMT_BIN="shfmt_${SHFMT_VERSION}_linux_amd64"
61-
if [[ ! -f /usr/local/bin/shfmt ]]; then
62-
wget -O shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/${SHFMT_BIN}"
63-
chmod +x shfmt
64-
sudo mv shfmt /usr/local/bin/
65-
fi
66-
sudo apt-get install shellcheck
52+
make setuppc
6753
6854
- name: Run pre-commits
6955
env:
@@ -73,14 +59,7 @@ jobs:
7359
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
7460
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
7561
76-
git fetch
77-
CUR_SHA=$(git log --pretty=tformat:"%H" -n1 . | tail -n1)
78-
79-
echo "Default branch is $DEFAULT_BRANCH"
80-
echo "Current SHA is $CUR_SHA"
62+
echo "Default branch = $DEFAULT_BRANCH"
63+
echo "Current SHA = ${{ github. sha }}"
8164
82-
if [[ $GITHUB_REF == "refs/heads/$DEFAULT_BRANCH" ]]; then
83-
pre-commit run --all
84-
else
85-
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref $CUR_SHA
86-
fi
65+
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref "${{ github. sha }}"

example/python/.pre-commit-config.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ repos:
9393
# - id: poetry-lock # Ensures the poetry.lock file is up-to-date with the pyproject.toml changes.
9494

9595
#############################################################################
96-
# CSS, Markdown, JavaScript, TypeScript, YAML style formatter
96+
# Markdown, JavaScript, TypeScript, YAML style formatter
9797
#############################################################################
9898
- repo: https://github.com/pre-commit/mirrors-prettier
9999
rev: v3.0.3
@@ -102,10 +102,8 @@ repos:
102102
name: prettier
103103
args: [--config, .ci/prettier.json, --write]
104104
types_or:
105-
- css
106-
- scss
107-
- ts
108-
- tsx
109105
- javascript
106+
- tsx
107+
- ts
110108
- yaml
111109
- markdown

example/python/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
SHFMT_VERSION := v3.8.0
2+
13
.PHONY: setuppc
24
setuppc:
35
@echo "Setting up pre-commit and hooks..."
@@ -12,14 +14,14 @@ ifeq ($(shell uname),Darwin)
1214
brew install shellcheck
1315
else
1416
@echo "Setting up shfmt (Linux)..."
15-
wget -qO shfmt "https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_$(shell uname -m)"
17+
wget -qO shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_$(shell uname -m)"
1618
chmod +x shfmt
17-
sudo mv shfmt /usr/local/bin/shfmt
19+
sudo mv shfmt /usr/local/bin/
1820

1921
@echo "Setting up shellcheck (Linux)..."
2022
sudo apt-get install shellcheck || sudo yum install shellcheck || sudo dnf install shellcheck
2123
endif
2224

2325
.PHONY: reqtxt
2426
reqtxt:
25-
poetry export -f requirements.txt --output requirements.txt --without-hashes
27+
poetry export -f requirements.txt --output requirements.txt

example/rust/.github/workflows/ci.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ jobs:
5555
env:
5656
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757
run: |
58-
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
58+
REPO_NAME=$(echo $GITHUB_REPOSITORY | sed 's/^.*\///')
59+
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
60+
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
5961
6062
echo "Default branch = $DEFAULT_BRANCH"
6163
echo "Current SHA = ${{ github. sha }}"

templates/.github/workflows/ci.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ jobs:
5656
env:
5757
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5858
run: |
59-
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
59+
REPO_NAME=$(echo $GITHUB_REPOSITORY | sed 's/^.*\///')
60+
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
61+
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
6062
6163
echo "Default branch = $DEFAULT_BRANCH"
6264
echo "Current SHA = ${{ github. sha }}"

test.sh

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

33
cargo install --path .
4-
cpa create --name example/python --preset python
4+
cpa create --name example/python --preset python3.10
55
cpa create --name example/rust --preset rust
66
cpa create --name example/base --preset base

0 commit comments

Comments
 (0)