diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 91eccb8..bed8425 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -8,36 +8,58 @@ jobs: api-build: name: Build runs-on: ubuntu-latest + container: golang:1.16.6 + services: + postgres: + image: postgres:13-alpine + env: + PGDATABASE: jokesbapak2 + POSTGRES_DB: jokesbapak2 + PGUSER: postgres + POSTGRES_USER: postgres + PGPASSWORD: password + POSTGRES_PASSWORD: password + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + redis: + image: redis:6.2-alpine + ports: + - 6379:6379 defaults: run: working-directory: ./api - + steps: - name: Checkout code uses: actions/checkout@v2 - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: 1.16.x - - - name: cache node_modules + - name: cache go modules uses: actions/cache@v2 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - + - name: Installling dependencies if: steps.cache.outputs.cache-hit != 'true' run: go mod vendor - + - name: Build run: go build main.go - + - name: Run test & coverage run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./... + env: + ENV: development + PORT: 5000 + DATABASE_URL: postgres://postgres:password@postgres:5432/jokesbapak2 + REDIS_URL: redis://@redis:6379 - name: Initialize CodeQL uses: github/codeql-action/init@v1 diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 77532dd..80d84a6 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -33,7 +33,7 @@ jobs: key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- - + - name: Installling dependencies if: steps.cache.outputs.cache-hit != 'true' run: yarn diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 52602f3..10f3c7c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -61,36 +61,58 @@ jobs: api-build: name: API runs-on: ubuntu-latest + container: golang:1.16.6 + services: + postgres: + image: postgres:13-alpine + env: + PGDATABASE: jokesbapak2 + POSTGRES_DB: jokesbapak2 + PGUSER: postgres + POSTGRES_USER: postgres + PGPASSWORD: password + POSTGRES_PASSWORD: password + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + redis: + image: redis:6.2-alpine + ports: + - 6379:6379 defaults: run: working-directory: ./api - + steps: - name: Checkout code uses: actions/checkout@v2 - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: 1.16.x - - - name: cache node_modules + - name: cache go modules uses: actions/cache@v2 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- - + - name: Installling dependencies if: steps.cache.outputs.cache-hit != 'true' run: go mod vendor - + - name: Build run: go build main.go - + - name: Run test & coverage run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./... + env: + ENV: development + PORT: 5000 + DATABASE_URL: postgres://postgres:password@postgres:5432/jokesbapak2 + REDIS_URL: redis://@redis:6379 - name: Initialize CodeQL uses: github/codeql-action/init@v1