Skip to content

Commit

Permalink
feat(database): add integration testing (#896)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockopp authored Jul 31, 2023
1 parent 02fcd74 commit adf4f65
Show file tree
Hide file tree
Showing 9 changed files with 2,322 additions and 10 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# name of the action
name: integration-test

# trigger on pull_request events that modify this file or any database files
on:
pull_request:
paths:
- '.github/workflows/integration-test.yml'
- 'database/**'

# pipeline to execute
jobs:
database:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:15-alpine
env:
POSTGRES_DB: vela
POSTGRES_PASSWORD: notARealPassword12345
POSTGRES_USER: vela
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

env:
POSTGRES_ADDR: postgres://vela:notARealPassword12345@localhost:5432/vela
SQLITE_ADDR: vela.db

steps:
- name: clone
uses: actions/checkout@v3

- name: install go
uses: actions/setup-go@v4
with:
# use version from go.mod file
go-version-file: 'go.mod'
cache: true
check-latest: true

- name: test
run: |
make integration-test
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:

- name: test
run: |
go test -race -covermode=atomic -coverprofile=coverage.out ./...
make test
- name: coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.out
file: coverage.out
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ fix:
@echo "### Fixing Go Code"
@go fix ./...

# The `integration-test` target is intended to run all integration tests for the Go source code.
.PHONY: integration-test
integration-test:
@echo
@echo "### Integration Testing"
INTEGRATION=1 go test -run TestDatabase_Integration ./...

# The `test` target is intended to run
# the tests for the Go source code.
#
Expand All @@ -99,18 +106,15 @@ fix:
test:
@echo
@echo "### Testing Go Code"
@go test -race ./...
@go test -race -covermode=atomic -coverprofile=coverage.out ./...

# The `test-cover` target is intended to run
# the tests for the Go source code and then
# open the test coverage report.
#
# Usage: `make test-cover`
.PHONY: test-cover
test-cover:
@echo
@echo "### Creating test coverage report"
@go test -race -covermode=atomic -coverprofile=coverage.out ./...
test-cover: test
@echo
@echo "### Opening test coverage report"
@go tool cover -html=coverage.out
Expand Down
2 changes: 1 addition & 1 deletion database/hook/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ hooks (
status TEXT,
link TEXT,
webhook_id INTEGER,
UNIQUE(repo_id, build_id)
UNIQUE(repo_id, number)
);
`
)
Expand Down
Loading

0 comments on commit adf4f65

Please sign in to comment.