From c5eab0a63f26cf2eec9f9a442b3fa1d41919a9c6 Mon Sep 17 00:00:00 2001 From: David Colburn Date: Tue, 30 Jan 2024 16:16:25 -0800 Subject: [PATCH] parallel tests (#601) * parallel tests * try with single build * fix workflow * checkout with lfs --- .github/workflows/test-integration.yaml | 55 +++++++++++++++++++++---- test/runner.go | 28 +++++++++++-- 2 files changed, 72 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test-integration.yaml b/.github/workflows/test-integration.yaml index 6b978a4f..9d4d6857 100644 --- a/.github/workflows/test-integration.yaml +++ b/.github/workflows/test-integration.yaml @@ -39,8 +39,10 @@ on: - go.mod jobs: - integration: + build: runs-on: buildjet-8vcpu-ubuntu-2204 + outputs: + image: ${{ steps.docker-md.outputs.tags }} steps: - uses: actions/checkout@v4 with: @@ -51,25 +53,64 @@ jobs: path: | ~/go/pkg/mod ~/go/bin - ~/bin/protoc ~/.cache - key: egress + key: egress-integration-${{ hashFiles('**/go.sum') }} + restore-keys: egress-integration + - name: Docker metadata + id: docker-md + uses: docker/metadata-action@v5 + with: + images: livekit/egress-integration + tags: | + type=sha + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.21.6 + + - name: Download Go modules + run: go mod download + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + file: ./build/test/Dockerfile + push: true + platforms: linux/amd64 + tags: ${{ steps.docker-md.outputs.tags }} + labels: ${{ steps.docker-md.outputs.labels }} + + test: + needs: build + strategy: + matrix: + integration_type: [room, web, participant, track_composite, track] + runs-on: buildjet-8vcpu-ubuntu-2204 + steps: - uses: shogo82148/actions-setup-redis@v1 with: redis-version: '6.x' auto-start: true - run: redis-cli ping - - name: Build docker image - run: docker build -t egress-test -f ./build/test/Dockerfile . - - name: Run tests + env: + IMAGE: ${{needs.build.outputs.image}} run: | docker run --rm \ --network host \ -e GITHUB_WORKFLOW=1 \ -e EGRESS_CONFIG_STRING="$(echo ${{ secrets.EGRESS_CONFIG_STRING }} | base64 -d)" \ + -e INTEGRATION_TYPE="${{ matrix.integration_type }}" \ -e S3_UPLOAD="$(echo ${{ secrets.S3_UPLOAD }} | base64 -d)" \ -e GCP_UPLOAD="$(echo ${{ secrets.GCP_UPLOAD }} | base64 -d)" \ - egress-test + ${{ env.IMAGE }} diff --git a/test/runner.go b/test/runner.go index 8fd70f48..f54d34e5 100644 --- a/test/runner.go +++ b/test/runner.go @@ -79,15 +79,35 @@ func NewRunner(t *testing.T) *Runner { confString = string(b) } - r := &Runner{ - RoomName: fmt.Sprintf("egress-integration-%d", rand.Intn(100)), - Muting: false, - } + r := &Runner{} err := yaml.Unmarshal([]byte(confString), r) require.NoError(t, err) + switch os.Getenv("INTEGRATION_TYPE") { + case "room": + r.RoomTestsOnly = true + r.RoomName = fmt.Sprintf("room-integration-%d", rand.Intn(100)) + case "web": + r.WebTestsOnly = true + r.RoomName = fmt.Sprintf("web-integration-%d", rand.Intn(100)) + case "participant": + r.ParticipantTestsOnly = true + r.RoomName = fmt.Sprintf("participant-integration-%d", rand.Intn(100)) + case "track_composite": + r.TrackCompositeTestsOnly = true + r.RoomName = fmt.Sprintf("track-composite-integration-%d", rand.Intn(100)) + case "track": + r.TrackTestsOnly = true + r.RoomName = fmt.Sprintf("track-integration-%d", rand.Intn(100)) + default: + if r.RoomName == "" { + r.RoomName = fmt.Sprintf("egress-integration-%d", rand.Intn(100)) + } + } + conf, err := config.NewServiceConfig(confString) require.NoError(t, err) + r.ServiceConfig = conf if conf.ApiKey == "" || conf.ApiSecret == "" || conf.WsUrl == "" {