Visitar URL original
Merge branch 'master' into fix-pivot-table-totals-requery · apache/superset@b4fcba7 · GitHub
Skip to content

Commit b4fcba7

Browse files
authored
Merge branch 'master' into fix-pivot-table-totals-requery
2 parents 21013ae + aabddf5 commit b4fcba7

283 files changed

Lines changed: 15049 additions & 4028 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/chromatic.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ jobs:
120120
121121
- name: Publish to Chromatic
122122
if: ${{ env.CHROMATIC_PROJECT_TOKEN != '' }}
123-
uses: chromaui/action@8e6c25f2af5570e4a0ed34674569c345d545ac4a # v18.12.1
123+
uses: chromaui/action@18599f2ae5010524d496b86099c9b69a37f5d8d2 # v18.12.2
124124
with:
125125
projectToken: ${{ env.CHROMATIC_PROJECT_TOKEN }}
126126
token: ${{ secrets.GITHUB_TOKEN }}

‎.github/workflows/codeql-analysis.yml‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ jobs:
2424
permissions:
2525
contents: read
2626
pull-requests: read
27+
# Lets the availability probe below tell "code scanning is not
28+
# enabled" apart from "this token cannot read alerts".
29+
security-events: read
2730
outputs:
2831
languages: ${{ steps.check.outputs.languages }}
32+
code-scanning: ${{ steps.code-scanning.outputs.available }}
2933
steps:
3034
- name: Checkout
3135
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -36,14 +40,27 @@ jobs:
3640
uses: $/.github/actions/change-detector/
3741
with:
3842
token: ${{ secrets.GITHUB_TOKEN }}
43+
# A repository without code scanning (e.g. a private fork or mirror
44+
# without GitHub Code Security) rejects the SARIF upload, so the
45+
# analysis would run to completion and then fail on every push.
46+
- name: Check code scanning availability
47+
id: code-scanning
48+
env:
49+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
run: .github/workflows/scripts/check-code-scanning-available.sh
3951

4052
analyze:
4153
name: Analyze
4254
needs: changes
4355
# Skip on PRs that touch neither code group (e.g. docs-only) so the
4456
# analysis runners don't spin up. push/schedule runs always proceed:
4557
# the change-detector returns "all changed" for non-PR events.
46-
if: ${{ contains(fromJSON(needs.changes.outputs.languages), 'python') || contains(fromJSON(needs.changes.outputs.languages), 'javascript') }}
58+
# Skipped entirely where code scanning is unavailable, since the upload
59+
# is this job's only product.
60+
if: >-
61+
needs.changes.outputs.code-scanning != 'false' &&
62+
(contains(fromJSON(needs.changes.outputs.languages), 'python') ||
63+
contains(fromJSON(needs.changes.outputs.languages), 'javascript'))
4764
runs-on: ubuntu-26.04
4865
timeout-minutes: 15
4966
permissions:

‎.github/workflows/docker.yml‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,18 @@ jobs:
4040
timeout-minutes: 5
4141
outputs:
4242
matrix_config: ${{ steps.set_matrix.outputs.matrix_config }}
43+
has-secrets: ${{ steps.check.outputs.has-secrets }}
4344
steps:
45+
- name: "Check for secrets"
46+
id: check
47+
shell: bash
48+
run: |
49+
if [ -n "${DOCKERHUB_USER}" ] && [ -n "${DOCKERHUB_TOKEN}" ]; then
50+
echo "has-secrets=1" >> "$GITHUB_OUTPUT"
51+
fi
52+
env:
53+
DOCKERHUB_USER: ${{ (secrets.DOCKERHUB_USER != '') || '' }}
54+
DOCKERHUB_TOKEN: ${{ (secrets.DOCKERHUB_TOKEN != '') || '' }}
4455
- id: set_matrix
4556
run: |
4657
MATRIX_CONFIG=$(if [ "${{ github.event_name }}" == "pull_request" ]; then echo '["superset", "dev", "lean"]'; else echo '["superset", "dev", "lean", "py311", "py312"]'; fi)
@@ -280,10 +291,18 @@ jobs:
280291
docker-build:
281292
name: docker-build
282293
needs: [setup_matrix, changes]
294+
# Only master pushes publish images (see scripts/docker-build-plan.sh).
295+
# Without the Docker Hub credentials (e.g. on a fork or mirror) they can
296+
# publish nothing, so they are skipped there. Version-branch pushes and
297+
# pull_request builds only load the image to validate that it builds, so
298+
# they run everywhere.
283299
if: >-
284-
needs.changes.outputs.python == 'true' ||
285-
needs.changes.outputs.frontend == 'true' ||
286-
needs.changes.outputs.docker == 'true'
300+
(github.event_name != 'push' ||
301+
github.ref != 'refs/heads/master' ||
302+
needs.setup_matrix.outputs.has-secrets) &&
303+
(needs.changes.outputs.python == 'true' ||
304+
needs.changes.outputs.frontend == 'true' ||
305+
needs.changes.outputs.docker == 'true')
287306
runs-on: ubuntu-26.04
288307
timeout-minutes: 60
289308
permissions:

‎.github/workflows/frontend-bundle-size-nightly.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ permissions:
2525

2626
jobs:
2727
refresh-baseline:
28+
# The nightly baseline is only consumed by upstream pull requests; forks
29+
# and mirrors can still start it manually.
30+
if: github.event_name != 'schedule' || github.repository == 'apache/superset'
2831
runs-on: ubuntu-26.04
2932
timeout-minutes: 30
3033
env:

‎.github/workflows/generate-FOSSA-report.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
persist-credentials: false
3838
submodules: recursive
3939
- name: Setup Java
40-
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
40+
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
4141
with:
4242
distribution: "temurin"
4343
java-version: "11"

‎.github/workflows/github-action-validator.yml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,19 @@ jobs:
4848
- name: Test docs-deploy freshness gate
4949
run: bash .github/workflows/scripts/check-docs-deploy-freshness.test.sh
5050

51+
- name: Test code scanning availability check
52+
run: bash .github/workflows/scripts/check-code-scanning-available.test.sh
53+
54+
# A repository without code scanning (e.g. a private fork or mirror
55+
# without GitHub Code Security) rejects the SARIF upload. The audit
56+
# still runs there; its findings are reported in the job log instead.
57+
- name: Check code scanning availability
58+
id: code-scanning
59+
env:
60+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
run: .github/workflows/scripts/check-code-scanning-available.sh
62+
5163
- name: Check for security issues on GHA workflows
5264
uses: zizmorcore/zizmor-action@cc914d7f3750a2d13d75c7f184a1060aa0e9d482 # v0.6.4
65+
with:
66+
advanced-security: ${{ steps.code-scanning.outputs.available != 'false' }}

‎.github/workflows/license-check.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
persist-credentials: false
2424
submodules: recursive
2525
- name: Setup Java
26-
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
26+
uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
2727
with:
2828
distribution: "temurin"
2929
java-version: "11"

‎.github/workflows/python-nightly-canary.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ concurrency:
3030

3131
jobs:
3232
unit-tests-next:
33+
# The nightly run reports to the upstream issue tracker; forks and
34+
# mirrors can still start it manually.
35+
if: github.event_name != 'schedule' || github.repository == 'apache/superset'
3336
runs-on: ubuntu-26.04
3437
timeout-minutes: 45
3538
env:
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# Reports whether the repository can accept code scanning (SARIF) uploads,
19+
# so jobs whose only product is such an upload can be skipped where the
20+
# upload is guaranteed to be rejected -- e.g. a private fork or mirror
21+
# without GitHub Code Security, where the analysis would run to completion
22+
# and then fail at the upload step on every push.
23+
#
24+
# Fails open: only GitHub's explicit "must be enabled" rejection counts as
25+
# unavailable. Any other response (success, an empty alert list, a token
26+
# without permission to read alerts, a network error) reports available, so
27+
# the upstream repository and forks that do have code scanning are never
28+
# skipped by mistake.
29+
#
30+
# Required env:
31+
# GH_TOKEN - token used to query the code scanning API
32+
# GITHUB_REPOSITORY - "owner/repo" to query
33+
# GITHUB_OUTPUT - path to the step's output file
34+
# Optional env:
35+
# GITHUB_API_URL - API root, defaults to https://api.github.com
36+
# OUTPUT_NAME - output key to write, defaults to "available"
37+
38+
set -euo pipefail
39+
40+
output_name="${OUTPUT_NAME:-available}"
41+
api_url="${GITHUB_API_URL:-https://api.github.com}"
42+
43+
# The response body can contain alert details, so it is inspected but never
44+
# printed. The HTTP status is appended on its own line so that an alert whose
45+
# text happens to contain the rejection message is not mistaken for it.
46+
response="$(
47+
curl --silent --max-time 30 \
48+
--write-out '\n%{http_code}' \
49+
--header "Authorization: Bearer ${GH_TOKEN}" \
50+
--header "Accept: application/vnd.github+json" \
51+
"${api_url}/repos/${GITHUB_REPOSITORY}/code-scanning/alerts?per_page=1" \
52+
2>/dev/null || true
53+
)"
54+
status="${response##*$'\n'}"
55+
body="${response%$'\n'*}"
56+
57+
available=true
58+
if [ "${status}" = "403" ] && grep --quiet --extended-regexp \
59+
'(Code|Advanced) Security must be enabled' <<<"${body}"; then
60+
available=false
61+
echo "Code scanning is not enabled for ${GITHUB_REPOSITORY}; jobs that only upload code scanning results will be skipped."
62+
fi
63+
64+
echo "${output_name}=${available}" >>"${GITHUB_OUTPUT}"
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# Exercises check-code-scanning-available.sh against a stubbed `curl`,
19+
# covering the "not enabled" rejection and the fail-open branches so the
20+
# output contract (available=true|false) can't silently regress. Run
21+
# directly, no extra tooling required:
22+
# bash .github/workflows/scripts/check-code-scanning-available.test.sh
23+
24+
set -euo pipefail
25+
26+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
27+
script_under_test="${script_dir}/check-code-scanning-available.sh"
28+
29+
failures=0
30+
31+
# Runs the script under test with a stubbed `curl` that replies with HTTP
32+
# status $2 and body $3 and exits with $4, asserting that GITHUB_OUTPUT ends
33+
# up containing exactly $5.
34+
run_case() {
35+
local case_name="$1"
36+
local http_status="$2"
37+
local response_body="$3"
38+
local curl_exit_code="$4"
39+
local expected_line="$5"
40+
41+
local workdir
42+
workdir="$(mktemp -d)"
43+
trap 'rm -rf "${workdir}"' RETURN
44+
45+
# Fake `curl` that replays a canned response regardless of arguments, so
46+
# the script under test never touches the network. The status follows the
47+
# body on its own line, as the real `--write-out` format produces.
48+
printf '%s\n%s' "${response_body}" "${http_status}" >"${workdir}/response"
49+
cat >"${workdir}/curl" <<EOF
50+
#!/bin/bash
51+
cat '${workdir}/response'
52+
exit ${curl_exit_code}
53+
EOF
54+
chmod +x "${workdir}/curl"
55+
56+
local output_file="${workdir}/github_output"
57+
: >"${output_file}"
58+
59+
if PATH="${workdir}:${PATH}" \
60+
GITHUB_OUTPUT="${output_file}" \
61+
GITHUB_REPOSITORY="apache/superset" \
62+
GH_TOKEN="fake-token" \
63+
bash "${script_under_test}" >/dev/null; then
64+
:
65+
else
66+
echo "FAIL (${case_name}): script exited non-zero"
67+
failures=$((failures + 1))
68+
return
69+
fi
70+
71+
local actual
72+
actual="$(cat "${output_file}")"
73+
if [ "${actual}" = "${expected_line}" ]; then
74+
echo "PASS (${case_name})"
75+
else
76+
echo "FAIL (${case_name}): expected '${expected_line}', got '${actual}'"
77+
failures=$((failures + 1))
78+
fi
79+
}
80+
81+
run_case "alerts are readable" \
82+
200 '[{"number":1,"state":"open"}]' 0 \
83+
"available=true"
84+
85+
run_case "no alerts yet" \
86+
200 '[]' 0 \
87+
"available=true"
88+
89+
run_case "Code Security is not enabled" \
90+
403 '{"message":"Code Security must be enabled for this repository to use code scanning.","status":"403"}' 0 \
91+
"available=false"
92+
93+
run_case "Advanced Security is not enabled" \
94+
403 '{"message":"Advanced Security must be enabled for this repository to use code scanning.","status":"403"}' 0 \
95+
"available=false"
96+
97+
run_case "an alert merely quotes the rejection message" \
98+
200 '[{"rule":{"description":"Code Security must be enabled for this repository"}}]' 0 \
99+
"available=true"
100+
101+
run_case "token cannot read alerts" \
102+
403 '{"message":"Resource not accessible by integration","status":"403"}' 0 \
103+
"available=true"
104+
105+
run_case "no analysis found" \
106+
404 '{"message":"no analysis found","status":"404"}' 0 \
107+
"available=true"
108+
109+
run_case "network failure" \
110+
000 '' 28 \
111+
"available=true"
112+
113+
if [ "${failures}" -gt 0 ]; then
114+
echo "${failures} case(s) failed"
115+
exit 1
116+
fi
117+
118+
echo "All cases passed"

0 commit comments

Comments
 (0)