Skip to content

Commit

Permalink
clean ci
Browse files Browse the repository at this point in the history
  • Loading branch information
ysawa0 committed May 12, 2024
1 parent 22291b2 commit 1b8304c
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 23 deletions.
6 changes: 4 additions & 2 deletions 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,9 +14,9 @@ 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
Expand Down
30 changes: 14 additions & 16 deletions templates/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ jobs:
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 @@ -46,22 +43,23 @@ jobs:
${{ runner.os }}-pc-${{ hashFiles('.pre-commit-config.yaml') }}
${{ runner.os }}-pc-
- name: Install dependencies
run: |
python -m pip install pre-commit
pre-commit install
# - name: Install dependencies
# run: |
# python -m pip install pre-commit
# pre-commit install

- name: Install shfmt
- name: Install dependencies
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
# 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
- name: Run pre-commits
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 3 additions & 5 deletions templates/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ repos:
- id: clippy # Lints Rust code with clippy for common mistakes and style issues
{%+ endif %}
#############################################################################
# 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 @@ -112,10 +112,8 @@ repos:
name: prettier
args: [--config, .ci/prettier.json, --write]
types_or:
- css
- scss
- ts
- tsx
- javascript
- tsx
- ts
- yaml
- markdown
66 changes: 66 additions & 0 deletions templates/rust/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
default_language_version:
python: python3

repos:
#############################################################################
# Misc
#############################################################################
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-merge-conflict # Searches for merge conflict markers within files.
- id: check-added-large-files # Blocks commits that add large files. Default limit is 500kB.
# Can be configured with args, e.g., '--maxkb=1000' to change the limit.
# exclude: 'your_dir/.*'
# args: ['--maxkb=5000']
- id: check-case-conflict # Identifies potential case-insensitive file name conflicts.
- id: check-ast # Validates the syntax of Python files.
- id: check-symlinks # Detects broken symlinks.
- id: trailing-whitespace # Removes any trailing whitespace at the end of lines.
- id: end-of-file-fixer # Ensures files end with a single newline or are empty.

#############################################################################
# JSON, TOML
#############################################################################
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-json # Validates JSON files to ensure they are properly formatted and syntactically correct.
types: [json]
- id: check-toml # Checks TOML files for errors and format issues to ensure valid syntax.
types: [toml]

#############################################################################
# Shell
#############################################################################
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: shfmt # Formats shell scripts to a standard convention using shfmt.
- id: shellcheck # Lints shell scripts to identify syntax and usage errors, with a specified severity of 'warning'.
args:
- --severity=warning
#############################################################################
# Rust
#############################################################################
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt # Formats Rust code using rustfmt
- id: cargo-check # Checks Rust code for compilation errors and warnings
- id: clippy # Lints Rust code with clippy for common mistakes and style issues
#############################################################################
# Markdown, JavaScript, TypeScript, YAML style formatter
#############################################################################
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: prettier # An opinionated code formatter supporting multiple languages.
name: prettier
args: [--config, .ci/prettier.json, --write]
types_or:
- javascript
- tsx
- ts
- yaml
- markdown

0 comments on commit 1b8304c

Please sign in to comment.