Skip to content

Commit 5d0350d

Browse files
committed
Add GitHub Actions workflow for testing Movie Rating API
1 parent 0042e0c commit 5d0350d

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.github/workflows/test.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Test Movie Rating API
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
services:
14+
postgres:
15+
image: postgres:13
16+
env:
17+
POSTGRES_PASSWORD: postgres
18+
POSTGRES_DB: test_db
19+
options: >-
20+
--health-cmd pg_isready
21+
--health-interval 10s
22+
--health-timeout 5s
23+
--health-retries 5
24+
ports:
25+
- 5432:5432
26+
27+
steps:
28+
- uses: actions/checkout@v3
29+
30+
- name: Set up Go
31+
uses: actions/setup-go@v3
32+
with:
33+
go-version: 1.23
34+
35+
- name: Install dependencies
36+
run: |
37+
go mod tidy
38+
39+
- name: Run unit tests
40+
run: go test -v ./...
41+
42+
- name: Build application
43+
run: go build -o robin-camp
44+
45+
- name: Validate OpenAPI specifications
46+
run: |
47+
npm install -g @apidevtools/swagger-cli
48+
npx swagger-cli validate .github/workflows/openapi.yml
49+
npx swagger-cli validate .github/workflows/boxoffice.openapi.yml
50+
51+
- name: Run end-to-end tests
52+
run: |
53+
chmod +x ./e2e-test.sh
54+
./e2e-test.sh
55+
env:
56+
AUTH_TOKEN: test_token
57+
DB_URL: postgres://postgres:postgres@localhost:5432/test_db?sslmode=disable
58+
BOXOFFICE_URL: https://mock.apifox.com/m1/4288164-0-default
59+
BOXOFFICE_API_KEY: test_api_key

0 commit comments

Comments
 (0)