Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
ysawa0 committed May 13, 2024
1 parent ea0fb0d commit 29a4583
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 45 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: integration

on:
pull_request: # Start the job on all PRs
push:
branches:
- master
- main

jobs:
integration:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@nightly

- name: Install dependencies
run: |
sh ./test.sh
4 changes: 3 additions & 1 deletion example/base/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
REPO_NAME=$(echo $GITHUB_REPOSITORY | sed 's/^.*\///')
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
echo "Default branch = $DEFAULT_BRANCH"
echo "Current SHA = ${{ github. sha }}"
Expand Down
72 changes: 72 additions & 0 deletions example/python/.ci/flake8.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[flake8]
ignore =
# C901, # function is too complex. Ignored because max-complexity is set.
D100,
# Missing docstring in public module.
D101,
# Missing docstring in public class.
D102,
# Missing docstring in public method.
D103,
# Missing docstring in public function.
D104,
# Missing docstring in public package.
D105,
# Missing docstring in magic method.
D107,
# Missing docstring in __init__.
D205,
# 1 blank line required between summary line and description.
D400,
# First line should end with a period.
E203,
# whitespace before ':'. Conflicts with how Black formats slicing.
E231,
# missing whitespace after ',', ';', or ':'. Conflicts with Black.
E266,
# too many leading '#' for block comment.
E402,
# module level import not at top of file.
E501,
# line too long (82 > 79 characters). Ignored because max-line-length is set.
F841,
# local variable is assigned to but never used.
I100,
# Import statements are in the wrong order.
I201,
# Missing newline between import groups.
I202,
# Additional newline in a group of imports.
W503
# line break before binary operator. This is no longer PEP 8 compliant.

exclude =
.cache,
.coverage.*,
.env,
.git,
.github,
.gradle,
.hg,
.mypy_cache,
.pytest_cache,
.svn,
.tox,
.venv,
.vscode,
*__pycache__,
*.egg-info,
*.pyc,
build,
dist,
htmlcov.*,

# List of application-specific import names.
application-import-names = flake8
# Import statement format style.
import-order-style = google
# The maximum McCabe complexity allowed.
max-complexity = 18
# The maximum allowed line length.
max-line-length = 120
# per-file-ignores = # Per-file-ignores setting can be used to ignore specific errors in specific files.
7 changes: 7 additions & 0 deletions example/python/.ci/prettier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"bracketSpacing": true,
"singleQuote": false,
"useTabs": false,
"tabWidth": 2,
"trailingComma": "all"
}
45 changes: 12 additions & 33 deletions example/python/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: CI
name: ci

on:
pull_request: # Start the job on all PRs
branches: [master, main]
types: [synchronize, opened, reopened, ready_for_review]
push: # Start the job on all main branch push
branches: [master, main]
push:
branches:
- master
- main

jobs:
precommit:
Expand All @@ -14,15 +14,14 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Set shfmt version environment variable
run: echo "SHFMT_VERSION=v3.7.0" >> $GITHUB_ENV

- name: Cache pip dependencies
uses: actions/cache@v3
with:
Expand All @@ -35,9 +34,8 @@ jobs:
uses: actions/cache@v3
with:
path: /usr/local/bin/shfmt
key: ${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
key: ${{ runner.os }}-shfmt-
restore-keys: |
${{ runner.os }}-shfmt-${{ env.SHFMT_VERSION }}
${{ runner.os }}-shfmt-
- name: Cache Pre-Commit environments
Expand All @@ -51,19 +49,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install pre-commit
pre-commit install
- name: Install shfmt
run: |
SHFMT_VERSION=${{ env.SHFMT_VERSION }}
SHFMT_BIN="shfmt_${SHFMT_VERSION}_linux_amd64"
if [[ ! -f /usr/local/bin/shfmt ]]; then
wget -O shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/${SHFMT_BIN}"
chmod +x shfmt
sudo mv shfmt /usr/local/bin/
fi
sudo apt-get install shellcheck
make setuppc
- name: Run pre-commits
env:
Expand All @@ -73,14 +59,7 @@ jobs:
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
git fetch
CUR_SHA=$(git log --pretty=tformat:"%H" -n1 . | tail -n1)
echo "Default branch is $DEFAULT_BRANCH"
echo "Current SHA is $CUR_SHA"
echo "Default branch = $DEFAULT_BRANCH"
echo "Current SHA = ${{ github. sha }}"
if [[ $GITHUB_REF == "refs/heads/$DEFAULT_BRANCH" ]]; then
pre-commit run --all
else
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref $CUR_SHA
fi
pre-commit run --from-ref origin/$DEFAULT_BRANCH --to-ref "${{ github. sha }}"
8 changes: 3 additions & 5 deletions example/python/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ repos:
# - id: poetry-lock # Ensures the poetry.lock file is up-to-date with the pyproject.toml changes.

#############################################################################
# CSS, Markdown, JavaScript, TypeScript, YAML style formatter
# Markdown, JavaScript, TypeScript, YAML style formatter
#############################################################################
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
Expand All @@ -102,10 +102,8 @@ repos:
name: prettier
args: [--config, .ci/prettier.json, --write]
types_or:
- css
- scss
- ts
- tsx
- javascript
- tsx
- ts
- yaml
- markdown
8 changes: 5 additions & 3 deletions example/python/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SHFMT_VERSION := v3.8.0

.PHONY: setuppc
setuppc:
@echo "Setting up pre-commit and hooks..."
Expand All @@ -12,14 +14,14 @@ ifeq ($(shell uname),Darwin)
brew install shellcheck
else
@echo "Setting up shfmt (Linux)..."
wget -qO shfmt "https://github.com/mvdan/sh/releases/download/v3.7.0/shfmt_v3.7.0_$(shell uname -m)"
wget -qO shfmt "https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_$(shell uname -m)"
chmod +x shfmt
sudo mv shfmt /usr/local/bin/shfmt
sudo mv shfmt /usr/local/bin/

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

.PHONY: reqtxt
reqtxt:
poetry export -f requirements.txt --output requirements.txt --without-hashes
poetry export -f requirements.txt --output requirements.txt
4 changes: 3 additions & 1 deletion example/rust/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
REPO_NAME=$(echo $GITHUB_REPOSITORY | sed 's/^.*\///')
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
echo "Default branch = $DEFAULT_BRANCH"
echo "Current SHA = ${{ github. sha }}"
Expand Down
4 changes: 3 additions & 1 deletion templates/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
REPO_NAME=$(echo $GITHUB_REPOSITORY | sed 's/^.*\///')
DEFAULT_BRANCH=$(curl -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$GITHUB_REPOSITORY" | jq -r '.default_branch')
echo "Default branch = $DEFAULT_BRANCH"
echo "Current SHA = ${{ github. sha }}"
Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

cargo install --path .
cpa create --name example/python --preset python
cpa create --name example/python --preset python3.10
cpa create --name example/rust --preset rust
cpa create --name example/base --preset base

0 comments on commit 29a4583

Please sign in to comment.