76 lines
2.2 KiB
YAML
76 lines
2.2 KiB
YAML
name: Build and Test Payment Service
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop, 'feature/**' ]
|
|
paths:
|
|
- 'backend/functions/payment-service/**'
|
|
- 'backend/pkg/**'
|
|
- '.gitea/workflows/build-backend-payment.yml'
|
|
pull_request:
|
|
branches: [ main, develop ]
|
|
paths:
|
|
- 'backend/functions/payment-service/**'
|
|
- 'backend/pkg/**'
|
|
|
|
jobs:
|
|
build-and-test:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.25'
|
|
|
|
- name: Cache Go modules
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.cache/go-build
|
|
~/go/pkg/mod
|
|
key: ${{ runner.os }}-go-payment-${{ hashFiles('backend/functions/payment-service/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-go-payment-
|
|
|
|
- name: Download dependencies
|
|
working-directory: ./backend/functions/payment-service
|
|
run: go mod download
|
|
|
|
- name: Verify dependencies
|
|
working-directory: ./backend/functions/payment-service
|
|
run: go mod verify
|
|
|
|
- name: Run go vet
|
|
working-directory: ./backend/functions/payment-service
|
|
run: go vet ./...
|
|
|
|
- name: Run tests
|
|
working-directory: ./backend/functions/payment-service
|
|
run: go test -v -race -coverprofile=coverage.out ./...
|
|
|
|
- name: Build binary
|
|
working-directory: ./backend/functions/payment-service
|
|
run: go build -v -o payment-service main.go
|
|
|
|
- name: Build container image
|
|
working-directory: ./backend/functions/payment-service
|
|
run: |
|
|
podman build -t coppertone-payment-service:${{ github.sha }} -f Containerfile .
|
|
podman build -t coppertone-payment-service:latest -f Containerfile .
|
|
|
|
- name: Upload coverage
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: payment-service-coverage
|
|
path: backend/functions/payment-service/coverage.out
|
|
|
|
- name: Upload binary
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: payment-service-binary
|
|
path: backend/functions/payment-service/payment-service
|