-
Notifications
You must be signed in to change notification settings - Fork 13
chore: robustify the codebase #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
f8ebc05
ci(.github/workflows/CI.yml): improve portability
michen00 dddf9ac
docs: establish constitution v1.0.0
michen00 f2376b9
build(claude): add allowed commands
michen00 7b86f9a
ci: also run on main push
michen00 d45c30f
feat: enable strict mode
michen00 8fad18e
fix(gcfixup): handle empty arguments in help
michen00 6809987
build(Makefile): enhance test target
michen00 87b1745
docs: add CONTRIBUTING.md to guide contributions
michen00 32ee8be
docs: amend constitution to v1.0.1
michen00 2f9083f
style: don't overspecify defaults
michen00 2d117b7
ci: install parallel for macOS
michen00 cd23650
build: validate scripts
michen00 b482ed4
build(Makefile): robustify a command
michen00 8040268
fix(ach): improve file re-staging logic
michen00 4d7dfc1
fix(scripts): handle broken pipe errors
michen00 f291e7e
fix(ach): safely handle empty positional arguments
michen00 1eb1dc0
fix: fix script validation
michen00 8c9332f
docs(README.md): add missing description
michen00 fc192a3
chore(.pre-commit-config.yaml): bump hooks
michen00 fba443b
chore(Makefile): remove dead code
michen00 3b52c63
fix: apply suggestions
michen00 7838e7e
fix: apply suggestions
michen00 6213105
chore: use double brackets
michen00 27b0c50
build(Makefile): handle file names with spaces
michen00 e2dfac7
refactor(ach): simplify a code block
michen00 e20b6f4
revert: "refactor(ach): simplify a code block"
michen00 4ee543d
fix: fix validation script
michen00 af4e18f
chore: reorganize a script
michen00 48a5c48
test: test the validation script
michen00 85b80f3
chore: run with bash explicitly
michen00 97e2770
fix: apply suggestions
michen00 eb72b77
ci: fix for CI
michen00 7b30b7f
chore: check for bash 4.3+
michen00 5076936
chore: autofix via pre-commit hooks
pre-commit-ci[bot] 6fa895d
feat: address feedback
michen00 cd34081
perf: streamline a command
michen00 7a91538
refactor: use while read
michen00 204ccae
revert: revert "refactor: use while read"
michen00 47f0709
refactor: lift make test logic
michen00 00cb92d
docs: fix a typo
michen00 497cf55
refactor: use double brackets for consistency
michen00 849ed0e
fix: apply suggestions
michen00 5b8e6d8
feat: address feedback
michen00 827b1b9
ci: update macOS scaffolding
michen00 8b43e12
feat(ach): improve error message
michen00 bc87eae
fix: adjust regex
michen00 5bdcec5
docs: clarify a comment
michen00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
| { | ||
| "permissions": { | ||
| "allow": ["Bash(wc:*)", "Bash(bats:*)"] | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,101 @@ | ||
| <!-- | ||
| Sync Impact Report: | ||
| Version: 1.0.0 → 1.0.1 | ||
| Ratified: 2025-01-18 | ||
| Last Amended: 2026-01-18 | ||
|
|
||
| Principles Modified: | ||
| - III. Test-First: Clarified scope - only scripts in project root require testing | ||
|
|
||
| Sections Modified: | ||
| - Quality Assurance / Testing Requirements: Clarified scope | ||
|
|
||
| Templates Status: | ||
| ✅ plan-template.md - No changes needed (generic testing guidance) | ||
| ✅ spec-template.md - No changes needed (generic testing guidance) | ||
| ✅ tasks-template.md - No changes needed (tests are optional per spec) | ||
| ✅ Command files - No outdated references found | ||
|
|
||
| Version Bump Rationale: PATCH - Clarification of testing scope (scripts in project root vs other scripts like dev scripts). No breaking changes, backward compatible. | ||
| --> | ||
|
|
||
| # bin Constitution | ||
|
|
||
| ## Core Principles | ||
|
|
||
| ### I. Script-First | ||
|
|
||
| Every utility is a standalone, independently executable script. Scripts MUST be self-contained with no external runtime dependencies beyond standard Unix utilities. Each script MUST have a clear, single purpose. Scripts MUST be executable and callable directly from the command line. | ||
|
|
||
| ### II. CLI Interface | ||
|
|
||
| All scripts MUST follow Unix conventions: text input/output via stdin/stdout/stderr, proper exit codes (0 for success, non-zero for failure), and comprehensive help messages via `--help` or `-h`. Scripts MUST support both interactive and non-interactive usage. Error messages MUST be clear and actionable, written to stderr. | ||
|
|
||
| ### III. Test-First (NON-NEGOTIABLE) | ||
|
|
||
| Every script in the project root MUST have comprehensive test coverage using bats. Tests MUST be written before or alongside implementation. Tests MUST cover happy paths, error cases, edge cases, and help output. All tests MUST pass before merging. Test files MUST be located in `tests/` directory with naming convention `[script-name].bats`. | ||
|
|
||
| **Scope**: This requirement applies to scripts located in the project root directory. Scripts in other locations (e.g., `.github/scripts/`, development tooling, or helper scripts) may be exempt from testing requirements at the project's discretion, but scripts in the project root that are part of the main utility suite MUST have tests. | ||
|
|
||
| ### IV. Simplicity | ||
|
|
||
| Scripts MUST prioritize simplicity and maintainability. Follow YAGNI (You Aren't Gonna Need It) principles. Avoid unnecessary complexity, abstraction, or premature optimization. Scripts MUST be readable and understandable by developers familiar with bash. When complexity is unavoidable, it MUST be justified and documented. | ||
|
|
||
| ### V. Portability | ||
|
|
||
| Scripts MUST work across Unix-like systems (Linux, macOS, BSD). Use POSIX-compliant constructs where possible. When bash-specific features are required, scripts MUST use `#!/usr/bin/env bash` shebang and document the minimum bash version. Avoid system-specific paths or assumptions. Test on multiple platforms when feasible. | ||
|
|
||
| ## Development Standards | ||
|
|
||
| ### Bash Best Practices | ||
|
|
||
| - Scripts MUST use `set -euo pipefail` for strict error handling. Exceptions for `-u` may be justified when scripts need to check for unset variables using patterns like `${VAR:-default}` or explicit unset checks | ||
| - Variables MUST be quoted to prevent word splitting and pathname expansion | ||
| - Functions MUST be used for reusable logic | ||
| - Scripts MUST include proper cleanup handlers (trap) for error recovery | ||
| - Scripts MUST validate inputs and provide clear error messages | ||
|
|
||
| ### Code Quality | ||
|
|
||
| - Scripts MUST pass shellcheck validation | ||
| - Scripts MUST follow consistent formatting (use .editorconfig) | ||
| - Scripts MUST include usage documentation in help output | ||
| - Complex logic MUST be commented for clarity | ||
|
|
||
| ## Quality Assurance | ||
|
|
||
| ### Testing Requirements | ||
|
|
||
| - All scripts in the project root MUST have corresponding test files in `tests/` | ||
| - Scripts in other locations (e.g., `.github/scripts/`, dev tooling) may be exempt from testing at project discretion | ||
| - Tests MUST use bats framework (minimum version 1.5.0) | ||
| - Tests MUST be independent and idempotent | ||
| - Tests MUST clean up after themselves | ||
| - Integration tests MUST use isolated test environments | ||
|
|
||
| ### Continuous Integration | ||
|
|
||
| - All tests MUST pass in CI before merging | ||
| - Pre-commit hooks MUST validate script syntax and formatting | ||
| - Code review MUST verify test coverage and constitution compliance | ||
|
|
||
| ## Governance | ||
|
|
||
| This constitution supersedes all other development practices and guidelines. All pull requests and code reviews MUST verify compliance with these principles. | ||
|
|
||
| **Amendment Process**: Amendments to this constitution require: | ||
|
|
||
| 1. Documentation of the proposed change and rationale | ||
| 2. Impact analysis on existing scripts and templates | ||
| 3. Update of dependent templates and documentation | ||
| 4. Version increment according to semantic versioning | ||
|
|
||
| **Versioning Policy**: | ||
|
|
||
| - MAJOR: Backward incompatible principle removals or redefinitions | ||
| - MINOR: New principle added or materially expanded guidance | ||
| - PATCH: Clarifications, wording improvements, typo fixes | ||
|
|
||
| **Compliance Review**: All PRs MUST include a constitution check. Violations MUST be justified in the Complexity Tracking section of implementation plans, or the PR MUST be updated to comply. | ||
|
|
||
| **Version**: 1.0.1 | **Ratified**: 2025-01-18 | **Last Amended**: 2026-01-18 | ||
This file contains hidden or 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,170 @@ | ||
| <!-- omit in toc --> | ||
|
|
||
| # Regarding contributions | ||
|
|
||
| All types of contributions are encouraged and valued. See the [Table of Contents](#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. We look forward to your contributions! | ||
|
|
||
| The project has defined a [code of conduct](https://github.com/michen00/.github/blob/main/CODE_OF_CONDUCT.md), providing a welcoming and friendly environment. Please adhere to it in all interactions. | ||
|
|
||
| > And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about: | ||
| > | ||
| > - Star the project | ||
| > - Post about it on LinkedIn or other social media | ||
| > - Refer this project in your project's README | ||
| > - Mention the project at local meetups and tell your friends/colleagues | ||
|
|
||
| <!-- omit in toc --> | ||
|
|
||
| ## Table of Contents | ||
|
|
||
| - [I have a question](#i-have-a-question) | ||
| - [I want to contribute](#i-want-to-contribute) | ||
| - [Reporting bugs](#reporting-bugs) | ||
| - [Before submitting a bug report](#before-submitting-a-bug-report) | ||
| - [How do I submit a good bug report?](#how-do-i-submit-a-good-bug-report) | ||
| - [Suggesting enhancements](#suggesting-enhancements) | ||
| - [Before Submitting an Enhancement](#before-submitting-an-enhancement) | ||
| - [How do I submit a good enhancement suggestion?](#how-do-i-submit-a-good-enhancement-suggestion) | ||
| - [Your first code contribution](#your-first-code-contribution) | ||
|
|
||
| ## I have a question | ||
|
|
||
| Before you ask a question, it is best to search for existing [issues][issues] and [discussions][discussions] that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first. | ||
|
|
||
| If you then still feel the need to ask a question and need clarification, we recommend the following: | ||
|
|
||
| - Create a [discussion][discussions_new]. | ||
| - Provide as much context as you can about what you're running into. | ||
| - Provide project and platform versions, depending on what seems relevant. | ||
|
|
||
| We will then take care of the discussion as soon as possible. | ||
|
|
||
| ## I want to contribute | ||
|
|
||
| ### Reporting bugs | ||
|
|
||
| #### Before submitting a bug report | ||
|
|
||
| A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible: | ||
|
|
||
| - Make sure that you are using the latest version. | ||
| - Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions. | ||
| - To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker][issues_bugs]. | ||
| - Also make sure to search the internet to see if users outside of the GitHub community have discussed the issue. | ||
| - Collect information about the bug: | ||
| - Stack trace | ||
| - OS and version (Windows, Linux, macOS, x86, ARM) | ||
| - Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant | ||
| - Possibly your input and the output | ||
| - Can you reliably reproduce the issue? And can you also reproduce it with older versions? | ||
| - Screenshots or animated GIFs showing the problem | ||
|
|
||
| #### How do I submit a good bug report? | ||
|
|
||
| We use GitHub issues to track bugs and errors. If you run into an issue with the project: | ||
|
|
||
| - Open an [issue][issues_new]. | ||
| - Explain the behavior you would expect and the actual behavior. | ||
| - Please provide as much context as possible and describe the _reproduction steps_ that someone else can follow to recreate the issue on their own. | ||
| - Provide the information you collected in the previous section. | ||
|
|
||
| Once it's filed: | ||
|
|
||
| - The project team will label the issue accordingly. | ||
| - A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps. Bugs without steps will not be addressed until they can be reproduced. | ||
| - If the team is able to reproduce the issue, it will be prioritized according to severity. | ||
|
|
||
| ### Suggesting enhancements | ||
|
|
||
| This section guides you through submitting an enhancement suggestion, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community understand your suggestion and find related suggestions. | ||
|
|
||
| #### Before Submitting an Enhancement | ||
|
|
||
| - Make sure that you are using the latest version. | ||
| - Read the documentation carefully and find out if the functionality is already covered, maybe by an individual configuration. | ||
| - Perform a [search][issues] to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one. | ||
| - Find out whether your idea fits with the scope and aims of the project. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. | ||
|
|
||
| #### How do I submit a good enhancement suggestion? | ||
|
|
||
| Enhancement suggestions are tracked as [GitHub issues][issues]. | ||
|
|
||
| - Use a **clear and descriptive title** for the issue to identify the suggestion. | ||
| - Provide a **step-by-step description of the suggested enhancement** in as many details as possible. | ||
| - **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you. | ||
| - You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to. | ||
| - **Explain why this enhancement would be useful** to most users. You may also want to point out other projects that solved it better and could serve as inspiration. | ||
|
|
||
| ### Your first code contribution | ||
|
|
||
| #### Getting started | ||
|
|
||
| Start by [forking the repository](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo), i.e. copying the repository to your account to grant you write access. Continue with cloning the forked repository to your local machine. | ||
|
|
||
| From the project root, run `make develop` to set up the project for development. | ||
|
|
||
| #### Development workflow | ||
|
|
||
| Make your changes to the code, then verify everything works: | ||
|
|
||
| ```sh | ||
| make check | ||
| ``` | ||
|
|
||
| ##### Running tests | ||
|
|
||
| To run all tests: | ||
|
|
||
| ```sh | ||
| make test | ||
| ``` | ||
|
|
||
| To run tests for a specific script: | ||
|
|
||
| ```sh | ||
| make test SCRIPTS=ach | ||
| ``` | ||
|
|
||
| To run tests for multiple scripts: | ||
|
|
||
| ```sh | ||
| make test SCRIPTS=ach,chdirx,gcfixup | ||
| ``` | ||
|
|
||
| The test runner validates that both the script file and its test file exist. If you specify an invalid script name, you'll see an error message listing available scripts. | ||
|
|
||
| You can combine script selection with other test options: | ||
|
|
||
| ```sh | ||
| # Run specific tests sequentially (useful for debugging) | ||
| make test SCRIPTS=ach,touchx PARALLEL=false | ||
|
|
||
| # Run all tests sequentially | ||
| make test PARALLEL=false | ||
| ``` | ||
|
|
||
| Note: When running a single script, tests always run sequentially. When running multiple scripts with `PARALLEL=true`, the job count is automatically optimized based on the number of scripts. | ||
|
|
||
| #### Committing your changes | ||
|
|
||
| Commit the changes using the [conventional commits](https://www.conventionalcommits.org) message style: | ||
|
|
||
| ```sh | ||
| git commit -am 'feat: add new feature' | ||
| ``` | ||
|
|
||
| Common commit types: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore` | ||
|
|
||
| Continue with pushing the local commits to GitHub: | ||
|
|
||
| ```sh | ||
| git push origin <branch name> | ||
| ``` | ||
|
|
||
| And finally, when you are satisfied with your changes, open a new PR. | ||
|
|
||
| [issues]: https://github.com/michen00/invisible-squiggles/issues | ||
| [issues_new]: https://github.com/michen00/invisible-squiggles/issues/new | ||
| [issues_bugs]: https://github.com/michen00/invisible-squiggles/issues?q=label%3Abug | ||
| [discussions]: https://github.com/michen00/invisible-squiggles/discussions | ||
| [discussions_new]: https://github.com/michen00/invisible-squiggles/discussions/new/choose |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.