@@ -17,27 +17,60 @@ jobs:
1717 uses : actions/setup-go@v5
1818 with :
1919 go-version : ' 1.24'
20+
21+ - name : Install dependencies
22+ run : go mod download
2023
2124 - name : Run tests
2225 run : |
2326 echo "Running Go tests..."
2427 go test -v -json ./... > test-results.json
2528
2629 - name : Report test results
27- uses : dorny/test-reporter@v1
30+ uses : dorny/test-reporter@v2
2831 if : always()
2932 with :
3033 name : Go Tests
3134 path : test-results.json
3235 reporter : golang-json
3336 fail-on-error : true
3437
35- integration-test :
36- name : Integration Test (${{ matrix.resolution }})
38+ build-image :
39+ name : Build Docker Image
3740 runs-on : ubuntu-latest
3841 needs : test
3942 if : needs.test.result == 'success'
4043
44+ steps :
45+ - name : Checkout code
46+ uses : actions/checkout@v4
47+
48+ - name : Set up Docker Buildx
49+ uses : docker/setup-buildx-action@v3
50+
51+ - name : Build and cache Docker image
52+ uses : docker/build-push-action@v5
53+ with :
54+ context : .
55+ push : false
56+ tags : stream-webpage:test-${{ github.run_id }}
57+ outputs : type=docker,dest=/tmp/stream-webpage-${{ github.run_id }}.tar
58+ cache-from : type=gha
59+ cache-to : type=gha,mode=max
60+
61+ - name : Upload Docker image artifact
62+ uses : actions/upload-artifact@v4
63+ with :
64+ name : docker-image-${{ github.run_id }}
65+ path : /tmp/stream-webpage-${{ github.run_id }}.tar
66+ retention-days : 1
67+
68+ integration-test :
69+ name : Integration Test (${{ matrix.resolution }})
70+ runs-on : ubuntu-latest
71+ needs : [test, build-image]
72+ if : needs.test.result == 'success' && needs.build-image.result == 'success'
73+
4174 strategy :
4275 matrix :
4376 resolution : [720p, 1080p, 2k]
@@ -62,16 +95,14 @@ jobs:
6295 - name : Checkout code
6396 uses : actions/checkout@v4
6497
65- - name : Set up Docker Buildx
66- uses : docker/setup-buildx-action@v3
67-
68- - name : Build Docker image
69- uses : docker/build-push-action@v5
98+ - name : Download Docker image artifact
99+ uses : actions/download-artifact@v4
70100 with :
71- context : .
72- push : false
73- tags : stream-webpage:test
74- load : true
101+ name : docker-image-${{ github.run_id }}
102+ path : /tmp
103+
104+ - name : Load Docker image
105+ run : docker load -i /tmp/stream-webpage-${{ github.run_id }}.tar
75106
76107 - name : Start stream-webpage container
77108 run : |
85116 -e RESOLUTION=${{ matrix.resolution }} \
86117 -e RTMP_URL=rtmp://localhost:1935/live/stream \
87118 -e WEBPAGE_URL="https://www.youtube.com/embed/xuCn8ux2gbs?autoplay=1&loop=1&playlist=xuCn8ux2gbs" \
88- stream-webpage:test
119+ stream-webpage:test-${{ github.run_id }}
89120
90121 - name : Setup FFmpeg
91122 uses : FedericoCarboni/setup-ffmpeg@v3
@@ -112,7 +143,7 @@ jobs:
112143 echo "Checking stream properties with ffprobe..."
113144 timeout 30 ffprobe -v quiet -print_format json -show_streams rtmp://localhost:1935/live/stream > stream_info.json 2>/dev/null || {
114145 echo "Stream not available yet, checking container logs..."
115- docker logs $(docker ps -q --filter ancestor= stream-webpage:test)
146+ docker logs stream-webpage
116147 docker logs $(docker ps -q --filter ancestor=tiangolo/nginx-rtmp)
117148 exit 1
118149 }
0 commit comments