feat: exclude integration tests #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: main | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
PORT: ${{ secrets.PORT }} | |
GIN_MODE: ${{ secrets.GIN_MODE }} | |
LOG_LEVEL: ${{ secrets.LOG_LEVEL }} | |
LOG_OUTPUT: ${{ secrets.LOG_OUTPUT }} | |
AUTHORIZATION_URL: ${{ secrets.AUTHORIZATION_URL }} | |
POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }} | |
POSTGRES_PORT: ${{ secrets.POSTGRES_PORT }} | |
POSTGRES_USER: ${{ secrets.POSTGRES_USER }} | |
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
POSTGRES_DB: ${{ secrets.POSTGRES_DB }} | |
POSTGRES_URL: ${{ secrets.POSTGRES_URL }} | |
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
DB_URL: ${{ secrets.DB_URL }} | |
DEPLOY_HOOK: ${{ secrets.DEPLOY_HOOK }} | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: go.mod | |
- name: Cache Go dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Download dependencies | |
run: go mod download | |
- name: Build | |
run: go build -v ./... | |
- name: Test | |
run: | | |
make ci | |
security: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Run Snyk to check for Go vulnerabilities | |
uses: snyk/actions/golang@master | |
with: | |
args: --severity-threshold=critical | |
test: | |
needs: [build, security] | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
include: | |
- name: E2E Tests | |
test_command: go test -v ./e2e/... | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Docker Compose | |
run: docker-compose -f docker-compose.ci.yml up -d --build --no-cache | |
- name: Run project | |
run: ${{ matrix.test_command }} | |
- name: Check Docker Compose status | |
run: docker-compose -f docker-compose.ci.yml ps | |
- name: Get Docker Compose logs on failure | |
if: failure() | |
run: docker-compose -f docker-compose.ci.yml logs | |
- name: Tear Down | |
if: always() | |
run: docker-compose -f docker-compose.ci.yml down | |
migrate: | |
needs: [test] | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Run database migrations | |
run: | | |
docker run --rm \ | |
-v $(pwd)/migrations:/migrations \ | |
migrate/migrate \ | |
-path /migrations \ | |
-database "${{ env.DB_URL }}" \ | |
up | |
deploy: | |
needs: [migrate] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy API to Render | |
run: | | |
curl -X POST \ | |
-H "Content-Type: application/json" \ | |
-d '{"branch": "main"}' \ | |
${{ env.DEPLOY_HOOK }} |