Skip to content

Cc 07 searchbar backend #63

Cc 07 searchbar backend

Cc 07 searchbar backend #63

Workflow file for this run

name: Go
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Enforce formatting
working-directory: ./api
run: gofmt -l . | grep ".go$" | xargs -r echo "Files not formatted:"
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Enforce linting
working-directory: ./api
run: |
lint_output=$(go vet ./...)
if [[ -n "$lint_output" ]]; then
echo "$lint_output"
echo "::error::Linting issues found"
exit 1
fi
test:
name: Test
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: backendbootcamp
ports:
- 5432:5432
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.19"
- name: Install Dependencies
working-directory: ./api
run: go mod tidy
- name: Build
working-directory: ./api/src
run: go build -v
- name: Init Database
run: SKIP_DOCKER=true ./scripts/init_db.sh
- name: Run Tests with Coverage
working-directory: ./api/tests
run: go test -race -coverprofile=coverage.txt -covermode=atomic
- name: Print Coverage
run: |
go tool cover -func=coverage.txt