Skip to content

Merge branch 'apisrv/refactor/update-action-node-version' into apisrv… #56

Merge branch 'apisrv/refactor/update-action-node-version' into apisrv…

Merge branch 'apisrv/refactor/update-action-node-version' into apisrv… #56

Workflow file for this run

name: APISRV Unit Tests
on:
push:
branches:
- "apisrv/test-workflow"
defaults:
run:
working-directory: "apisrv"
permissions:
contents: read
jobs:
test:
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
elasticsearch:
image: elasticsearch:8.5.3
env:
discovery.type: single-node
ports:
- 9200:9200
options: >-
--health-cmd "curl http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 3
strategy:
matrix:
go-version: [1.21.x] # [1.18.x, 1.19.x, 1.20.x, 1.21.x]
os: [ubuntu-latest] # [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Install Dependencies
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.1
- name: Run Lint
run: |
golangci-lint run -E gofmt -E stylecheck -E gocritic --verbose --timeout=3m --out-format=github-actions
- name: Run Unit Test
env:
TEST_REAL: "true"
POSTGRES_HOST: "0.0.0.0"
POSTGRES_PORT: "5432"
POSTGRES_USER: "postgres"
POSTGRES_NEWS_DB: "news"
PGPASSWORD: "postgres"
ES_URL: "http://0.0.0.0:9200"
ES_UNIT_TEST_INDEX: "unit_test_v1"
ES_UNIT_TEST_INDEX_ALIAS: "unit_test_index"
ES_UNIT_TEST_SEARCH_ALIAS: "unit_test_search"
ES_NEWS_DOC_INDEX: "news_docs_v1"
ES_NEWS_DOC_INDEX_ALIAS: "news_docs_index"
ES_NEWS_DOC_SEARCH_ALIAS: "news_docs_search"
DATA_DIR: "" # /home/runner/work/garage/garage/apisrv/data
run: |
export DATA_DIR="$(realpath ./data)/"
export PSQL_NEWS_DSN="host=$POSTGRES_HOST port=$POSTGRES_PORT dbname=$POSTGRES_NEWS_DB user=$POSTGRES_USER"
env
bash scripts/psql-unit_test-set_up.sh
bash scripts/es-unit_test-set_up.sh
bash scripts/es-news_category-set_up.sh
go test -race -covermode=atomic -coverprofile=coverage.out ./...
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
flags: apisrv
fail_ci_if_error: true
verbose: true