Skip to content

Commit f696347

Browse files
committed
Merge #150: Split E2E tests in pre-commit script for GitHub Actions compatibility
05ee4b0 docs: [#146] update documentation for split E2E test execution (copilot-swe-agent[bot]) af2846e chore: [#146] replace e2e-tests-full with split tests in pre-commit script (copilot-swe-agent[bot]) 17bbe8d Initial plan (copilot-swe-agent[bot]) Pull request description: GitHub Copilot agents run in GitHub Actions environments where LXD VM networking is broken ([actions/runner-images#13003](actions/runner-images#13003)). The pre-commit script's `e2e-tests-full` cannot run there, blocking automated commits. ## Changes **`scripts/pre-commit.sh`** - Split single E2E test step into two GitHub runner-compatible steps: - `e2e-provision-and-destroy-tests` - LXD VM lifecycle (no nested networking) - `e2e-config-tests` - Docker-based configuration tests - Maintains identical coverage, now 7 steps instead of 6 **`docs/contributing/commit-process.md`** - Updated checklist to reflect split execution - Added section explaining split strategy and when to use `e2e-tests-full` locally **`.github/copilot-instructions.md`** - Fixed binary name typo (`e2e-provision-tests` → `e2e-provision-and-destroy-tests`) - Clarified pre-commit hook behavior ```bash # Before (fails in GitHub Actions) "Running comprehensive E2E tests|...|RUST_LOG=warn|cargo run --bin e2e-tests-full" # After (GitHub Actions compatible) "Running E2E provision and destroy tests|...|RUST_LOG=warn|cargo run --bin e2e-provision-and-destroy-tests" "Running E2E configuration tests|...|RUST_LOG=warn|cargo run --bin e2e-config-tests" ``` Developers can still run `cargo run --bin e2e-tests-full` manually for single-command local testing. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Update Pre-Commit Script for GitHub Runner-Compatible E2E Tests</issue_title> > <issue_description>## Overview > > Update the pre-commit verification script (`scripts/pre-commit.sh`) to run GitHub runner-compatible E2E tests instead of the full E2E test suite. This enables GitHub Copilot agents to successfully execute pre-commit checks in GitHub Actions environments where LXD VM network connectivity is limited. > > ## Specification > > See detailed specification: [docs/issues/update-precommit-script-for-github-runner-compatible-e2e-tests.md](https://github.com/torrust/torrust-tracker-deployer/blob/main/docs/issues/update-precommit-script-for-github-runner-compatible-e2e-tests.md) > > ## Problem Statement > > The pre-commit script currently runs `e2e-tests-full` which: > - Requires LXD VMs with full network connectivity > - Cannot run on GitHub Actions runners due to known networking limitations with nested virtualization > - Prevents GitHub Copilot agents from executing pre-commit checks > > ## Solution > > Replace the single `e2e-tests-full` step with two GitHub runner-compatible tests: > 1. `e2e-provision-and-destroy-tests` - Infrastructure lifecycle testing > 2. `e2e-config-tests` - Software installation and configuration testing > > ## Implementation Plan > > ### Phase 1: Update Pre-Commit Script (30 minutes) > > - [ ] Task 1.1: Replace the E2E full test step with provision and destroy test step > - [ ] Task 1.2: Add the configuration test step after provision and destroy test step > - [ ] Task 1.3: Verify step numbering and total step count are correct > - [ ] Task 1.4: Test the script locally to ensure both tests run successfully > > ### Phase 2: Documentation Updates (15 minutes) > > - [ ] Task 2.1: Update `docs/contributing/commit-process.md` to document the split E2E test execution > - [ ] Task 2.2: Update `.github/copilot-instructions.md` if needed > - [ ] Task 2.3: Ensure documentation clarifies when to use E2E full tests vs split tests > > ### Phase 3: Validation (15 minutes) > > - [ ] Task 3.1: Run `./scripts/pre-commit.sh` locally to verify both E2E tests execute > - [ ] Task 3.2: Verify pre-commit script passes when both E2E tests succeed > - [ ] Task 3.3: Verify pre-commit script fails when either E2E test fails > - [ ] Task 3.4: Run shellcheck on the modified script > > ## Acceptance Criteria > > **Quality Checks**: > > - [ ] Pre-commit checks pass: `./scripts/pre-commit.sh` > - [ ] Shellcheck passes for `scripts/pre-commit.sh` > > **Task-Specific Criteria**: > > - [ ] Pre-commit script runs provision and destroy E2E tests > - [ ] Pre-commit script runs configuration E2E tests > - [ ] Both E2E test steps execute in sequence > - [ ] Script succeeds when both tests pass > - [ ] Script fails appropriately when either test fails > - [ ] Step numbering and count are correct > - [ ] Timing notes accurately describe each test's duration expectations > - [ ] Documentation reflects the split E2E test approach > > **Testing Criteria**: > > - [ ] Verify locally: `./scripts/pre-commit.sh` completes successfully > - [ ] Verify provision test step runs: Check for "Running E2E provision and destroy tests" message > - [ ] Verify config test step runs: Check for "Running E2E configuration tests" message > - [ ] Both test steps show success messages with timing > > ## Related > > - **Parent Epic**: #112 - Refactor and Improve E2E Test Execution > - **Depends On**: #121 - Install Git Pre-Commit Hooks for Copilot Agent > - **Related**: #120 - Configure GitHub Copilot Agent Environment > > ## Time Estimate > > **Total**: 1-1.5 hours > > - Script modification: 30 minutes > - Documentation updates: 15 minutes > - Testing and validation: 15 minutes > - Buffer for edge cases: 15 minutes</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > <comment_new><author>@josecelano</author><body> > ## Specification > > Full specification document: [docs/issues/146-1-6-update-precommit-script-for-github-runner-compatible-e2e-tests.md](https://github.com/torrust/torrust-tracker-deployer/blob/main/docs/issues/146-1-6-update-precommit-script-for-github-runner-compatible-e2e-tests.md)</body></comment_new> > </comments> > </details> - Fixes #146 <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. ACKs for top commit: josecelano: ACK 05ee4b0 Tree-SHA512: 6b92a41f9c39ee755f09f527a9ba0172158c4e8d2d1868098c5a65fb878e662a4b32f20bdb645150ce6666b10c366f4ae69dcf32ea66ca852e66aaaadc0f5bc0
2 parents be7981a + 05ee4b0 commit f696347

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

.github/copilot-instructions.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ These principles should guide all development decisions, code reviews, and featu
119119
- **Unit Tests**: When writing unit tests, follow conventions described in [`docs/contributing/testing/`](../docs/contributing/testing/)
120120
- **E2E Tests**:
121121
- `cargo run --bin e2e-tests-full` - Comprehensive tests (⚠️ **LOCAL ONLY** - cannot run on GitHub Actions due to network connectivity issues)
122-
- `cargo run --bin e2e-provision-tests` - Infrastructure provisioning tests
123-
- `cargo run --bin e2e-config-tests` - Configuration validation tests
122+
- `cargo run --bin e2e-provision-and-destroy-tests` - Infrastructure provisioning and destruction tests (GitHub runner-compatible)
123+
- `cargo run --bin e2e-config-tests` - Software installation and configuration tests (GitHub runner-compatible)
124+
- Pre-commit hook runs the split tests (`e2e-provision-and-destroy-tests` + `e2e-config-tests`) for GitHub Copilot compatibility
124125
- See [`docs/e2e-testing.md`](../docs/e2e-testing.md) for detailed information about CI limitations
125126

126127
Follow the project conventions and ensure all checks pass.

docs/contributing/commit-process.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,29 @@ This script runs all mandatory checks:
134134
2. **Run all linters**: `cargo run --bin linter all` (stable & nightly toolchains)
135135
3. **Run tests**: `cargo test`
136136
4. **Test documentation builds**: `cargo doc --no-deps --bins --examples --workspace --all-features`
137-
5. **Run E2E tests**: `cargo run --bin e2e-tests-full`
137+
5. **Run E2E provision and destroy tests**: `cargo run --bin e2e-provision-and-destroy-tests`
138+
6. **Run E2E configuration tests**: `cargo run --bin e2e-config-tests`
139+
7. **Run code coverage check**: `cargo cov-check` (informational only)
138140

139141
**All checks must pass** before committing. Fix any reported issues.
140142

143+
### E2E Test Execution Strategy
144+
145+
The pre-commit script runs E2E tests as **two separate commands** instead of a single comprehensive test:
146+
147+
- **Provision and Destroy Tests**: Test infrastructure lifecycle (LXD VMs)
148+
- **Configuration Tests**: Test software installation and configuration (Docker containers)
149+
150+
This split approach provides the same comprehensive coverage while being compatible with GitHub Actions runners. The split is necessary because GitHub Actions has networking limitations with nested LXD VMs that prevent the full E2E test suite from running.
151+
152+
**For local development**, you can still run the full E2E test suite manually for convenience:
153+
154+
```bash
155+
cargo run --bin e2e-tests-full
156+
```
157+
158+
This provides the same coverage in a single run but is only supported in local environments with proper LXD networking.
159+
141160
### Running Individual Linters
142161

143162
If you need to run specific linters for debugging:

scripts/pre-commit.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ declare -a STEPS=(
2020
"Running linters|All linters passed|||cargo run --bin linter all"
2121
"Running tests|All tests passed|||cargo test"
2222
"Testing cargo documentation|Documentation builds successfully|||cargo doc --no-deps --bins --examples --workspace --all-features"
23-
"Running comprehensive E2E tests|All E2E tests passed|(Filtering logs to WARNING level and above - this may take a few minutes)|RUST_LOG=warn|cargo run --bin e2e-tests-full"
23+
"Running E2E provision and destroy tests|Provision and destroy tests passed|(Testing infrastructure lifecycle - this may take a few minutes)|RUST_LOG=warn|cargo run --bin e2e-provision-and-destroy-tests"
24+
"Running E2E configuration tests|Configuration tests passed|(Testing software installation and configuration)|RUST_LOG=warn|cargo run --bin e2e-config-tests"
2425
"Running code coverage check|Coverage meets 75% threshold|(Informational only - does not block commits)||cargo cov-check"
2526
)
2627

0 commit comments

Comments
 (0)