ci: fix failing tests

This commit is contained in:
Reinaldy Rafli 2021-11-09 00:08:06 +07:00
parent 9175fc2ea3
commit 64ef0c19d8
No known key found for this signature in database
GPG Key ID: CFDB9400255D8CB6
4 changed files with 86 additions and 115 deletions

View File

@ -1,4 +1,4 @@
name: API
name: CI
on:
push:
@ -6,9 +6,9 @@ on:
jobs:
api-build:
name: Build
name: API
runs-on: ubuntu-latest
container: golang:1.17
container: golang:1.17-buster
timeout-minutes: 15
services:
postgres:
@ -28,7 +28,7 @@ jobs:
ports:
- 5432:5432
redis:
image: redis:6.2-alpine
image: redis:6-alpine
ports:
- 6379:6379
defaults:
@ -39,17 +39,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- 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
run: go mod download
- name: Build
run: go build main.go
@ -84,3 +75,51 @@ jobs:
- uses: codecov/codecov-action@v2
with:
flags: api
client-build:
name: Client
runs-on: ubuntu-latest
container: node:14-buster
timeout-minutes: 15
defaults:
run:
working-directory: ./client
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Yarn
run: npm install -g yarn
- name: Installling dependencies
run: yarn install
- name: Lint
run: yarn lint
- name: Build
run: yarn build
env:
VITE_SENTRY_DSN: https://examplePublicKey@o0.ingest.sentry.io/0
VITE_NODE_ENV: development
VITE_API_ENDPOINT: https://jokesbapak2.herokuapp.com/v1
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT_CLIENT }}
with:
environment: production
set_commits: skip
version: ${{ github.sha }}

View File

@ -1,68 +0,0 @@
name: Client
on:
push:
branches: [ "master" ]
jobs:
client-build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: ./client
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2.1.5
with:
node-version: 14.x
- 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-
- name: Installling dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn
- name: Lint
run: yarn lint
- name: Build
run: yarn build
env:
VITE_SENTRY_DSN: https://examplePublicKey@o0.ingest.sentry.io/0
VITE_NODE_ENV: development
VITE_API_ENDPOINT: https://jokesbapak2.herokuapp.com/v1
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT_CLIENT }}
with:
environment: production
set_commits: skip
version: ${{ github.sha }}

View File

@ -8,6 +8,7 @@ jobs:
client-build:
name: Client
runs-on: ubuntu-latest
container: node:14-buster
timeout-minutes: 15
defaults:
run:
@ -17,26 +18,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2.1.5
with:
node-version: 14.x
- 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-
- name: Setup Yarn
run: npm install -g yarn
- name: Installling dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn
run: yarn install
- name: Lint
run: npx eslint --ext .svelte,.js,.ts --ignore-path .gitignore .
@ -62,7 +48,7 @@ jobs:
api-build:
name: API
runs-on: ubuntu-latest
container: golang:1.17
container: golang:1.17-buster
timeout-minutes: 15
services:
postgres:
@ -82,7 +68,7 @@ jobs:
ports:
- 5432:5432
redis:
image: redis:6.2-alpine
image: redis:6-alpine
ports:
- 6379:6379
defaults:
@ -93,17 +79,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- 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
run: go mod download
- name: Build
run: go build main.go

View File

@ -20,7 +20,25 @@ func TestGetSubmittedItems(t *testing.T) {
}
defer c.Release()
_, err = c.Exec(ctx, "INSERT INTO submission (id, link, created_at, author, status) VALUES ($1, $2, $3, $4, $5), ($6, $7, $8, $9, $10)", submissionData...)
tx, err := c.Begin(ctx)
if err != nil {
t.Error("an error was thrown:", err)
}
defer tx.Rollback(ctx)
_, err = tx.Exec(
ctx,
`INSERT INTO submission
(id, link, created_at, author, status)
VALUES
($1, $2, $3, $4, $5),
($6, $7, $8, $9, $10)`,
submissionData...)
if err != nil {
t.Error("an error was thrown:", err)
}
err = tx.Commit(ctx)
if err != nil {
t.Error("an error was thrown:", err)
}
@ -55,7 +73,12 @@ func TestGetterQueryBuilder(t *testing.T) {
}
if s != "SELECT * FROM submission WHERE TRUE AND author = $1 AND status = $2 LIMIT 15 OFFSET 10" {
t.Error("expected query to be", "SELECT * FROM submission WHERE TRUE AND author = $1 AND status = $2 LIMIT 15 OFFSET 15", "got:", s)
t.Error(
"expected query to be",
"SELECT * FROM submission WHERE TRUE AND author = $1 AND status = $2 LIMIT 15 OFFSET 15",
"got:",
s,
)
}
if i[0].(string) != "Test <example@test.com>" {