Skip to content

Commit

Permalink
feat: add github action test
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai committed Feb 21, 2024
1 parent 45cf3a1 commit b382505
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/node.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: "orakl node test"

on:
push:
branches-ignore:
- "master"
paths:
- "node/**"
jobs:
core-build:
runs-on: ubuntu-latest
timeout-minutes: 3

services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: orakl-test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

steps:
- uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.21.5"
check-latest: true
cache-dependency-path: |
./node/go.sum
- name: Run lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
working-directory: node
skip-pkg-cache: true
skip-build-cache: true
args: --timeout=10m

- name: Run Vet
run: |
cd ./node
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest
go vet
go vet -vettool=$(which shadow)
- name: Install golang-migrate
run: |
curl -L https://github.com/golang-migrate/migrate/releases/download/v4.17.0/migrate.linux-amd64.tar.gz | tar xvz
sudo mv ./migrate /usr/bin
- name: Migrate up
run: |
cd ./node
migrate -database "postgresql://postgres:postgres@localhost:5432/orakl-test?search_path=public&sslmode=disable" -verbose -path ./migrations up
- name: Install dependencies
run: |
cd ./node
go mod tidy
- name: Install task
run: |
sudo snap install task --classic
- name: Run test
run: |
cd ./node
task local:test
env:
DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/orakl-test?search_path=public"
REDIS_HOST: "localhost"
REDIS_PORT: "6379"
4 changes: 4 additions & 0 deletions node/taskfiles/taskfile.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ tasks:
dotenv: [".env"]
cmds:
- go test ./pkg/admin/tests -v
test:
cmds:
- task: test-db
- task: test-admin

0 comments on commit b382505

Please sign in to comment.