-
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.
Signed-off-by: feathercyc <[email protected]>
- Loading branch information
Showing
16 changed files
with
2,202 additions
and
509 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 | ||
componets: 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] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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 |
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,27 @@ | ||
use interval_map::{Interval, IntervalMap}; | ||
|
||
trait Point<T> { | ||
fn new_point(x: T) -> Interval<T>; | ||
} | ||
|
||
impl Point<u32> for Interval<u32> { | ||
fn new_point(x: u32) -> Self { | ||
Interval::new(x, x + 1) | ||
} | ||
} | ||
|
||
fn main() { | ||
let mut interval_map = IntervalMap::<u32, i32>::new(); | ||
interval_map.insert(Interval::new(3, 7), 20); | ||
interval_map.insert(Interval::new(2, 6), 15); | ||
|
||
let tmp_point = Interval::new_point(5); | ||
assert_eq!(tmp_point, Interval::new(5, 6)); | ||
|
||
interval_map.insert(tmp_point.clone(), 10); | ||
assert_eq!(interval_map.get(&tmp_point).unwrap(), &10); | ||
assert_eq!( | ||
interval_map.find_all_overlap(&Interval::new_point(5)).len(), | ||
3 | ||
); | ||
} |
Oops, something went wrong.