-
Notifications
You must be signed in to change notification settings - Fork 1
52 lines (49 loc) · 1.65 KB
/
go-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Go Application Tests
on:
pull_request:
paths:
- 'backend/aashub/**'
push:
branches: [main]
paths:
- 'backend/aashub/**'
jobs:
unit-tests:
name: Run Unit Tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Get dependencies
working-directory: backend/aashub
run: go mod download
- name: Run unit tests
run: go test ./... -v -tags=unit
working-directory: backend/aashub
integration-tests:
name: Run Integration Tests
needs: unit-tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
- name: Start all services with Docker Compose
run: docker-compose -f ci/docker-compose.yml up -d
- name: Wait for services to be ready
run: |
until [ "$(docker inspect --format='{{.State.Health.Status}}' app)" == "healthy" ]; do
echo "Current health status: $(docker inspect --format='{{.State.Health.Status}}' app)"
sleep 5
done
- name: Run integration tests
run: docker exec app /bin/sh -c "cd /workspace/backend/aashub && go test ./... -tags=integration"
- name: Shutdown services
run: docker-compose -f ci/docker-compose.yml down