Skip to content

Merge pull request #46 from ChandruWritesCode/44-feat-to-add-logout-b… #40

Merge pull request #46 from ChandruWritesCode/44-feat-to-add-logout-b…

Merge pull request #46 from ChandruWritesCode/44-feat-to-add-logout-b… #40

Workflow file for this run

name: Go Integration & Test Suite
on:
push:
pull_request:
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: ${{ vars.POSTGRES_USER || 'elephant_admin' }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD || 'local_test_password' }}
POSTGRES_DB: ${{ vars.POSTGRES_DB || 'elephant_messenger' }}
ports:
- 42359:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Set up Go runtime environment
uses: actions/setup-go@v5
with:
go-version: '1.26'
cache: true
cache-dependency-path: server/go.sum
- name: Run Go Vet Sanitation Checks
run: |
cd server
go vet ./...
- name: Run Advanced Staticcheck Compiler
uses: dominikh/staticcheck-action@v1
with:
version: "latest"
install-go: false
working-directory: "server"
- name: Execute Package Test Automation Suite
env:
HOST: ${{ vars.HOST || '127.0.0.1' }}
PORT: ${{ vars.PORT || '8080'}}
POSTGRES_USER: ${{ vars.POSTGRES_USER || 'elephant_admin' }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD || 'local_test_password' }}
POSTGRES_DB: ${{ vars.POSTGRES_DB || 'elephant_messenger' }}
POSTGRES_PORT: ${{ vars.POSTGRES_PORT || '42359' }}
POSTGRES_HOST: ${{ vars.POSTGRES_HOST || 'localhost' }}
JWT_SECRET: ${{ secrets.JWT_SECRET || 'testing_only_secret_key_string_32_chars' }}
ARGON_MEMORY: ${{ vars.ARGON_MEMORY || '65536' }}
ARGON_ITERATIONS: ${{ vars.ARGON_ITERATIONS || '1' }}
ARGON_PARALLELISM: ${{ vars.ARGON_PARALLELISM || '2'}}
run: |
cd server
sudo apt-get update && sudo apt-get install -y postgresql-client
PGPASSWORD="$POSTGRES_PASSWORD" psql -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -U "$POSTGRES_USER" -d "$POSTGRES_DB" \
-f migrations/001_create_users_up.sql \
-f migrations/002_create_refresh_tokens_up.sql \
-f migrations/003_add_search_indexes_up.sql \
-f migrations/004_create_message_up.sql \
-f migrations/005_create_message_status_up.sql \
-f migrations/006_create_groups_table_up.sql
go run main.go &
for i in $(seq 1 10); do
curl -sf http://$HOST:$PORT/api/health && break
echo "Waiting for server... attempt $i"
sleep 2
done
go test -v ./...