Skip to content

Commit 1fe1955

Browse files
authored
fix: comprehensive CI/CD improvements and test infrastructure overhaul (#2)
## Summary This PR contains a comprehensive overhaul of the CI/CD pipeline and test infrastructure, including security improvements, test stability fixes, and new features. With 44 files changed, adding 1,265 lines and removing 392 lines across 37 commits. ## Major Changes ### 🔒 Security Enhancements - **GitHub Actions Security**: Pinned all GitHub Actions to commit SHAs instead of version tags to prevent supply chain attacks - **Pre-commit Hooks**: Added comprehensive security scanning with TruffleHog for secret detection ### 🏗️ CI/CD Infrastructure Improvements - **Modularized CI Workflow**: Extracted reusable workflows to `.github/workflows/reusable/` directory - **Added Validation Scripts**: Created shell scripts for various validation checks: - `check-case-conflicts.sh` - Prevents file naming conflicts - `check-line-endings.sh` - Ensures consistent line endings - `check-merge-conflicts.sh` - Detects merge conflict markers - `check-trailing-whitespace.sh` - Removes trailing whitespace - `validate-json.sh` & `validate-yaml.sh` - Configuration file validation - **CI Status Monitoring**: Added scripts for CI status checks and PR comment generation - **Pre-commit Workflow**: New comprehensive pre-commit workflow with security, validation, and conventional commits checks ### ✅ Test Infrastructure Improvements - **Test Database Setup**: Major overhaul of `scripts/prepare-test-db.sh`: - Updated to use `api_keys` table (was `api_tokens`) for consistency with schema changes - Improved reliability with better wait conditions and error handling - Added automatic pocket-id binary download with OS/architecture detection - Enhanced logging and debugging capabilities - **Test Isolation**: Fixed test naming conflicts by using random prefixes (`acctest.RandomWithPrefix`) - **Terraform Compatibility Testing**: Added matrix testing across Terraform versions 1.5.7, 1.6.6, 1.7.5, 1.8.5, and 1.9.8 ### 🚀 New Features - **User Data Source Enhancement**: Added username lookup support to the user data source - **Client-side Validation**: Added comprehensive validation to all resources: - URL validation for callback URLs - Email format validation - String length constraints - Required field validation ### 📝 Documentation Updates - Updated provider examples to remove version constraints - Enhanced user data source documentation with username lookup examples - Added markdownlint configuration (`.markdownlint.json`) for consistent documentation ### 🐛 Bug Fixes - Fixed API limitation handling for user disabled field - Resolved test environment setup issues with absolute paths - Fixed test failures due to naming conflicts - Corrected validation error messages to match expectations - Fixed CI workflow permission issues ### 🧪 Test Improvements - Enhanced test coverage with better assertions - Added random naming to prevent test conflicts - Improved test reliability with proper environment setup - Fixed groups data source test to handle dynamic group counts ## Files Changed (44 files) **CI/CD Workflows (12 files)**: - `.github/workflows/ci.yml` - `.github/workflows/pre-commit.yml` - `.github/workflows/reusable/*.yml` (10 files) **Scripts (11 files)**: - `scripts/prepare-test-db.sh` - Test database setup - `scripts/ci-status-check.sh` - CI status monitoring - `scripts/generate-ci-comment.sh` - PR comment generation - `scripts/validation/*.sh` (7 validation scripts) **Source Code (11 files)**: - Resource validation improvements in `internal/resources/` - Test improvements in `internal/provider/` - Data source enhancements in `internal/datasources/` **Configuration & Documentation (10 files)**: - `.markdownlint.json` - Markdown linting rules - `.pre-commit-config.yaml` - Pre-commit hook configuration - Documentation templates and examples ## Testing All tests are passing: - ✅ Unit tests - ✅ Integration tests - ✅ Acceptance tests - ✅ Terraform compatibility tests (5 versions) - ✅ Pre-commit checks
1 parent 726c897 commit 1fe1955

54 files changed

Lines changed: 1780 additions & 395 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
name: Breaking Change Proposal
3+
about: Propose a breaking change for a future major version
4+
title: '[BREAKING] '
5+
labels: 'breaking-change, needs-discussion'
6+
assignees: ''
7+
8+
---
9+
10+
## Breaking Change Summary
11+
12+
A clear and concise description of the proposed breaking change.
13+
14+
## Motivation
15+
16+
Why is this breaking change necessary? What problems does it solve that cannot be addressed in a backward-compatible way?
17+
18+
## Current Behavior
19+
20+
Describe how the provider currently works in this area.
21+
22+
## Proposed Behavior
23+
24+
Describe how the provider would work after this change.
25+
26+
## Migration Path
27+
28+
How would users migrate from the current behavior to the new behavior? Please provide:
29+
30+
- Clear migration steps
31+
- Example configurations (before and after)
32+
- Any tools or scripts that could help with migration
33+
34+
## Impact Assessment
35+
36+
- Which resources/data sources are affected?
37+
- Approximately how many users might be impacted?
38+
- What is the severity of the breaking change (minor adjustment vs. major refactoring)?
39+
40+
## Alternatives Considered
41+
42+
What alternatives have you considered that would not require a breaking change?
43+
44+
## Target Version
45+
46+
Which major version should include this breaking change? (e.g., v1.0.0, v2.0.0)
47+
48+
## Community Note
49+
50+
- Breaking changes require careful consideration and community input
51+
- Please vote on this issue by adding a 👍 reaction
52+
- Join the discussion to share your thoughts on the proposal
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
name: Bug Report
3+
about: Create a report to help us improve
4+
title: '[BUG] '
5+
labels: 'bug, needs-triage'
6+
assignees: ''
7+
8+
---
9+
10+
## Bug Description
11+
12+
A clear and concise description of what the bug is.
13+
14+
## Terraform Version
15+
16+
Run `terraform -v` to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.
17+
18+
## Provider Version
19+
20+
If you are not running the latest version of the provider, please upgrade because your issue may have already been fixed.
21+
22+
## Affected Resource(s)
23+
24+
Please list the resources as a list, for example:
25+
26+
- pocketid_user
27+
- pocketid_group
28+
29+
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
30+
31+
## Terraform Configuration Files
32+
33+
```hcl
34+
# Copy-paste your Terraform configuration here.
35+
# Please remove any sensitive information like API keys.
36+
```
37+
38+
## Debug Output
39+
40+
Please provide a link to a GitHub Gist containing the complete debug output: <https://www.terraform.io/docs/internals/debugging.html>. Please do NOT paste the debug output in the issue; just paste a link to the Gist.
41+
42+
## Expected Behavior
43+
44+
What should have happened?
45+
46+
## Actual Behavior
47+
48+
What actually happened?
49+
50+
## Steps to Reproduce
51+
52+
Please list the steps required to reproduce the issue, for example:
53+
54+
1. `terraform apply`
55+
56+
## Important Factoids
57+
58+
Are there anything atypical about your accounts that we should know? For example: Running in a VPN environment, using a proxy, etc.
59+
60+
## References
61+
62+
Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:
63+
64+
- #0000

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Security Vulnerability
4+
url: mailto:security@leer.dev
5+
about: Please report security vulnerabilities via email instead of GitHub issues
6+
- name: Terraform Provider Registry
7+
url: https://registry.terraform.io/providers/trozz/pocketid/latest
8+
about: View the provider documentation on the Terraform Registry
9+
- name: Community Discussion
10+
url: https://github.com/trozz/terraform-provider-pocketid/discussions
11+
about: Ask questions and discuss ideas with the community
12+
- name: Provider Development Guide
13+
url: https://developer.hashicorp.com/terraform/plugin/sdkv2
14+
about: Learn how to contribute to Terraform provider development
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: Documentation Issue
3+
about: Report issues or improvements needed in documentation
4+
title: '[DOCS] '
5+
labels: 'documentation, good first issue'
6+
assignees: ''
7+
8+
---
9+
10+
## Documentation Location
11+
12+
Please provide a link to the documentation page or file that needs improvement.
13+
14+
## Current Documentation
15+
16+
What does the documentation currently say? Please quote the relevant section if applicable.
17+
18+
## Issue Description
19+
20+
Please describe what is wrong, unclear, or missing in the documentation.
21+
22+
## Suggested Improvement
23+
24+
How would you improve this documentation? Please provide specific suggestions or even a draft of the improved text.
25+
26+
## Additional Context
27+
28+
Add any other context about the documentation issue here. For example:
29+
30+
- Did this cause confusion when trying to use the provider?
31+
- Are there missing examples?
32+
- Is the information outdated?
33+
34+
## Community Note
35+
36+
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
37+
- Documentation improvements are often good first issues for new contributors!
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: Feature Request
3+
about: Suggest an idea for this project
4+
title: '[FEATURE] '
5+
labels: 'enhancement, needs-triage'
6+
assignees: ''
7+
8+
---
9+
10+
## Is your feature request related to a problem? Please describe
11+
12+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
13+
14+
## Describe the solution you'd like
15+
16+
A clear and concise description of what you want to happen.
17+
18+
## Describe alternatives you've considered
19+
20+
A clear and concise description of any alternative solutions or features you've considered.
21+
22+
## Additional context
23+
24+
Add any other context or screenshots about the feature request here.
25+
26+
## Terraform Configuration
27+
28+
If applicable, please provide a sample Terraform configuration that demonstrates the desired functionality:
29+
30+
```hcl
31+
# Example of how you'd like to use this feature
32+
resource "pocketid_example" "this" {
33+
# proposed configuration
34+
}
35+
```
36+
37+
## Community Note
38+
39+
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
40+
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
41+
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
name: Provider Crash Report
3+
about: Report a provider crash or panic
4+
title: '[CRASH] '
5+
labels: 'bug, crash, priority-high'
6+
assignees: ''
7+
8+
---
9+
10+
## Crash Summary
11+
12+
Brief description of what you were doing when the provider crashed.
13+
14+
## Terraform Version
15+
16+
Run `terraform -v` to show the version.
17+
18+
## Provider Version
19+
20+
Version of terraform-provider-pocketid that crashed.
21+
22+
## Terraform Configuration
23+
24+
```hcl
25+
# Minimal configuration that reproduces the crash
26+
# Please remove any sensitive information
27+
```
28+
29+
## Crash Output
30+
31+
```
32+
# Please paste the full panic output here
33+
# This typically starts with "panic:" and includes a stack trace
34+
```
35+
36+
## Steps to Reproduce
37+
38+
1.
39+
2.
40+
3.
41+
42+
## Debug Logs
43+
44+
Please provide a link to a GitHub Gist containing the complete debug output leading up to the crash: <https://www.terraform.io/docs/internals/debugging.html>
45+
46+
## Environment Details
47+
48+
- Operating System:
49+
- Architecture (x86_64, arm64, etc.):
50+
- Any special network configuration (proxy, VPN, etc.):
51+
52+
## Workaround
53+
54+
Have you found any way to avoid the crash? If so, please describe.
55+
56+
## Note
57+
58+
Provider crashes are high-priority issues. We'll investigate as soon as possible.

.github/ISSUE_TEMPLATE/question.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: Question
3+
about: Ask a question about using the provider
4+
title: '[QUESTION] '
5+
labels: 'question'
6+
assignees: ''
7+
8+
---
9+
10+
## Question
11+
12+
A clear and concise description of your question.
13+
14+
## Terraform Version
15+
16+
Output of `terraform -v`:
17+
18+
## Provider Version
19+
20+
Version of terraform-provider-pocketid:
21+
22+
## What I'm Trying to Achieve
23+
24+
Describe what you're trying to accomplish. This helps us provide better guidance.
25+
26+
## What I've Tried
27+
28+
Please describe what you've already attempted, including:
29+
30+
- Terraform configuration snippets
31+
- Any error messages you've encountered
32+
- Documentation or examples you've referenced
33+
34+
## Additional Context
35+
36+
Add any other context about your question here.
37+
38+
## Note
39+
40+
- For general Terraform questions unrelated to this provider, please visit the [Terraform Community Forum](https://discuss.hashicorp.com/c/terraform-core)
41+
- Consider checking existing issues and discussions before posting
42+
- If this turns out to be a bug, we'll convert it to a bug report
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Security Vulnerability
3+
about: Please report security vulnerabilities via email to security@leer.dev
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
## STOP
11+
12+
Please do NOT create a public issue for security vulnerabilities.
13+
14+
Instead, please report security issues by emailing: <security@leer.dev>
15+
16+
Include:
17+
18+
- Description of the vulnerability
19+
- Steps to reproduce
20+
- Potential impact
21+
- Any suggested fixes
22+
23+
We will respond within 48 hours and work with you to understand and address the issue responsibly.
24+
25+
Thank you for helping keep terraform-provider-pocketid secure!

0 commit comments

Comments
 (0)