Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit 8c75916

Browse files
committed
refactor: [#14] reorganize Makefile into infrastructure/application layers
- Restructure Makefile into clear hierarchical layers (infra-, app-, vm-, test-, dev-) - Rename commands for better clarity: test -> test-e2e, test-syntax -> lint - Remove backward compatibility for legacy commands (apply, destroy, ssh, etc.) - Update help output with grouped commands by layer for better discoverability - Update all scripts, tests, and documentation to use new command structure - Implement twelve-factor app deployment workflow separation - Infrastructure provisioning: make infra-apply (platform setup) - Application deployment: make app-deploy (Build + Release + Run stages) - VM access and debugging: make vm-ssh, vm-console, vm-status - Testing: make test-e2e (comprehensive), make lint (syntax), make test-unit - Development workflows: make dev-deploy, make dev-test, make dev-clean Updated files: - Makefile: Complete restructure with new command organization - CI workflow: Updated to use make infra-test-ci - Documentation: Updated all references to use new command names - Test scripts: Updated to use new infra/app health check commands - E2E test: Updated to use make lint instead of make test-syntax This refactoring improves command discoverability, follows twelve-factor app principles, and provides clear separation between infrastructure and application concerns while maintaining all existing functionality.
1 parent 732a297 commit 8c75916

File tree

11 files changed

+165
-149
lines changed

11 files changed

+165
-149
lines changed

.github/copilot-instructions.md

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -132,30 +132,30 @@ cd torrust-tracker-demo
132132
make install-deps
133133

134134
# 3. Setup SSH key for VMs
135-
make setup-ssh-key
135+
make infra-config-local
136136

137137
# 4. Test twelve-factor deployment workflow locally
138138
make infra-apply # Provision infrastructure (platform setup)
139139
make app-deploy # Deploy application (Build + Release + Run stages)
140-
make health-check # Validate deployment
141-
make ssh # Connect to VM
140+
make app-health-check # Validate deployment
141+
make vm-ssh # Connect to VM
142142
make infra-destroy # Cleanup
143143

144144
# 5. Run tests
145-
make test # Full infrastructure test
146-
make test-syntax # Syntax validation only
145+
make test-e2e # Full infrastructure test
146+
make lint # Syntax validation only
147147
```
148148

149149
### Main Commands
150150

151151
#### Twelve-Factor Workflow (Recommended)
152152

153-
| Command | Purpose |
154-
| ------------------- | ------------------------------------------------- |
155-
| `make infra-apply` | Provision infrastructure (platform setup) |
156-
| `make app-deploy` | Deploy application (Build + Release + Run stages) |
157-
| `make app-redeploy` | Redeploy application (Release + Run stages only) |
158-
| `make health-check` | Validate deployment health |
153+
| Command | Purpose |
154+
| ----------------------- | ------------------------------------------------- |
155+
| `make infra-apply` | Provision infrastructure (platform setup) |
156+
| `make app-deploy` | Deploy application (Build + Release + Run stages) |
157+
| `make app-redeploy` | Redeploy application (Release + Run stages only) |
158+
| `make app-health-check` | Validate deployment health |
159159

160160
#### Infrastructure Management
161161

@@ -171,19 +171,18 @@ make test-syntax # Syntax validation only
171171

172172
#### VM Access and Debugging
173173

174-
| Command | Purpose |
175-
| ----------------- | --------------------------------- |
176-
| `make ssh` | Connect to deployed VM |
177-
| `make console` | Access VM console (text-based) |
178-
| `make vm-console` | Access VM graphical console (GUI) |
174+
| Command | Purpose |
175+
| --------------------- | --------------------------------- |
176+
| `make vm-ssh` | Connect to deployed VM |
177+
| `make vm-console` | Access VM console (text-based) |
178+
| `make vm-gui-console` | Access VM graphical console (GUI) |
179179

180180
#### Testing and Validation
181181

182-
| Command | Purpose |
183-
| ------------------ | --------------------------------------- |
184-
| `make test` | Run complete infrastructure tests |
185-
| `make test-syntax` | Run syntax validation only |
186-
| `make lint` | Run all linting (alias for test-syntax) |
182+
| Command | Purpose |
183+
| ------------------ | --------------------------------- |
184+
| `make test-e2e` | Run complete infrastructure tests |
185+
| `make lint` | Run syntax validation only |
187186

188187
#### Legacy Commands (Deprecated)
189188

@@ -245,7 +244,7 @@ The twelve-factor **Build, Release, Run** stages apply to the application deploy
245244
1. **Initial Setup**: `make infra-apply``make app-deploy`
246245
2. **Code Changes**: `make app-redeploy` (skips infrastructure)
247246
3. **Infrastructure Changes**: `make infra-apply``make app-redeploy`
248-
4. **Validation**: `make health-check`
247+
4. **Validation**: `make app-health-check`
249248
5. **Cleanup**: `make infra-destroy`
250249

251250
### Git Workflow
@@ -408,8 +407,8 @@ The project implements intelligent sudo cache management to improve the user exp
408407

409408
```bash
410409
make install-deps # Install dependencies
411-
make setup-ssh-key # Configure SSH access
412-
make test-prereq # Verify setup
410+
make infra-config-local # Configure SSH access
411+
make infra-test-prereq # Verify setup
413412
```
414413

415414
3. **Install recommended VS Code extensions**:
@@ -439,7 +438,7 @@ The project implements intelligent sudo cache management to improve the user exp
439438
```bash
440439
make infra-apply # Deploy test VM
441440
make app-deploy # Deploy application
442-
make ssh # Verify access
441+
make vm-ssh # Verify access
443442
make infra-destroy # Clean up
444443
```
445444

@@ -448,7 +447,7 @@ The project implements intelligent sudo cache management to improve the user exp
448447
### For Infrastructure Changes
449448

450449
1. **Local testing first**: Always test infrastructure changes locally
451-
2. **Validate syntax**: Run `make test-syntax` before committing
450+
2. **Validate syntax**: Run `make lint` before committing
452451
3. **Document changes**: Update relevant documentation
453452
4. **Test twelve-factor workflow**: Ensure both infrastructure provisioning and application deployment work
454453
```bash
@@ -482,15 +481,15 @@ Be mindful of the execution context for different types of commands. The project
482481

483482
When executing commands on the remote VM, be aware of limitations with interactive sessions.
484483

485-
- **Problem**: The VS Code integrated terminal may not correctly handle commands that initiate a new interactive shell, such as `ssh torrust@<VM_IP>` or `make ssh`. The connection may succeed, but subsequent commands sent to that shell may not execute as expected, and their output may not be captured.
484+
- **Problem**: The VS Code integrated terminal may not correctly handle commands that initiate a new interactive shell, such as `ssh torrust@<VM_IP>` or `make vm-ssh`. The connection may succeed, but subsequent commands sent to that shell may not execute as expected, and their output may not be captured.
486485

487486
- **Solution**: Prefer executing commands non-interactively whenever possible. Instead of opening a persistent SSH session, pass the command directly to `ssh`.
488487

489488
- **Don't do this**:
490489

491490
```bash
492491
# 1. Log in
493-
make ssh
492+
make vm-ssh
494493
# 2. Run command (this might fail or output won't be seen)
495494
df -H
496495
```
@@ -569,7 +568,7 @@ This ensures that the command is executed and its output is returned to the prim
569568
**Pre-commit Testing Requirement**: ALWAYS run the CI test suite before committing any changes:
570569

571570
```bash
572-
make test-ci
571+
make infra-test-ci
573572
```
574573

575574
This command runs all unit tests that don't require a virtual machine, including:
@@ -581,7 +580,7 @@ This command runs all unit tests that don't require a virtual machine, including
581580
582581
Only commit if all CI tests pass. If any tests fail, fix the issues before committing.
583582
584-
**Note**: End-to-end tests (`make test`) are excluded from pre-commit requirements due to their longer execution time (~5-8 minutes), but running them before pushing is strongly recommended for comprehensive validation.
583+
**Note**: End-to-end tests (`make test-e2e`) are excluded from pre-commit requirements due to their longer execution time (~5-8 minutes), but running them before pushing is strongly recommended for comprehensive validation.
585584
586585
**Best Practice**: Always ask "Would you like me to commit these changes?" before performing any git state-changing operations.
587586

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
sudo ./install-opentofu.sh --install-method deb
2828
2929
- name: Run CI test suite
30-
run: make test-ci
30+
run: make infra-test-ci

0 commit comments

Comments
 (0)