HW#14 #86
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: 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 | |
POSTGRES_HOST_AUTH_METHOD: trust | |
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 | |
run: find . -iname "./migrations/*.sql" -exec psql --host=localhost --username=calendar --dbname=calendar -f {} \; | |
working-directory: hw12_13_14_15_calendar | |
- 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 |