Add interaction test #276
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Backend | |
on: | |
push: | |
branches: ['main'] | |
pull_request: | |
types: [opened, synchronize] | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
code-setup: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'backend/go.mod' | |
code-quality-check: | |
needs: code-setup | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'backend/go.mod' | |
- name: Format | |
run: if [ "$(gofmt -l -d ./backend | wc -l)" -gt 0 ]; then gofmt -l -d ./backend && exit 1; fi | |
- name: Check for GORM Debug | |
run: if [ "$(grep --exclude-dir migrations -rE 'DB.[\s\n]*Debug\(\)' ./backend | wc -l)" -gt 0 ]; then grep --exclude-dir migrations -rE 'DB.[\s\n]*Debug\(\)' ./backend && exit 1; fi | |
- name: Check for logrus without context | |
run: if [ "$(grep --exclude-dir migrations --exclude main.go --exclude recovery.go --exclude logging.go -rE '\s+log\.(Debug|Info|Warn|Error|Fatal)' ./backend | grep -v 'WithContext' | grep -v 'Level' | wc -l)" -gt 0 ]; then grep --exclude-dir migrations --exclude main.go --exclude recovery.go --exclude logging.go -rE '\s+log\.(Debug|Info|Warn|Error|Fatal)' ./backend | grep -v 'WithContext' | grep -v 'Level' && exit 1; fi | |
- name: Run linter | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
args: --config ./.golangci.yml --timeout 5m | |
working-directory: backend | |
# version: latest | |
# Pinning the version until https://github.com/golangci/golangci-lint/issues/3862 is solved | |
version: v1.52.2 | |
make-check: | |
needs: [code-setup] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'backend/go.mod' | |
- name: copy backend | |
run: | | |
mkdir tmp | |
cp -a backend/. tmp/ | |
- name: Make private graph | |
run: | | |
cd backend/ | |
make private-gen | |
- name: Make public graph | |
run: | | |
cd backend/ | |
make public-gen | |
- name: Diff Check | |
run: | | |
diff -r backend/ tmp/ | |
build: | |
needs: code-quality-check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'backend/go.mod' | |
- name: Build binary | |
run: cd backend/ && go build . | |
test: | |
needs: code-quality-check | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: ankane/pgvector | |
env: | |
POSTGRES_PASSWORD: postgres | |
POSTGRES_USER: postgres | |
POSTGRES_DB: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
clickhouse: | |
image: clickhouse/clickhouse-server:23.5.1.3174 | |
ports: | |
- 9000:9000 | |
redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
env: | |
CLICKHOUSE_ADDRESS: 'localhost:9000' | |
CLICKHOUSE_DATABASE: 'default' | |
CLICKHOUSE_TEST_DATABASE: 'test' | |
CLICKHOUSE_USERNAME: 'default' | |
CLICKHOUSE_PASSWORD: '' | |
PSQL_HOST: 'localhost' | |
PSQL_PORT: '5432' | |
PSQL_USER: 'postgres' | |
PSQL_DB: 'postgres' | |
PSQL_PASSWORD: 'postgres' | |
ENVIRONMENT: 'test' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: 'backend/go.mod' | |
- name: Run tests | |
run: cd backend && go test -p 1 ./... -v | |
- name: Run fuzz tests | |
run: cd backend && make fuzz |