-
Notifications
You must be signed in to change notification settings - Fork 310
112 lines (109 loc) · 3.4 KB
/
go.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
107
108
109
110
111
112
name: Go Code
on:
pull_request:
paths:
- '.github/workflows/go.yml'
- '*.go'
- '.revive.toml'
- 'cmd/**'
- 'go.mod'
- 'go.sum'
- 'Makefile'
- 'pkg/**'
- '!pkg/webui/**'
- 'pkg/webui/**.go'
- 'tools/**'
jobs:
quality:
name: Code Quality
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install Go and Dependencies
uses: ./.github/actions/install-go-and-deps
- name: Build Mage
uses: ./.github/actions/build-mage
- name: Install Node and Dependencies
uses: ./.github/actions/install-node-and-deps
- name: Format code
run: tools/bin/mage go:fmt
- name: Run go generate
run: tools/bin/mage go:generate
- name: Generate i18n messages
run: tools/bin/mage go:messages
- name: Generate allowed fieldmask paths
run: tools/bin/mage jsSDK:allowedFieldMaskPaths
- name: Check for diff
run: tools/bin/mage git:diff
- name: Lint code
uses: golangci/golangci-lint-action@v6
with:
version: v1.62.2
only-new-issues: true
args: --timeout=10m ./pkg/... ./cmd/...
test:
name: Tests
runs-on: ubuntu-24.04
permissions:
contents: read
id-token: write
services:
postgres:
image: postgres
ports:
- '5432/tcp'
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:7
ports:
- '6379/tcp'
timeout-minutes: 15
steps:
- name: Create ttn_lorawan_is_test DB
uses: docker://postgres
env:
PGPASSWORD: root
with:
entrypoint: /usr/bin/createdb
args: -h postgres -U root ttn_lorawan_is_test
- name: Create ttn_lorawan_is_store_test DB
uses: docker://postgres
env:
PGPASSWORD: root
with:
entrypoint: /usr/bin/createdb
args: -h postgres -U root ttn_lorawan_is_store_test
- name: Configure AWS Credentials
if: "${{ env.AWS_REGION != '' }}"
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: '${{ secrets.AWS_REGION }}'
role-to-assume: 'arn:aws:iam::${{ secrets.AWS_USER_ID }}:role/${{ secrets.AWS_ROLE_NAME }}'
role-session-name: '${{ secrets.AWS_ROLE_NAME }}-${{ github.job }}-${{ github.run_id }}'
env:
AWS_REGION: '${{ secrets.AWS_REGION }}'
- name: Check out code
uses: actions/checkout@v4
- name: Install Go and Dependencies
uses: ./.github/actions/install-go-and-deps
- name: Build Mage
uses: ./.github/actions/build-mage
- name: Test binary execution
run: tools/bin/mage go:testBinaries
- name: Test code
env:
SQL_DB_ADDRESS: localhost:${{ job.services.postgres.ports['5432'] }}
SQL_DB_AUTH: 'root:root'
REDIS_ADDRESS: localhost:${{ job.services.redis.ports['6379'] }}
TEST_REDIS: '1'
TEST_SLOWDOWN: '8'
GCP_CREDENTIALS: ${{ secrets.GCP_TEST_CREDENTIALS }}
TEST_BUCKET: ttn-lorawan-test
run: tools/bin/mage go:test
- name: Check for diff
run: tools/bin/mage git:diff