✅Add e2e tests #612
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Main | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| jobs: | |
| main: | |
| name: Main Process | |
| runs-on: ubuntu-latest | |
| env: | |
| GO_VERSION: 1.23 | |
| GOLANGCI_LINT_VERSION: v1.63.4 | |
| YAEGI_VERSION: v0.16.1 | |
| CGO_ENABLED: 0 | |
| defaults: | |
| run: | |
| working-directory: ${{ github.workspace }}/go/src/github.com/${{ github.repository }} | |
| steps: | |
| # https://github.com/marketplace/actions/setup-go-environment | |
| - name: Set up Go ${{ env.GO_VERSION }} | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| # https://github.com/marketplace/actions/checkout | |
| - name: Check out code | |
| uses: actions/checkout@v5 | |
| with: | |
| path: go/src/github.com/${{ github.repository }} | |
| fetch-depth: 0 | |
| # https://github.com/marketplace/actions/cache | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ github.workspace }}/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| # https://golangci-lint.run/usage/install#other-ci | |
| - name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }} | |
| run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} | |
| - name: Install Yaegi ${{ env.YAEGI_VERSION }} | |
| run: curl -sfL https://raw.githubusercontent.com/traefik/yaegi/master/install.sh | bash -s -- -b $(go env GOPATH)/bin ${YAEGI_VERSION} | |
| - name: Setup GOPATH | |
| run: go env -w GOPATH=${{ github.workspace }}/go | |
| - name: Check and get dependencies | |
| run: | | |
| go mod tidy | |
| git diff --exit-code go.mod | |
| # git diff --exit-code go.sum | |
| go mod download | |
| go mod vendor | |
| # git diff --exit-code ./vendor/ | |
| - name: Lint and Tests | |
| run: make | |
| - name: Run tests with Yaegi | |
| run: make yaegi_test | |
| env: | |
| GOPATH: ${{ github.workspace }}/go | |
| integration: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v5 | |
| - name: Setup Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Install PowerShell and Pester | |
| run: | | |
| # Set non-interactive mode to avoid prompts | |
| export DEBIAN_FRONTEND=noninteractive | |
| sudo apt-get update | |
| sudo apt-get install -y wget apt-transport-https software-properties-common | |
| # Download and install Microsoft signing key and repository | |
| wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb" | |
| # Use dpkg with force-confdef and force-confold to handle config conflicts automatically | |
| sudo dpkg --force-confdef --force-confold -i packages-microsoft-prod.deb | |
| sudo apt-get update | |
| sudo apt-get install -y powershell | |
| # Install Pester testing framework | |
| pwsh -c "Install-Module -Name Pester -Force -Scope CurrentUser -SkipPublisherCheck" | |
| - name: Run Integration Tests | |
| shell: pwsh | |
| run: | | |
| # Run the integration test script (skip cleanup for log collection on failure) | |
| ./Test-Integration.ps1 -HttpTimeoutSeconds 60 -SkipDockerCleanup | |
| - name: Show logs on failure | |
| if: failure() | |
| run: | | |
| echo "=== Docker container status ===" | |
| docker ps -a | |
| echo "=== CrowdSec logs ===" | |
| docker logs crowdsec-test 2>/dev/null || echo "No CrowdSec container logs" | |
| echo "=== Traefik logs ===" | |
| docker logs traefik-test 2>/dev/null || echo "No Traefik container logs" | |
| echo "=== Traefik Access Logs ===" | |
| docker exec traefik-test cat /var/log/traefik/access.log 2>/dev/null || echo "No current Traefik access logs" | |
| echo "=== Traefik Access Logs Backup (from test runs) ===" | |
| docker exec traefik-test cat /var/log/traefik/access.log.bak 2>/dev/null || echo "No Traefik access logs backup" | |
| echo "=== Whoami logs ===" | |
| docker logs whoami-test 2>/dev/null || echo "No Whoami container logs" | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results | |
| path: test-results.xml | |
| if-no-files-found: ignore | |
| - name: Cleanup | |
| if: always() | |
| run: docker compose -f docker-compose.test.yml down -v --remove-orphans |