-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (125 loc) · 4.18 KB
/
ci.yaml
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: CI
on:
pull_request: ~
push:
branches: [main] # so that we build a Go cache that can be re-used in PRs
env:
GO_VERSION: '1.21'
NODE_VERSION: '18'
PYTHON_VERSION: '3.12'
PHP_VERSION: '8.3'
DOCKER_TOOLS: false
jobs:
linters:
name: Linters
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Install vendors
run: make deps
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.54.2
# Done by setup-go
skip-pkg-cache: true
skip-build-cache: true
tests:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Install vendors
run: make deps
- name: Tests
run: make tests
registry:
name: Generate registry
runs-on: ubuntu-latest
strategy:
matrix:
kind_version: [next, v11.0.x, v10.4.x, v10.3.x, v10.2.x, v10.1.x]
steps:
- uses: actions/checkout@v4
- name: Use Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup PHP ${{ env.PHP_VERSION }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
tools: phpstan, psalm
extensions: none, curl, ctype, dom, mbstring, opcache, simplexml, tokenizer
ini-values: opcache.enable_cli=1
- name: Install mypy
run: python3 -m pip install mypy
- name: Install ts-node
run: npm install -g ts-node
- name: Clone kind-registry
run: git clone --depth=1 https://github.com/grafana/kind-registry.git ../kind-registry
- name: Run code generation
run: |
go run cmd/cli/main.go generate \
--config ./config/foundation_sdk.dev.yaml \
--parameters output_dir=./generated/%l,grafana_version=${{ matrix.kind_version == 'next' && 'main' || matrix.kind_version }},kind_registry_version=${{ matrix.kind_version }},go_package_root=github.com/grafana/cog/generated/go
- name: Compile generated Go code
run: |
for d in generated/go/*/ ; do
echo "Building $d"
go build "./$d"
done
- name: Compile generated Typescript code
run: |
for d in generated/typescript/src/*/ ; do
echo "Building $d"
ts-node "./$d"
done
- name: Lint generated Python code
run: mypy generated/python/
- name: Lint generated PHP code with phpstan
run: phpstan analyze --memory-limit 256M -c .config/ci/php/phpstan.neon
- name: Lint generated PHP code with psalm
run: psalm -c .config/ci/php/psalm.xml generated/php
examples:
name: Run examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install ts-node
run: npm install -g ts-node
- name: Install vendors
run: make deps
- name: Clone kind-registry
run: git clone --depth=1 https://github.com/grafana/kind-registry.git ../kind-registry
- name: Run code generation
run: |
go run cmd/cli/main.go generate \
--config ./config/foundation_sdk.dev.yaml \
--parameters kind_registry_version=next,grafana_version=main
- name: Run the Go example
run: |
go run ./examples/_go/*
- name: Run the Typescript example
run: |
ts-node examples/typescript