Skip to content

Commit

Permalink
Logging and other improvements (#5)
Browse files Browse the repository at this point in the history
* Update bug report template
* Update contribution guide
* Use a different target dir when running code coverage to not break incremental builds
* Remove atty dependency in buildit by disabling default clap feature
* Add different target dir for coverage builds to play nice with incremental builds
* Improve code coverage of view_command module
* Change logging impl to log4rs and add tests
* Update contribution guide and add a PR template
* Add pre-commit hooks for BuildIt
* Update PR template
* Add --show-timings arg. Minor refactor of size display format arg usage. Improve code coverage
* Enable coverage workflow for PRs
* Fix unused import warning
  • Loading branch information
emilevr authored Oct 19, 2023
1 parent 576f539 commit e203f66
Show file tree
Hide file tree
Showing 23 changed files with 469 additions and 304 deletions.
36 changes: 28 additions & 8 deletions .git-hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,51 @@ fi

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 --
echo $STAGED_FILES | grep -q -e "src/" -e "buildit/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 ..."
echo "👷 Checking CLI code formatting ..."
cargo fmt -- --check
FORMATTING_EXIT_CODE=$?
if [ $FORMATTING_EXIT_CODE -ne 0 ]; then
echo "❌ Please fix the detected formatting issues in CLI code."
exit 1
else
echo "✔️ All formatting checks passed for CLI code."
fi

echo "👷 Checking CLI code with Clippy ..."
cargo clippy
CLIPPY_EXIT_CODE=$?
if [ $CLIPPY_EXIT_CODE -ne 0 ]; then
echo "❌ Please fix the issues Clippy raised."
echo "❌ Please fix the issues Clippy raised in CLI code."
exit 1
else
echo "✔️ Clippy did not detect any issues."
echo "✔️ Clippy did not detect any issues in CLI code."
fi

echo "👷 Checking code formatting ..."
cargo fmt -- --check
echo "👷 Checking BuildIt code formatting ..."
cargo fmt --manifest-path ./buildit/Cargo.toml -- --check
FORMATTING_EXIT_CODE=$?
if [ $FORMATTING_EXIT_CODE -ne 0 ]; then
echo "❌ Please fix the detected formatting issues."
echo "❌ Please fix the detected formatting issues in BuildIt code."
exit 1
else
echo "✔️ All formatting checks passed for BuildIt code."
fi

echo "👷 Checking BuildIt code with Clippy ..."
cargo clippy --manifest-path ./buildit/Cargo.toml
CLIPPY_EXIT_CODE=$?
if [ $CLIPPY_EXIT_CODE -ne 0 ]; then
echo "❌ Please fix the issues Clippy raised in BuildIt code."
exit 1
else
echo "✔️ All formatting checks passed."
echo "✔️ Clippy did not detect any issues in BuildIt code."
fi

echo "🚀 Done."
Expand Down
10 changes: 6 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ body:
description: |
Also tell us, what did you expect to happen? If applicable, add screenshots to help explain your problem.
> :bulb: You can attach files by dragging and dropping them on the text control below.
placeholder: Tell or show us what you see!
> :exclamation: Make sure that any files you submit do not contain sensitive information!
placeholder: Tell or show us what you see.
validations:
required: true
- type: input
Expand Down Expand Up @@ -48,9 +49,10 @@ body:
id: logs
attributes:
label: Relevant log output
description: >
Please copy and paste any relevant log output. This will be automatically formatted into code, so no
need for backticks.
description: |
Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
Warning or errors may have been written to the log file at `~/.space/space.log`.
> :exclamation: Make sure that any log entries you provide do not contain sensitive information!
render: Shell
- type: checkboxes
id: terms
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: coverage
run-name: Code Coverage
on:
- pull_request
- workflow_call
- workflow_dispatch
jobs:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ coverage/
*.profraw
tmp.sample/
tmp.sample.zip
target_coverage/
9 changes: 6 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ When contributing to this repository, please first discuss the change you wish t
- The Rust programming language is preferred for all code in this repository. A contribution that includes
code in any other language will only be accepted under extraordinary circumstances.
- Performance is a primary goal of this project. Please ensure your code is fast and safe.
- High code coverage (95%+) is a requirement of this project. Make sure you add / update tests to cover your
code.
- Please use descriptive variable names. Code is the best documentation.
- Keep it simple.
- Please create tests in a *separate* file named <module-file-name>_test.rs, rather than directly in the
module file.
- Keep it as simple as possible.

> :exclamation: Please note we have a code of conduct, please follow it in all your interactions with the project.
Expand All @@ -24,8 +28,7 @@ When contributing to this repository, please first discuss the change you wish t

### Release Versions

A release is created, by admins, via pushing a tag that matches the following regex: `\d+.\d+.\d+`, i.e. 0.1.0
or 1.1.1.
A release is created, by admins, via pushing a tag that matches the following regex: `\d+.\d+.\d+`, i.e. 1.1.1.

## Code of Conduct

Expand Down
Loading

0 comments on commit e203f66

Please sign in to comment.