Skip to content

fix: increase wait time for worker readiness in end-to-end tests #26

fix: increase wait time for worker readiness in end-to-end tests

fix: increase wait time for worker readiness in end-to-end tests #26

name: Run tests and upload coverage
on:
push:
branches:
- master
- test/end-to-end # for testing purposes to be remoeved later
jobs:
unit-tests:
name: Run unit tests and upload coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
- name: Install dependencies
run: go mod download
- name: Run unit tests with coverage
run: go test -coverprofile=coverage.txt -covermode=atomic ./...
- name: Upload results to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt
fail_ci_if_error: true
integration-and-e2e-tests:
name: Run integration and e2e tests
runs-on: ubuntu-latest
services:
docker:
image: docker:dind
options: >-
--privileged
--health-cmd="docker ps"
--health-interval=10s
--health-timeout=5s
--health-retries=5
rabbitmq:
image: rabbitmq:3.13-management
ports:
- 5672:5672
- 15672:15672
options: >-
--health-cmd="rabbitmq-diagnostics -q ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
file-storage:
image: seber/maxit-file-storage:latest
env:
APP_PORT: 8888
ports:
- 8888:8888
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
- name: Install dependencies
run: go mod download
- name: Run integration tests
env:
DOCKER_HOST: unix:///var/run/docker.sock
run: go test -tags=integration ./...
- name: Build worker Docker image
run: docker build -t worker:test .
- name: Run worker service
env:
DOCKER_HOST: unix:///var/run/docker.sock
run: |
docker run -d \
--name worker-service \
-v /var/run/docker.sock:/var/run/docker.sock \
-e RABBITMQ_HOST=rabbitmq \
-e RABBITMQ_PORT=5672 \
-e RABBITMQ_USER=guest \
-e RABBITMQ_PASSWORD=guest \
-e STORAGE_HOST=file-storage \
-e STORAGE_PORT=8888 \
-e DOCKER_HOST=unix:///var/run/docker.sock \
worker:test
- name: Wait for worker to be ready
run: sleep 10
- name: Run e2e tests
env:
DOCKER_HOST: unix:///var/run/docker.sock
run: go test -tags=e2e ./...
- name: Show worker logs on failure
if: failure()
run: docker logs worker-service || docker logs file-storage
- name: Cleanup worker service
if: always()
run: docker rm -f worker-service || true