44 push :
55 branches :
66 - master
7+ workflow_dispatch : # for testing purposes to be deleted later
78
89
910jobs :
10- test :
11- name : Run tests and collect coverage
11+ unit-tests :
12+ name : Run unit tests and upload coverage
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Checkout
16+ uses : actions/checkout@v4
17+ with :
18+ fetch-depth : 2
19+
20+ - name : Set up Go
21+ uses : actions/setup-go@v5
22+ with :
23+ go-version : " 1.24"
24+
25+ - name : Install dependencies
26+ run : go mod download
27+
28+ - name : Run unit tests with coverage
29+ run : go test -coverprofile=coverage.txt -covermode=atomic ./...
30+
31+ - name : Upload results to Codecov
32+ uses : codecov/codecov-action@v5
33+ with :
34+ token : ${{ secrets.CODECOV_TOKEN }}
35+ files : ./coverage.txt
36+ fail_ci_if_error : true
37+
38+ integration-and-e2e-tests :
39+ name : Run integration and e2e tests
1240 runs-on : ubuntu-latest
1341 services :
1442 docker :
2957 --health-interval=10s
3058 --health-timeout=5s
3159 --health-retries=5
60+ file-storage :
61+ image : seber/maxit-file-storage:latest
62+ env :
63+ APP_PORT : 8888
64+ ports :
65+ - 8888:8888
3266 steps :
3367 - name : Checkout
3468 uses : actions/checkout@v4
@@ -43,22 +77,39 @@ jobs:
4377 - name : Install dependencies
4478 run : go mod download
4579
46- - name : Run unit tests with coverage
47- run : go test -coverprofile=coverage-unit.txt -covermode=atomic ./...
48-
49- - name : Run integration tests with coverage
80+ - name : Run integration tests
5081 env :
5182 DOCKER_HOST : unix:///var/run/docker.sock
52- run : go test -tags=integration -coverprofile=coverage-integration.txt -covermode=atomic ./...
83+ run : go test -tags=integration ./...
84+
85+ - name : Build worker Docker image
86+ run : docker build -t worker:test .
5387
54- - name : Merge coverage reports
88+ - name : Run worker service
89+ env :
90+ DOCKER_HOST : unix:///var/run/docker.sock
5591 run : |
56- go install github.com/wadey/gocovmerge@latest
57- gocovmerge coverage-unit.txt coverage-integration.txt > coverage.txt
92+ docker run -d \
93+ --name worker-service \
94+ --network host \
95+ -v /var/run/docker.sock:/var/run/docker.sock \
96+ -e RABBITMQ_URL=amqp://guest:guest@localhost:5672/ \
97+ -e FILE_STORAGE_URL=http://localhost:8888 \
98+ -e DOCKER_HOST=unix:///var/run/docker.sock \
99+ worker:test
58100
59- - name : Upload results to Codecov
60- uses : codecov/codecov-action@v5
61- with :
62- token : ${{ secrets.CODECOV_TOKEN }}
63- files : ./coverage.txt
64- fail_ci_if_error : true
101+ - name : Wait for worker to be ready
102+ run : sleep 10
103+
104+ - name : Run e2e tests
105+ env :
106+ DOCKER_HOST : unix:///var/run/docker.sock
107+ run : go test -tags=e2e ./...
108+
109+ - name : Show worker logs on failure
110+ if : failure()
111+ run : docker logs worker-service
112+
113+ - name : Cleanup worker service
114+ if : always()
115+ run : docker rm -f worker-service || true
0 commit comments