refactor: refactoring pipeline file #31
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 }} | |
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: Build | |
run: go build -v ./... | |
- name: Test | |
run: go test -v ./internal/... | |
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 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Docker Compose | |
run: docker-compose -f docker-compose.ci.yml up -d --build | |
- name: Run project | |
run: make ci | |
- name: Set up Go for E2E tests | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: go.mod | |
- name: Run E2E tests | |
run: go test -v ./e2e/... | |
- name: Print Docker Compose status if failure | |
if: failure() | |
run: docker-compose -f docker-compose.ci.yml ps | |
- name: Print Docker Compose logs if 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 |