Lint generated PHP code in CI #1325
Workflow file for this run
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: 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 | |
- 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 | |
run: phpstan analyze --memory-limit 256M -c .config/ci/php/phpstan.neon | |
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 |