2021-07-16 09:10:40 +00:00
|
|
|
name: PR
|
|
|
|
|
2021-07-23 15:39:23 +00:00
|
|
|
on:
|
2021-07-16 09:10:40 +00:00
|
|
|
pull_request:
|
|
|
|
branches: [ "*" ]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
client-build:
|
|
|
|
name: Client
|
|
|
|
runs-on: ubuntu-latest
|
2021-09-26 19:14:03 +00:00
|
|
|
timeout-minutes: 15
|
2021-07-16 09:10:40 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: ./client
|
2021-07-23 15:39:23 +00:00
|
|
|
|
2021-07-16 09:10:40 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Setup Node
|
|
|
|
uses: actions/setup-node@v2.1.5
|
|
|
|
with:
|
|
|
|
node-version: 14.x
|
2021-07-23 15:39:23 +00:00
|
|
|
|
2021-07-16 09:10:40 +00:00
|
|
|
- name: Get yarn cache directory path
|
|
|
|
id: yarn-cache-dir-path
|
|
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
|
|
|
|
|
|
- name: cache node_modules
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-
|
2021-07-23 15:39:23 +00:00
|
|
|
|
2021-07-16 09:10:40 +00:00
|
|
|
- name: Installling dependencies
|
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
|
|
|
run: yarn
|
|
|
|
|
|
|
|
- name: Lint
|
2021-07-16 09:11:11 +00:00
|
|
|
run: npx eslint --ext .svelte,.js,.ts --ignore-path .gitignore .
|
2021-07-23 15:39:23 +00:00
|
|
|
|
2021-07-16 09:11:11 +00:00
|
|
|
- name: Formatting
|
|
|
|
run: npx prettier --check --ignore-path .gitignore --plugin-search-dir=. "./**/*.(ts|json|js|svelte)"
|
|
|
|
|
2021-07-16 09:10:40 +00:00
|
|
|
- name: Build
|
|
|
|
run: yarn build
|
|
|
|
env:
|
|
|
|
VITE_SENTRY_DSN: https://examplePublicKey@o0.ingest.sentry.io/0
|
|
|
|
VITE_NODE_ENV: development
|
2021-07-17 13:27:09 +00:00
|
|
|
VITE_API_ENDPOINT: https://jokesbapak2.herokuapp.com/v1
|
2021-07-16 09:10:40 +00:00
|
|
|
|
|
|
|
- name: Initialize CodeQL
|
|
|
|
uses: github/codeql-action/init@v1
|
|
|
|
with:
|
|
|
|
languages: javascript
|
|
|
|
|
|
|
|
- name: Perform CodeQL Analysis
|
|
|
|
uses: github/codeql-action/analyze@v1
|
|
|
|
|
|
|
|
api-build:
|
|
|
|
name: API
|
|
|
|
runs-on: ubuntu-latest
|
2021-07-17 11:27:26 +00:00
|
|
|
container: golang:1.16.6
|
2021-09-26 19:14:03 +00:00
|
|
|
timeout-minutes: 15
|
2021-07-17 11:27:26 +00:00
|
|
|
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
|
2021-07-16 09:10:40 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: ./api
|
2021-07-17 11:27:26 +00:00
|
|
|
|
2021-07-16 09:10:40 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
2021-07-17 11:27:26 +00:00
|
|
|
- name: cache go modules
|
2021-07-16 09:10:40 +00:00
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ~/go/pkg/mod
|
|
|
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-go-
|
2021-07-17 11:27:26 +00:00
|
|
|
|
2021-07-16 09:10:40 +00:00
|
|
|
- name: Installling dependencies
|
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
|
|
|
run: go mod vendor
|
2021-07-17 11:27:26 +00:00
|
|
|
|
2021-07-16 09:10:40 +00:00
|
|
|
- name: Build
|
|
|
|
run: go build main.go
|
2021-07-17 11:27:26 +00:00
|
|
|
|
2021-07-16 09:10:40 +00:00
|
|
|
- name: Run test & coverage
|
|
|
|
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
|
2021-07-17 11:27:26 +00:00
|
|
|
env:
|
|
|
|
ENV: development
|
|
|
|
PORT: 5000
|
|
|
|
DATABASE_URL: postgres://postgres:password@postgres:5432/jokesbapak2
|
|
|
|
REDIS_URL: redis://@redis:6379
|
2021-07-16 09:10:40 +00:00
|
|
|
|
|
|
|
- name: Initialize CodeQL
|
|
|
|
uses: github/codeql-action/init@v1
|
|
|
|
with:
|
|
|
|
languages: go
|
|
|
|
|
|
|
|
- name: Perform CodeQL Analysis
|
2021-07-19 18:35:21 +00:00
|
|
|
uses: github/codeql-action/analyze@v1
|
|
|
|
|
|
|
|
- uses: codecov/codecov-action@v2
|
|
|
|
with:
|
|
|
|
flags: api
|