-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from GG2002/add-ci
feat: add ci
- Loading branch information
Showing
2 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: PR Checks | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
components: clippy | ||
override: true | ||
|
||
- name: Make script executable | ||
run: chmod +x ci/scripts/check-trailing-spaces.sh | ||
|
||
- name: Trailing spaces check | ||
run: ci/scripts/check-trailing-spaces.sh | ||
|
||
- name: Audit | ||
run: cargo audit | ||
|
||
- name: Format | ||
run: cargo fmt --all -- --check | ||
|
||
- name: Clippy | ||
run: cargo clippy --all-targets --all-features -- -D warnings | ||
|
||
- name: Test | ||
run: cargo test --verbose | ||
|
||
commit: | ||
name: Commit Message Validation | ||
if: github.event_name == 'pull_request' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- run: git show-ref | ||
- uses: actions-rs/[email protected] | ||
with: | ||
crate: git-cz | ||
version: latest | ||
- name: Validate commit messages | ||
run: git-cz check ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | ||
|
||
spell-check: | ||
name: Spell Check | ||
if: github.event_name == 'pull_request' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Check Spelling | ||
uses: crate-ci/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Script Author: https://github.com/stdrc | ||
# Repo: https://github.com/risingwavelabs/risingwave/blame/main/scripts/check/check-trailing-spaces.sh | ||
|
||
# Exits as soon as any line fails. | ||
set -euo pipefail | ||
|
||
self=$0 | ||
|
||
# Shell colors | ||
RED='\033[0;31m' | ||
BLUE='\033[0;34m' | ||
GREEN='\033[0;32m' | ||
ORANGE='\033[0;33m' | ||
BOLD='\033[1m' | ||
NONE='\033[0m' | ||
|
||
print_help() { | ||
echo "Usage: $self [-f|--fix]" | ||
echo | ||
echo "Options:" | ||
echo " -f, --fix Fix trailing spaces." | ||
echo " -h, --help Show this help message and exit." | ||
} | ||
|
||
fix=false | ||
while [ $# -gt 0 ]; do | ||
case $1 in | ||
-f | --fix) | ||
fix=true | ||
;; | ||
-h | --help) | ||
print_help | ||
exit 0 | ||
;; | ||
*) | ||
echo -e "${RED}${BOLD}$self: invalid option \`$1\`\n${NONE}" | ||
print_help | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
temp_file=$(mktemp) | ||
|
||
echo -ne "${BLUE}" | ||
git config --global --add safe.directory '*' | ||
git grep -nIP --untracked '[[:space:]]+$' | tee $temp_file || true | ||
echo -ne "${NONE}" | ||
|
||
bad_files=$(cat $temp_file | cut -f1 -d ':' | sort -u) | ||
rm $temp_file | ||
|
||
if [ ! -z "$bad_files" ]; then | ||
if [[ $fix == true ]]; then | ||
for file in $bad_files; do | ||
sed -i '' -e's/[[:space:]]*$//' "$file" | ||
done | ||
|
||
echo | ||
echo -e "${GREEN}${BOLD}All trailing spaces listed above have been cleaned.${NONE}" | ||
exit 0 | ||
else | ||
echo | ||
echo -e "${RED}${BOLD}Please clean all the trailing spaces listed above.${NONE}" | ||
echo -e "${BOLD}You can run '$self --fix' for convenience.${NONE}" | ||
exit 1 | ||
fi | ||
else | ||
echo -e "${GREEN}${BOLD}No trailing spaces found.${NONE}" | ||
exit 0 | ||
fi |