|
| 1 | +--- |
| 2 | +name: E2E Configuration Tests |
| 3 | + |
| 4 | +# This workflow tests ONLY software configuration, release, and run phases |
| 5 | +# using Docker containers. It does NOT test infrastructure provisioning |
| 6 | +# (VMs/containers creation) as that is handled by the E2E Provision Tests |
| 7 | +# workflow. |
| 8 | +# |
| 9 | +# This workflow uses Docker containers instead of LXD VMs to avoid GitHub |
| 10 | +# Actions network connectivity issues within VMs that prevent software |
| 11 | +# installation. |
| 12 | +# |
| 13 | +# NETWORK TUNING: We use smorimoto/tune-github-hosted-runner-network to fix |
| 14 | +# flaky networking issues that cause Docker GPG key downloads to fail |
| 15 | +# intermittently in GitHub Actions. |
| 16 | +# See: https://github.com/actions/runner-images/issues/1187 and |
| 17 | +# https://github.com/actions/runner-images/issues/2890 |
| 18 | + |
| 19 | +on: |
| 20 | + push: |
| 21 | + branches: [main, develop] |
| 22 | + pull_request: |
| 23 | + branches: [main] |
| 24 | + workflow_dispatch: {} # Allow manual triggering |
| 25 | + |
| 26 | +jobs: |
| 27 | + e2e-config-tests: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + timeout-minutes: 45 # Timeout for complete configuration testing with software installation |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: Checkout repository |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Setup Rust toolchain |
| 36 | + uses: dtolnay/rust-toolchain@stable |
| 37 | + with: |
| 38 | + toolchain: stable |
| 39 | + |
| 40 | + - name: Cache Rust dependencies |
| 41 | + uses: Swatinem/rust-cache@v2 |
| 42 | + |
| 43 | + - name: Install Ansible |
| 44 | + run: ./scripts/setup/install-ansible.sh |
| 45 | + |
| 46 | + - name: Setup Docker |
| 47 | + uses: docker/setup-buildx-action@v3 |
| 48 | + |
| 49 | + - name: Verify installations |
| 50 | + run: | |
| 51 | + docker --version |
| 52 | + ansible --version |
| 53 | + cargo --version |
| 54 | +
|
| 55 | + - name: Build E2E configuration tests binary |
| 56 | + run: | |
| 57 | + cargo build --bin e2e-config-tests --release |
| 58 | +
|
| 59 | + - name: Run E2E configuration test |
| 60 | + run: | |
| 61 | + # Run the E2E configuration test with debug logging for better debugging |
| 62 | + echo "🚀 Starting E2E configuration test at $(date)" |
| 63 | + cargo run --bin e2e-config-tests |
| 64 | + echo "✅ E2E configuration test completed at $(date)" |
| 65 | + env: |
| 66 | + # Preserve environment variables for the E2E test |
| 67 | + RUST_LOG: debug |
| 68 | + |
| 69 | + - name: Get test outputs (on success) |
| 70 | + if: success() |
| 71 | + run: | |
| 72 | + echo "=== Docker Containers ===" |
| 73 | + docker ps -a || echo "No containers found" |
| 74 | +
|
| 75 | + echo "=== Docker Images ===" |
| 76 | + docker images || echo "No images found" |
| 77 | +
|
| 78 | + - name: Debug information (on failure) |
| 79 | + if: failure() |
| 80 | + run: | |
| 81 | + echo "=== Docker Status ===" |
| 82 | + docker ps -a || echo "Docker ps failed" |
| 83 | +
|
| 84 | + echo "=== Docker Logs ===" |
| 85 | + # Get logs from any containers that might still be running |
| 86 | + for container in $(docker ps -aq 2>/dev/null || true); do |
| 87 | + echo "=== Logs for container $container ===" |
| 88 | + docker logs "$container" 2>/dev/null || echo "Could not get logs for container $container" |
| 89 | + done |
| 90 | +
|
| 91 | + echo "=== System Resources ===" |
| 92 | + df -h |
| 93 | + free -h |
| 94 | +
|
| 95 | + echo "=== Recent logs ===" |
| 96 | + sudo journalctl --since "10 minutes ago" --no-pager | tail -50 || echo "Journal logs not available" |
| 97 | +
|
| 98 | + - name: Cleanup containers (always run) |
| 99 | + if: always() |
| 100 | + run: | |
| 101 | + echo "Cleaning up test containers..." |
| 102 | + # Clean up any remaining containers from the test |
| 103 | + docker ps -aq | xargs -r docker rm -f || echo "No containers to remove" |
| 104 | +
|
| 105 | + # Clean up any test images if needed |
| 106 | + docker images --filter "reference=torrust-provisioned-instance*" -q | xargs -r docker rmi -f || echo "No test images to remove" |
| 107 | +
|
| 108 | + - name: Final verification |
| 109 | + if: always() |
| 110 | + run: | |
| 111 | + echo "Verifying final cleanup..." |
| 112 | + docker ps -a |
| 113 | +
|
| 114 | + echo "=== Test Summary ===" |
| 115 | + echo "E2E configuration test workflow completed" |
| 116 | + if [ "${{ job.status }}" = "success" ]; then |
| 117 | + echo "✅ All configuration tests passed successfully" |
| 118 | + else |
| 119 | + echo "❌ Some configuration tests failed - check logs above" |
| 120 | + fi |
0 commit comments