@cryptotaxi247 / netdata-1 / commits / 64c9bcaf8

Skip non-native builds in CI on PRs in most cases. (#20055)

* Skip non-native builds in CI on PRs in most cases. * Fix argument passing. * Fix missing output.

Austin S. Hemmelgarn committed Apr 8, 2025 at 06:58 UTC 64c9bcaf81e3a2ead3839eb449ea221cffffeb59
4 files changed +76 -2
.github/scripts/gen-matrix-docker.py
+5
@@ -1,16 +1,21 @@
1 #!/usr/bin/env python3
2
3 import json
4 +import sys
5
6 from ruamel.yaml import YAML
7
8 yaml = YAML(typ='safe')
9 entries = list()
10 +native_only = sys.argv[1]
11
12 with open('.github/data/distros.yml') as f:
13 data = yaml.load(f)
14
15 for arch in data['docker_arches']:
16 + if native_only == '1' and data['arch_data'][arch]['qemu']:
17 + continue
18 +
19 entries.append({
20 'arch': arch,
21 'platform': data['platform_map'][arch],
.github/scripts/gen-matrix-static.py
+5
@@ -1,16 +1,21 @@
1 #!/usr/bin/env python3
2
3 import json
4 +import sys
5
6 from ruamel.yaml import YAML
7
8 yaml = YAML(typ='safe')
9 entries = list()
10 +native_only = sys.argv[1]
11
12 with open('.github/data/distros.yml') as f:
13 data = yaml.load(f)
14
15 for arch in data['static_arches']:
16 + if native_only == '1' and data['arch_data'][arch]['qemu']:
17 + continue
18 +
19 entries.append({
20 'arch': arch,
21 'runner': data['arch_data'][arch]['runner'],
.github/workflows/build.yml
+31 -1
@@ -28,6 +28,7 @@ jobs:
28 outputs:
29 run: ${{ steps.check-run.outputs.run }}
30 skip-go: ${{ steps.check-go.outputs.skip-go }}
31 + static-native: ${{ steps.check-static.outputs.static-native }}
32 steps:
33 - name: Checkout
34 id: checkout
@@ -80,6 +81,21 @@ jobs:
81 files_ignore: |
82 **/*.md
83 packaging/repoconfig/
84 + - name: Check static build files
85 + id: check-static-build-files
86 + uses: step-security/changed-files@v45
87 + with:
88 + since_last_remote_commit: ${{ github.event_name != 'pull_request' }}
89 + files: |
90 + .github/data/distros.yml
91 + .github/workflows/build.yml
92 + .github/scripts/build-static.sh
93 + .github/scripts/get-static-cache-key.sh
94 + .github/scripts/gen-matrix-static.py
95 + packaging/makeself/
96 + files_ignore: |
97 + **/*.md
98 + packaging/repoconfig/
99 - name: List all changed files in pattern
100 continue-on-error: true
101 if: github.event_name != 'workflow_dispatch'
@@ -110,6 +126,18 @@ jobs:
126 else
127 echo 'skip-go=' >> "${GITHUB_OUTPUT}"
128 fi
129 + - name: Check Static
130 + id: check-static
131 + run: |
132 + if [ '${{ github.event_name }}' == 'pull_request' ]; then
133 + if [ "${{ steps.check-static-build-files.outputs.any_modified }}" == "true" ] || [ "${{ !contains(github.event.pull_request.labels.*.name, 'run-ci/non-native') }}" = "true" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
134 + echo 'static-native=0' >> "${GITHUB_OUTPUT}"
135 + else
136 + echo 'static-native=1' >> "${GITHUB_OUTPUT}"
137 + fi
138 + else
139 + echo 'static-native=0' >> "${GITHUB_OUTPUT}"
140 + fi
141
142 build-dist: # Build the distribution tarball and store it as an artifact.
143 name: Build Distribution Tarball
@@ -187,6 +215,8 @@ jobs:
215 static-matrix: # Generate the static build matrix.
216 name: Prepare Build Matrix
217 runs-on: ubuntu-latest
218 + needs:
219 + - file-check
220 outputs:
221 matrix: ${{ steps.set-matrix.outputs.matrix }}
222 steps:
@@ -201,7 +231,7 @@ jobs:
231 - name: Read build matrix
232 id: set-matrix
233 run: |
204 - matrix="$(.github/scripts/gen-matrix-static.py)"
234 + matrix="$(.github/scripts/gen-matrix-static.py "${{ needs.file-check.outputs.static-native }}")"
235 echo "Generated matrix: ${matrix}"
236 echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
237 - name: Failure Notification
.github/workflows/docker.yml
+35 -1
@@ -33,6 +33,7 @@ jobs:
33 outputs:
34 run: ${{ steps.check-run.outputs.run }}
35 skip-go: ${{ steps.check-go.outputs.skip-go }}
36 + docker-native: ${{ steps.check-native.outputs.docker-native }}
37 steps:
38 - name: Checkout
39 id: checkout
@@ -86,6 +87,25 @@ jobs:
87 files_ignore: |
88 **/*.md
89 packaging/repoconfig/
90 + - name: Check Docker files
91 + id: check-docker-files
92 + if: github.event_name != 'workflow_dispatch'
93 + uses: step-security/changed-files@v45
94 + with:
95 + since_last_remote_commit: ${{ github.event_name != 'pull_request' }}
96 + files: |
97 + .dockerignore
98 + .github/data/distros.yml
99 + .github/workflows/docker.yml
100 + .github/scripts/docker-test.sh
101 + .github/scripts/gen-matrix-docker.py
102 + .github/scripts/gen-docker-tags.py
103 + .github/scripts/gen-docker-imagetool-args.py
104 + packaging/docker/
105 + packaging/runtime-check.sh
106 + files_ignore: |
107 + **/*.md
108 + packaging/repoconfig/
109 - name: List all changed files in pattern
110 continue-on-error: true
111 if: github.event_name != 'workflow_dispatch'
@@ -118,10 +138,24 @@ jobs:
138 else
139 echo 'skip-go=' >> "${GITHUB_OUTPUT}"
140 fi
141 + - name: Check Native
142 + id: check-native
143 + run: |
144 + if [ '${{ github.event_name }}' == 'pull_request' ]; then
145 + if [ "${{ steps.check-docker-files.outputs.any_modified }}" == "true" ] || [ "${{ !contains(github.event.pull_request.labels.*.name, 'run-ci/non-native') }}" = "true" ]; then
146 + echo 'docker-native=0' >> "${GITHUB_OUTPUT}"
147 + else
148 + echo 'docker-native=1' >> "${GITHUB_OUTPUT}"
149 + fi
150 + else
151 + echo 'docker-native=0' >> "${GITHUB_OUTPUT}"
152 + fi
153
154 matrix:
155 name: Generate Docker Build Matrix
156 runs-on: ubuntu-latest
157 + needs:
158 + - file-check
159 outputs:
160 matrix: ${{ steps.set-matrix.outputs.matrix }}
161 steps:
@@ -136,7 +170,7 @@ jobs:
170 - name: Read build matrix
171 id: set-matrix
172 run: |
139 - matrix="$(.github/scripts/gen-matrix-docker.py)"
173 + matrix="$(.github/scripts/gen-matrix-docker.py "${{ needs.file-check.outputs.docker-native }}")"
174 echo "Generated matrix: ${matrix}"
175 echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
176 - name: Failure Notification