Skip to content

Commit 269580a

Browse files
committed
ops: refactored test for coverage
ops: added coverage to ci ops: fix ci i hope ops: fix ci i hope 2 ops: fix ci i hope 3 ops: fix ci i hope 4 ops: fix ci i hope 5 ops: fix ci i hope ops: setup ci yeah
1 parent fe0fca8 commit 269580a

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

.github/workflows/cov-test.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Continuous testing with coverage
2+
on:
3+
workflow_dispatch:
4+
schedule:
5+
- cron: "0 12,23 * * *"
6+
7+
jobs:
8+
covtest:
9+
name: Integration tests with coverage
10+
runs-on: ubuntu-latest
11+
services:
12+
postgres:
13+
image: postgres
14+
env:
15+
POSTGRES_PASSWORD: postgres
16+
POSTGRES_DB: gists
17+
POSTGRES_USER: postgres
18+
options: >-
19+
--health-cmd pg_isready
20+
--health-interval 10s
21+
--health-timeout 5s
22+
--health-retries 5
23+
ports:
24+
- 5432:5432
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Install Go toolchain
28+
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
29+
with:
30+
go-version: 1.23.0
31+
- uses: extractions/setup-just@v2
32+
- name: Run migrations
33+
run: go build -o main && chmod +x ./main && PORT="4000" PG_USER="postgres" PG_PASSWORD="postgres" PG_PORT="5432" PG_HOST="0.0.0.0" PG_DATABASE="gists" GOOGLE_KEY="" GOOGLE_SECRET="" GITHUB_KEY="" GITHUB_SECRET="" PUBLIC_URL="http://localhost:4000" APP_KEY="DUMP_APP_KEY_FOR_TEST" SMTP_HOST="" MAIL_SMTP="" MAIL_PASSWORD="" SMTP_PORT="" FRONTEND_URL="http://localhost:3000" ./main migrate
34+
- name: Run tests
35+
run: |
36+
export PORT="4000" PG_USER="postgres" PG_PASSWORD="postgres" PG_PORT="5432" PG_HOST="0.0.0.0" PG_DATABASE="gists" GOOGLE_KEY="" GOOGLE_SECRET="" GITHUB_KEY="" GITHUB_SECRET="" PUBLIC_URL="http://localhost:4000" APP_KEY="DUMP_APP_KEY_FOR_TEST" SMTP_HOST="" MAIL_SMTP="" MAIL_PASSWORD="" SMTP_PORT="" FRONTEND_URL="http://localhost:3000"
37+
just report-all
38+
- uses: actions/upload-artifact@v4
39+
with:
40+
name: coverage-result
41+
path: ./test/coverage/

.github/workflows/mr-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
- name: Run migrations
3232
run: go build -o main && chmod +x ./main && PORT="4000" PG_USER="postgres" PG_PASSWORD="postgres" PG_PORT="5432" PG_HOST="0.0.0.0" PG_DATABASE="gists" GOOGLE_KEY="" GOOGLE_SECRET="" GITHUB_KEY="" GITHUB_SECRET="" PUBLIC_URL="http://localhost:4000" APP_KEY="DUMP_APP_KEY_FOR_TEST" SMTP_HOST="" MAIL_SMTP="" MAIL_PASSWORD="" SMTP_PORT="" FRONTEND_URL="http://localhost:3000" ./main migrate
3333
- name: Run tests
34-
run: PORT="4000" PG_USER="postgres" PG_PASSWORD="postgres" PG_PORT="5432" PG_HOST="0.0.0.0" PG_DATABASE="gists" GOOGLE_KEY="" GOOGLE_SECRET="" GITHUB_KEY="" GITHUB_SECRET="" PUBLIC_URL="http://localhost:4000" APP_KEY="DUMP_APP_KEY_FOR_TEST" SMTP_HOST="" MAIL_SMTP="" MAIL_PASSWORD="" SMTP_PORT="" FRONTEND_URL="http://localhost:3000" go test ./tests/
34+
run: cd test && PORT="4000" PG_USER="postgres" PG_PASSWORD="postgres" PG_PORT="5432" PG_HOST="0.0.0.0" PG_DATABASE="gists" GOOGLE_KEY="" GOOGLE_SECRET="" GITHUB_KEY="" GITHUB_SECRET="" PUBLIC_URL="http://localhost:4000" APP_KEY="DUMP_APP_KEY_FOR_TEST" SMTP_HOST="" MAIL_SMTP="" MAIL_PASSWORD="" SMTP_PORT="" FRONTEND_URL="http://localhost:3000" go test

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
tmp
33
.env
44
api
5+
test/coverage

justfile

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ test-all:
55
cd test && go test
66

77
report-all:
8-
#!/usr/bin/env sh
9-
for file in gists storage storage server user utils organizations; do
10-
just report-test $file
11-
done
8+
for file in gists storage storage server user utils organizations; do just report-test $file; done
129

1310
report-test PACKAGE:
14-
cd test && go test -coverprofile=cov-{{PACKAGE}}.out -coverpkg=./../{{PACKAGE}} && go tool cover -html=cov-{{PACKAGE}}.out -o {{PACKAGE}}-coverage.html && rm cov-{{PACKAGE}}.out
11+
mkdir -p test/coverage
12+
cd test && go test -coverprofile=cov-{{PACKAGE}}.out -coverpkg=./../{{PACKAGE}} && go tool cover -html=cov-{{PACKAGE}}.out -o coverage/{{PACKAGE}}-coverage.html && rm cov-{{PACKAGE}}.out
1513

1614
test TEST:
1715
go test ./tests/{{TEST}} -v

0 commit comments

Comments
 (0)