Skip to content

Commit

Permalink
Adds Workflow and Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
jannikf02 committed Aug 12, 2024
1 parent f9f3315 commit fc8ac6f
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
52 changes: 52 additions & 0 deletions .github/workflows/go-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/backend/aashub/main.go",
"program": "${workspaceFolder}/backend/aashub/cmd/aashub/main.go",
"env": {},
"args": []
}
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"go.buildFlags": ["-tags=unit,integration"],
"go.testFlags": ["-tags=unit,integration"],
"[json]": {
"editor.insertSpaces": true,
"editor.formatOnSave": true,
Expand Down
15 changes: 15 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@
},
"problemMatcher": [],
"detail": "Fix code formatting using Prettier"
},
{
"label": "Build Go Docs",
"type": "shell",
"command": "swag",
"args": ["init", "-g", "cmd/aashub/main.go", "--parseDependency", "--parseInternal", "-o", "docs"],
"options": {
"cwd": "${workspaceFolder}/backend/aashub"
},
"group": {
"kind": "build",
"isDefault": false
},
"problemMatcher": [],
"detail": "Build Go documentation using Swag"
}
]
}

0 comments on commit fc8ac6f

Please sign in to comment.