-
Notifications
You must be signed in to change notification settings - Fork 9
127 lines (106 loc) · 3.55 KB
/
Copy pathci-pr-checks.yaml
File metadata and controls
127 lines (106 loc) · 3.55 KB
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
name: CI - PR Checks
on:
pull_request:
branches:
- main
jobs:
# Detect if PR contains code changes (skip expensive checks for docs-only PRs)
check-code-changes:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
has_code_changes: ${{ steps.filter.outputs.code }}
steps:
- name: Checkout source
uses: actions/checkout@v7
- name: Check for code changes
uses: dorny/paths-filter@v4
id: filter
with:
filters: |
code:
- '!docs/**'
- '!**/*.md'
- '!LICENSE'
- '!OWNERS'
# Go: lint, build, and test
lint-and-test:
runs-on: ubuntu-latest
needs: check-code-changes
if: needs.check-code-changes.outputs.has_code_changes == 'true'
steps:
- name: Checkout source
uses: actions/checkout@v7
- name: Extract Go version from go.mod
run: sed -En 's/^go (.*)$/GO_VERSION=\1/p' go.mod >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: "${{ env.GO_VERSION }}"
cache-dependency-path: ./go.sum
- name: Download dependencies
run: go mod download
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.8.0
args: ""
- name: Build
run: make build
- name: Test
run: make test
# Python: lint and test (only if Python files exist)
python-lint-and-test:
runs-on: ubuntu-latest
needs: check-code-changes
if: needs.check-code-changes.outputs.has_code_changes == 'true'
steps:
- name: Checkout source
uses: actions/checkout@v7
- name: Check for Python files
id: check-python
run: |
if find . -name "*.py" -not -path "./.git/*" | head -1 | grep -q .; then
echo "has_python=true" >> "$GITHUB_OUTPUT"
else
echo "has_python=false" >> "$GITHUB_OUTPUT"
fi
- name: Set up Python
if: steps.check-python.outputs.has_python == 'true'
uses: actions/setup-python@v7
with:
python-version: "3.11"
- name: Install dependencies
if: steps.check-python.outputs.has_python == 'true'
run: pip install ./pkg/client/python
- name: Install ruff
if: steps.check-python.outputs.has_python == 'true'
# Pinned so lint results only change when we bump the version, not
# when ruff releases (0.16.0 introduced 101 new findings, see #116).
run: pip install ruff==0.15.22
- name: Run ruff check
if: steps.check-python.outputs.has_python == 'true'
run: ruff check .
- name: Run ruff format check
if: steps.check-python.outputs.has_python == 'true'
run: ruff format --check .
- name: Run unit tests
if: steps.check-python.outputs.has_python == 'true'
run: PYTHONPATH=pkg/client/python python -m unittest discover -s pkg/client/python/tests
# Container: build (no push) to validate Dockerfile
container-build:
runs-on: ubuntu-latest
needs: check-code-changes
if: needs.check-code-changes.outputs.has_code_changes == 'true'
steps:
- name: Checkout source
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build container (no push)
run: |
docker buildx build \
--platform linux/amd64 \
--tag test-build:pr-${{ github.event.pull_request.number }} \
.