-
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.
- Loading branch information
Showing
57 changed files
with
10,201 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,2 @@ | ||
[alias] | ||
buildit = "run --release --manifest-path ./buildit/Cargo.toml --" |
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,15 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[*.{yaml,yml}] | ||
indent_size = 2 |
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,13 @@ | ||
#!/bin/sh | ||
|
||
echo "👷 Running the post-checkout hook ..." | ||
|
||
HOOKS_DIR="./.git-hooks" | ||
echo "👷 Setting hooks directory to $HOOKS_DIR" | ||
git config core.hooksPath $HOOKS_DIR | ||
CONFIG_EXIT_CODE=$? | ||
if [ $CONFIG_EXIT_CODE -ne 0 ]; then | ||
echo "❌ Unable to set hooks directory. Please run 'git config core.hooksPath $HOOKS_DIR' manually." | ||
else | ||
echo "✔️ Set hooks directory successfully." | ||
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,73 @@ | ||
#!/bin/sh | ||
|
||
echo "👷 Running the pre-commit hook ..." | ||
|
||
if git rev-parse --verify HEAD >/dev/null 2>&1 | ||
then | ||
against=HEAD | ||
else | ||
# Initial commit: diff against an empty tree object | ||
against=$(git hash-object -t tree /dev/null) | ||
fi | ||
|
||
# If you want to allow non-ASCII filenames set this variable to true. | ||
allownonascii=$(git config --type=bool hooks.allownonascii) | ||
|
||
# Redirect output to stderr. | ||
exec 1>&2 | ||
|
||
# Cross platform projects tend to avoid non-ASCII filenames; prevent | ||
# them from being added to the repository. We exploit the fact that the | ||
# printable range starts at the space character and ends with tilde. | ||
if [ "$allownonascii" != "true" ] && | ||
# Note that the use of brackets around a tr range is ok here, (it's | ||
# even required, for portability to Solaris 10's /usr/bin/tr), since | ||
# the square bracket bytes happen to fall in the designated range. | ||
test $(git diff --cached --name-only --diff-filter=A -z $against | | ||
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 | ||
then | ||
cat <<\EOF | ||
❌ Attempt to add a non-ASCII file name. | ||
This can cause problems if you want to work with people on other platforms. | ||
To be portable it is advisable to rename the file. | ||
If you know what you are doing you can disable this check using: | ||
git config hooks.allownonascii true | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
# If there are whitespace errors, print the offending file names and fail. | ||
# exec git diff-index --check --cached $against -- | ||
|
||
echo "👷 Checking if any source of CI files have changed ..." | ||
STAGED_FILES=$(git diff-index --cached --name-only HEAD) | ||
echo $STAGED_FILES | grep -q -e "src/" -F -- | ||
GREP_EXIT_CODE=$? | ||
if [ $GREP_EXIT_CODE -ne 0 ]; then | ||
echo "✔️ No source files were changed. Not running additional tasks." | ||
exit 0 | ||
fi | ||
|
||
echo "👷 Checking code with Clippy ..." | ||
cargo clippy | ||
CLIPPY_EXIT_CODE=$? | ||
if [ $CLIPPY_EXIT_CODE -ne 0 ]; then | ||
echo "❌ Please fix the issues Clippy raised." | ||
exit 1 | ||
else | ||
echo "✔️ Clippy did not detect any issues." | ||
fi | ||
|
||
echo "👷 Checking code formatting ..." | ||
cargo fmt -- --check | ||
FORMATTING_EXIT_CODE=$? | ||
if [ $FORMATTING_EXIT_CODE -ne 0 ]; then | ||
echo "❌ Please fix the detected formatting issues." | ||
exit 1 | ||
else | ||
echo "✔️ All formatting checks passed." | ||
fi | ||
|
||
echo "🚀 Done." | ||
|
||
exit 0 |
17 changes: 17 additions & 0 deletions
17
.github/actions/detect-and-install-rust-toolchain/action.yaml
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,17 @@ | ||
name: Detect and install Rust toolchain | ||
description: > | ||
Detects the version of Rust specified in the rust-toolchain.toml file and installs it. | ||
inputs: | ||
components: | ||
description: A Comma Separated Value (CSV) string with components to install, .e.g clippy,rustfmt | ||
type: string | ||
runs: | ||
using: composite | ||
steps: | ||
- uses: ./.github/actions/detect-rust-toolchain-version | ||
|
||
- name: Install Rust toolchain ${{ env.RUST_TOOLCHAIN_VERSION }} | ||
uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
components: ${{ inputs.components }} | ||
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} |
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,12 @@ | ||
name: Detect Rust toolchain version | ||
description: > | ||
Detects the version of Rust specified in the rust-toolchain.toml file and sets the RUST_TOOLCHAIN_VERSION | ||
environment variable accordingly. | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Detect Rust toolchain version | ||
shell: pwsh | ||
run: | | ||
$version = (Select-String -Path ./rust-toolchain.toml -Pattern "^channel\s*=\s*`"\s*(\d+.\d+.\d+)").Matches.Groups[1].Value | ||
Write-Host "RUST_TOOLCHAIN_VERSION=$version" >> "${env:GITHUB_ENV}" |
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,16 @@ | ||
name: Install BuildIt | ||
description: Installs the BuildIt CLI | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Cache BuildIt | ||
uses: actions/cache@v3 | ||
continue-on-error: true | ||
with: | ||
path: ./buildit/target | ||
key: buildit-${{ runner.os }}-${{ hashFiles('./buildit') }} | ||
restore-keys: buildit-${{ runner.os }}-${{ hashFiles('./buildit') }} | ||
|
||
- name: Install the BuildIt CLI | ||
shell: pwsh | ||
run: cargo install --path ./buildit |
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,17 @@ | ||
name: Install tmux | ||
description: Installs tmux on supported OSes | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Install tmux (Linux) | ||
if: ${{ runner.os == 'ubuntu-latest' }} | ||
shell: bash | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y tmux | ||
- name: Install tmux (Mac) | ||
if: ${{ runner.os == 'macos-latest' }} | ||
shell: bash | ||
run: | | ||
brew install tmux |
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,48 @@ | ||
name: Run all tests | ||
description: Runs all tests, including interactive ones. | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Non-interactive tests | ||
if: ${{ runner.os == 'windows-latest' }} | ||
shell: pwsh | ||
run: cargo test --all-features --release | ||
|
||
- uses: ./.github/actions/install-tmux | ||
|
||
- name: All tests | ||
if: ${{ runner.os == 'ubuntu-latest' || runner.os == 'macos-latest' }} | ||
shell: bash | ||
run: | | ||
# Do not exit on first non-zero return code, as we want to do cleanup at the end. | ||
set +e | ||
# Start a tmux session named 'tests'. | ||
tmux new-session -d -s tests -x 200 -y 20 | ||
# Send the command to run the tests with code coverage. | ||
tmux send-keys -t tests 'cargo test --all-features --release -- --include-ignored ; tmux wait -S tests-finished' Enter | ||
# Wait for the tests-finished signal. | ||
tmux wait-for tests-finished | ||
# Show the tmux session output including up to the last 1000 lines scrolled out of view. | ||
tmux capture-pane -p -t tests -S -1000 | ||
# Check for all tests succeeded. | ||
tmux capture-pane -p -t tests | grep 'test result: FAILED' | ||
# Note: We don't want to see the failed string above | ||
if [ $? -eq 0 ] | ||
then | ||
echo "Detected failed tests!" | ||
EXITCODE=1 | ||
else | ||
echo "Did not detect any failed tests." | ||
EXITCODE=0 | ||
fi | ||
# Exit the tmux session. | ||
tmux kill-session -t tests | ||
# Now exit with the saved exit code. | ||
exit $EXITCODE |
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,28 @@ | ||
name: benchmark | ||
run-name: Run benchmarks | ||
on: | ||
- pull_request | ||
- workflow_call | ||
- workflow_dispatch | ||
jobs: | ||
benchmark: | ||
name: Benchmark | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/detect-and-install-rust-toolchain | ||
|
||
- uses: ./.github/actions/install-buildit | ||
|
||
- name: Cache tmp.sample | ||
uses: actions/cache@v3 | ||
timeout-minutes: 1 | ||
continue-on-error: true | ||
with: | ||
path: ./tmp.sample | ||
key: tmp.sample-${{ github.job }}-${{ runner.os }} | ||
restore-keys: tmp.sample-${{ github.job }}-${{ runner.os }} | ||
|
||
- name: Benchmark | ||
run: buildit benchmark |
Oops, something went wrong.