Skip to content

Commit 48671fb

Browse files
committed
feat: update CI workflow for unit and e2e tests, including Docker integration
1 parent 069ba15 commit 48671fb

3 files changed

Lines changed: 69 additions & 18 deletions

File tree

‎.github/workflows/publish-coverage.yaml‎

Lines changed: 67 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,39 @@ on:
44
push:
55
branches:
66
- master
7+
workflow_dispatch: # for testing purposes to be deleted later
78

89

910
jobs:
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:
@@ -29,6 +57,12 @@ jobs:
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

‎run_e2e_tests.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ echo ""
8585
echo "[*] Running end-to-end tests..."
8686
echo ""
8787

88-
TEST_FLAGS="-v -tags=integration -timeout 10m"
88+
TEST_FLAGS="-v -tags=e2e -timeout 10m"
8989

9090
EXIT_CODE=0
9191

‎tests/e2e/end_to_end_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build integration
1+
//go:build e2e
22

33
package e2e
44

0 commit comments

Comments
 (0)