generated from OtusGolang/home_work
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (86 loc) · 2.71 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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: psql --host=localhost --username=calendar --dbname=calendar -f ./migrations/0001_create_events_table.sql -f ./migrations/0002_alter_events_table_add_notified.sql
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