-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/validate #44
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
Open
florianow
wants to merge
7
commits into
main
Choose a base branch
from
feature/validate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/validate #44
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
49e808d
ci: adding changes to the validate process
florianow cc81c0c
chore: adding tf stuff to git ignore
florianow 06f05a4
chore: remove cache files
florianow 4ab1753
ci: test script
florianow 3577e5c
ci: adding everything to pre-commit
florianow dadec5d
chore: adding files to modules
florianow 9fa4177
chore: adding "how to contribute"
florianow 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,26 +1,32 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
branches: [ main, feature/* ] | ||
pull_request: | ||
branches: [ main ] | ||
merge_group: | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- uses: meshcloud/setup-collie@main | ||
- name: Set up meshcloud collie CLI | ||
uses: meshcloud/setup-collie@main | ||
|
||
- uses: nixbuild/nix-quick-install-action@v26 | ||
- name: Install Nix | ||
uses: nixbuild/nix-quick-install-action@v26 | ||
with: | ||
nix_on_tmpfs: true | ||
|
||
- uses: rrbutani/use-nix-shell-action@v1 | ||
- name: Enter nix dev shell | ||
uses: rrbutani/use-nix-shell-action@v1 | ||
with: | ||
devShell: .#github_actions # use a special github actions shell | ||
devShell: .#github_actions | ||
|
||
- name: ensure all pre-commit hooks pass | ||
- name: Run pre-commit checks | ||
run: pre-commit run --all-files --show-diff-on-failure |
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 |
---|---|---|
|
@@ -50,3 +50,106 @@ Refer to each module's README.md for specific usage instructions such as needed | |
|
||
The meshStack Hub is a 🌤️ [cloudfoundation.org community](https://cloudfoundation.org/?ref=github-collie-cli) project. | ||
Reach out to us on the [cloudfoundation.org slack](http://cloudfoundationorg.slack.com). | ||
|
||
## 🛠️ How to Contribute | ||
|
||
Thank you for your interest in contributing Terraform modules or building blocks to **meshstack-hub**! To ensure high quality and consistency, please follow the steps below: | ||
|
||
--- | ||
|
||
### 1. Fork & Clone | ||
|
||
```bash | ||
git clone [email protected]:<your-username>/meshstack-hub.git | ||
cd meshstack-hub | ||
git checkout -b feature/your-module | ||
``` | ||
|
||
--- | ||
|
||
### 2. Enter Nix Development Shell | ||
|
||
The repository provides a `flake.nix` that includes pre-commit hooks, formatting, validation, and docs generation: | ||
|
||
```bash | ||
nix develop | ||
``` | ||
|
||
This prepares the environment with `terraform`, `terraform-docs`, `pre-commit`, and any other needed tools automatically. | ||
|
||
--- | ||
|
||
### 3. Write and Organize Your Terraform Module | ||
|
||
- Add your module under the correct provider folder (e.g. `aws/`, `azure/`, `gcp/`). | ||
- Include: | ||
- `main.tf`, `variables.tf`, `outputs.tf`, `versions.tf`, `providers.tf`, `APP_TEAM_README.md` | ||
- A `README.md` describing the module’s purpose and usage. | ||
|
||
--- | ||
|
||
### 4. Run Pre‑commit Hooks | ||
|
||
Hooks are already available in your shell: | ||
|
||
```bash | ||
pre-commit run --all-files | ||
``` | ||
|
||
They include checks like `terraform fmt`, `terraform validate` and automated docs via `terraform-docs`. | ||
|
||
Commiting will auto-run them: | ||
|
||
```bash | ||
git add . | ||
git commit -m "feat: add new vpc module" | ||
``` | ||
|
||
--- | ||
|
||
This is typically triggered via pre-commit hooks during commits. | ||
|
||
--- | ||
|
||
### 7. Add or Update Tests | ||
|
||
- Run them inside `nix develop`, for example: | ||
|
||
Ensure all tests pass and code/formats stay clean. | ||
|
||
--- | ||
|
||
### 8. Push & Open a Pull Request | ||
|
||
```bash | ||
git push origin feature/your-module | ||
``` | ||
|
||
In your PR description include: | ||
- Module purpose, inputs/outputs | ||
- Provider details | ||
- Any breaking changes or migration notes | ||
- Confirmation that all tests and checks passed | ||
|
||
--- | ||
|
||
### 9. Review & Merge | ||
|
||
CI will rerun all hooks/tests. A maintainer will review and merge or request adjustments. | ||
|
||
--- | ||
|
||
## ✅ Summary Checklist | ||
|
||
1. [ ] Module in the correct provider folder | ||
2. [ ] `main.tf`, `variables.tf`, `outputs.tf`, `README.md` | ||
3. [ ] `nix develop` used to enter environment ✅ | ||
4. [ ] `pre-commit run --all-files` passed ✅ | ||
5. [ ] `terraform init`, `validate`, `fmt` passed ✅ | ||
6. [ ] `terraform-docs markdown .` docs generated ✅ | ||
7. [ ] Tests added/updated and passing ✅ | ||
8. [ ] PR includes description & proof that all checks passed ✅ | ||
|
||
--- | ||
|
||
Thanks again for helping to improve **meshstack-hub**! 🚀 |
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,42 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
warnings=() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. d: i appreciate that AI generated script, but can't we use sth builtin for tflint maybe? (don't spend a ton of time reseaching this, the script is fine) |
||
|
||
# Required Terraform files | ||
common_tf_files=("main.tf" "variables.tf" "outputs.tf" "provider.tf" "versions.tf") | ||
readme_file="APP_TEAM_README.md" | ||
|
||
# Find relevant module directories | ||
mapfile -t paths_to_check < <(find modules/ -type d \( -path "*/buildingblock" -o -path "*/backplane" \)) | ||
|
||
if [ "${#paths_to_check[@]}" -eq 0 ]; then | ||
echo "❌ No Terraform module folders found." | ||
exit 1 | ||
fi | ||
|
||
# Check each directory silently unless a file is missing | ||
for path in "${paths_to_check[@]}"; do | ||
for tf_file in "${common_tf_files[@]}"; do | ||
if [[ ! -f "$path/$tf_file" ]]; then | ||
warnings+=("⚠️ '$tf_file' is missing in $path") | ||
fi | ||
done | ||
|
||
if [[ "$(basename "$path")" == "buildingblock" ]]; then | ||
if [[ ! -f "$path/$readme_file" ]]; then | ||
warnings+=("⚠️ '$readme_file' is missing in $path") | ||
fi | ||
fi | ||
done | ||
|
||
# Output only if something's wrong | ||
if [ "${#warnings[@]}" -gt 0 ]; then | ||
echo "❌ Issues detected:" | ||
for warn in "${warnings[@]}"; do | ||
echo "$warn" | ||
done | ||
exit 1 | ||
else | ||
exit 0 | ||
fi |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d: no longer needed?