Skip to content

Commit 0e56ac4

Browse files
authored
docs: update copilot instructions for clarity and structure (#338)
* docs: update copilot instructions for clarity and structure * docs: update biome schema version to 2.3.8 and remove peer dependencies from package-lock * docs: update copilot instructions for Node.js compatibility and code standards * docs: update copilot instructions and lint configuration for clarity and accuracy
1 parent 512d0fe commit 0e56ac4

File tree

4 files changed

+71
-96
lines changed

4 files changed

+71
-96
lines changed

.github/copilot-instructions.md

Lines changed: 69 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,100 @@
11
# Terraform Module Releaser
22

33
A GitHub Action written in TypeScript that automates versioning, releases, and documentation for Terraform modules in
4-
GitHub monorepos. The action creates module-specific Git tags, GitHub releases, pull request comments, and generates
5-
comprehensive wiki documentation.
4+
monorepos. Creates module-specific Git tags, GitHub releases, PR comments, and comprehensive wiki documentation.
65

7-
**Always reference these instructions first and fallback to search or Bash commands only when you encounter unexpected
8-
information that does not match the info here.**
6+
## Tech Stack
97

10-
## Working Effectively
8+
- **TypeScript 5.9+** with strict mode
9+
- **Node.js 22+** for local development (`.node-version`); compiles to Node.js 20+ compatible output
10+
- **Vitest** for testing with V8 coverage
11+
- **Biome** for linting/formatting (not ESLint/Prettier)
12+
- **@actions/core** and **@octokit** for GitHub integration
1113

12-
### Bootstrap and Build the Repository
14+
## Essential Commands
1315

14-
- Install Node.js dependencies: `npm ci --no-fund`
15-
- Run TypeScript type checking: `npm run typecheck`
16-
- Lint and format code: `npm run check`
16+
```bash
17+
# Format and lint (run before every commit)
18+
npm run check:fix
19+
npm run textlint:fix
1720

18-
### Testing
21+
# Type checking
22+
npm run typecheck
1923

20-
- Run full test suite: `npm run test` (requires GITHUB_TOKEN for some tests)
21-
- Run tests in watch mode during development: `npm run test:watch`
22-
23-
## Validation
24-
25-
### Required Environment Variables for Full Testing
24+
# Testing
25+
npm run test # Full test suite (requires GITHUB_TOKEN)
26+
npm run test:watch # Watch mode for development
27+
```
2628

27-
- `GITHUB_TOKEN` - Required for tests that interact with GitHub API. Without this, some tests will be skipped with clear
28-
error messages.
29+
## GITHUB_TOKEN Setup
2930

30-
### External Dependencies
31+
Integration tests require a valid GitHub token. Set it in your environment:
3132

32-
External dependencies like terraform-docs are automatically installed and handled during `npm run test` - no manual
33-
prerequisite downloads needed. Note that firewall restrictions may block some operations in certain environments.
33+
```bash
34+
# For current session
35+
export GITHUB_TOKEN="ghp_your_token_here"
3436

35-
### Manual Validation Scenarios
37+
# Or create .env file (add to .gitignore)
38+
echo "GITHUB_TOKEN=ghp_your_token_here" > .env
39+
```
3640

37-
- **Always validate TypeScript compilation**: Run `npm run typecheck` to catch type errors.
38-
- **Always test functionality**: Run `npm run test` to verify operation and functionality.
39-
- **Validate linting compliance**: Run `npm run check` to ensure code meets style requirements.
41+
## Project Structure
4042

41-
## Common Tasks
43+
```bash
44+
src/ # TypeScript source
45+
├── index.ts # Entry point
46+
├── ... # Core logic and utilities
47+
└── types/ # Type definitions
48+
__tests__/ # Tests (mirror src/)
49+
tf-modules/ # Example Terraform modules for testing
50+
dist/ # Compiled output (auto-generated)
51+
```
4252

43-
### Build and Test Workflow
53+
## Code Standards
4454

45-
- `npm ci --no-fund` -- Install dependencies
46-
- `npm run typecheck` -- Type checking
47-
- `npm run check` -- Lint/formatting code
48-
- `npm run test` -- Run full test suite
55+
**Naming:**
4956

50-
### Development
57+
- Functions/variables: `camelCase` (`parseModules`, `tagName`)
58+
- Types/interfaces: `PascalCase` (`TerraformModule`, `WikiConfig`)
59+
- Constants: `UPPER_SNAKE_CASE` (`WIKI_HOME_FILENAME`)
5160

52-
- Use `npm run test:watch` for continuous testing during development
53-
- Use `npm run check` to check linting without fixing
54-
- Always run `npm run check:fix` before committing or the CI (.github/workflows/lint.yml) will fail
61+
**Style:** Biome enforces all formatting automatically via `npm run check:fix`
5562

56-
### Working with the Action Locally
63+
## Development Workflow
5764

58-
- The action can be tested locally using the CI workflow configuration in `.github/workflows/ci.yml`
59-
- Test terraform modules are located in `tf-modules/` directory
60-
- Use GitHub Codespaces or Dev Containers for a consistent development environment (configuration in `.devcontainer/`)
65+
1. Make changes in `src/`
66+
2. Run `npm run check:fix && npm run textlint:fix` (autofix formatting)
67+
3. Run `npm run typecheck` (verify compilation)
68+
4. Run `npm run test` (ensure tests pass)
69+
5. Commit using [Conventional Commits](https://www.conventionalcommits.org/) format (e.g., `feat:`, `fix:`, `chore:`)
6170

62-
## Key Repository Structure
71+
**Commit Format:** We follow Conventional Commits with semantic versioning. Examples: `feat: add new feature`,
72+
`fix: resolve bug`, `chore: update dependencies`
6373

64-
```shell
65-
/home/runner/work/terraform-module-releaser/terraform-module-releaser/
66-
├── .devcontainer/ # Dev container configuration
67-
├── .github/workflows/ # CI/CD workflows (ci.yml, test.yml, lint.yml)
68-
├── __mocks__/ # Test mocks
69-
├── __tests__/ # Test files (mirror src/ structure)
70-
├── action.yml # GitHub Action metadata and inputs
71-
├── dist/ # Compiled action bundle (generated)
72-
├── package.json # Dependencies and scripts
73-
├── scripts/ # Utility scripts (changelog.js, parse-modules-test.ts)
74-
├── src/ # TypeScript source code
75-
│ ├── index.ts # Action entry point
76-
│ ├── main.ts # Main action logic
77-
│ ├── config.ts # Configuration handling
78-
│ ├── context.ts # GitHub Actions context
79-
│ ├── parser.ts # Terraform module discovery
80-
│ ├── terraform-module.ts # Module representation
81-
│ ├── wiki.ts # Wiki generation
82-
│ ├── terraform-docs.ts # Terraform documentation
83-
│ ├── releases.ts # GitHub releases
84-
│ ├── tags.ts # Git tags
85-
│ ├── pull-request.ts # PR comments
86-
│ └── types/ # TypeScript type definitions
87-
├── tf-modules/ # Example Terraform modules for testing
88-
├── biome.json # Biome linter/formatter configuration
89-
├── tsconfig.json # TypeScript configuration
90-
└── vitest.config.ts # Test configuration
91-
```
74+
## Testing Notes
9275

93-
## Linting and Formatting
76+
- Path aliases: `@/``src/`, `@/tests/``__tests__/`
77+
- Some tests download terraform-docs binary (requires internet)
78+
- Tests without GITHUB_TOKEN are automatically skipped
79+
- Test modules in `tf-modules/` directory
9480

95-
- Uses **Biome** (not Prettier or ESLint) for TypeScript linting and formatting
96-
- Configuration in `biome.json`
97-
- Super Linter runs in CI but defers TypeScript formatting to Biome
81+
## Boundaries
9882

99-
## Testing Framework
83+
**Always do:**
10084

101-
- Uses **Vitest** for testing with TypeScript support
102-
- Configuration in `vitest.config.ts`
103-
- Tests include both unit tests and integration tests with real GitHub API calls
104-
- Coverage reporting with V8 provider
105-
- Path aliases configured: `@/` points to `src/`, `@/tests/` to `__tests__/`
85+
- Run `npm run check:fix` before committing
86+
- Add/update tests for code changes
87+
- Follow TypeScript strict mode
88+
- Use existing patterns in codebase
10689

107-
## Known Limitations
90+
⚠️ **Ask first:**
10891

109-
- Some tests require `GITHUB_TOKEN` environment variable - they will be skipped with clear messages if not provided
110-
- Some tests require internet access to download terraform-docs binary
111-
- The action is designed to run in GitHub Actions environment with appropriate permissions
92+
- Adding new dependencies
93+
- Changing build configuration
94+
- Modifying GitHub Actions workflows
11295

113-
### Troubleshooting
96+
🚫 **Never do:**
11497

115-
- If API tests fail with "GITHUB_TOKEN environment variable must be set": Provide a valid GitHub token or skip
116-
integration tests
117-
- If build fails: Ensure Node.js 22 is installed (specified in `.node-version`)
118-
- If linting fails: Run `npm run check:fix` to autofix formatting issues
98+
- Commit without running lint/tests
99+
- Modify `dist/` manually (auto-generated)
100+
- Bypass TypeScript strict checks

.github/workflows/lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ jobs:
5555
VALIDATE_JAVASCRIPT_PRETTIER: false # Using biome
5656
VALIDATE_JSON_PRETTIER: false # Using biome
5757
VALIDATE_JSCPD: false # Using biome
58+
VALIDATE_MARKDOWN: false # Not needed, using textlint and prettier
5859
VALIDATE_TERRAFORM_FMT: false # Terraform modules here aren't needed (They're for testing only)
5960
VALIDATE_TERRAFORM_TFLINT: false # Terraform modules here aren't needed (They're for testing only)
6061
VALIDATE_TYPESCRIPT_STANDARD: false # Using biome

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.2.5/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
33
"vcs": {
44
"enabled": true,
55
"clientKind": "git",

package-lock.json

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)