Skip to content

HW#12

HW#12 #72

Workflow file for this run

name: Otus homework tests
on:
push:
branches:
- hw*
env:
GO111MODULE: "on"
jobs:
lint:
runs-on: ubuntu-latest
if: ${{ !contains(github.ref, 'calendar') }}
steps:
- name: Extract branch name
run: echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ~1.19
- name: Check out code
uses: actions/checkout@v3
- name: Linters
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.1
working-directory: ${{ env.BRANCH }}
tests:
runs-on: ubuntu-latest
if: ${{ !contains(github.ref, 'calendar') }}
steps:
- name: Extract branch name
run: echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ^1.19
- name: Check out code
uses: actions/checkout@v3
- name: Unit tests
run: go test -v -count=1 -race -timeout=1m ./...
working-directory: ${{ env.BRANCH }}
- name: Optimization tests
run: go test -v -count=1 -timeout=1m -tags bench ./...
if: env.BRANCH == 'hw10_program_optimization'
working-directory: ${{ env.BRANCH }}
- name: Bash tests
shell: bash
run: ./test.sh
if: contains('hw01_hello_otus hw07_file_copying hw08_envdir_tool hw11_telnet_client', env.BRANCH)
working-directory: ${{ env.BRANCH }}
tests_by_makefile:
runs-on: ubuntu-latest
if: contains(github.ref, 'calendar')
# services:
# postgres:
# image: postgres
# env:
# POSTGRES_DB: calendar
# POSTGRES_USER: calendar
# POSTGRES_PASSWORD: calendar
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
# ports:
# - 5432:5432
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ^1.20
- name: Check out code
uses: actions/checkout@v3
- name: Init database
uses: yakubique/postgresql-apply-migrations@v1.1
with:
migrations: './hw12_13_14_15_calendar/migrations'
host: localhost
username: calendar
password: calendar
db: calendar
#run: psql -h localhost -U calendar -d calendar -Wcalendar -f ./hw12_13_14_15_calendar/migrations/0001_create_events_table.sql
- name: make lint
run: make lint
working-directory: hw12_13_14_15_calendar
- name: make build
run: make build
working-directory: hw12_13_14_15_calendar
- name: make test
run: make test
working-directory: hw12_13_14_15_calendar