Skip to content

Commit 2c1a2b2

Browse files
gopidesupavanHariGS-DB
authored andcommitted
Apply zizmor findings (apache#45408)
1 parent d1502fb commit 2c1a2b2

26 files changed

+218
-89
lines changed

.github/actions/breeze/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ inputs:
2424
default: "3.9"
2525
use-uv:
2626
description: 'Whether to use uv tool'
27-
required: "true"
28-
type: "string"
27+
required: true
2928
outputs:
3029
host-python-version:
3130
description: Python version used in host

.github/actions/install-pre-commit/action.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ runs:
3636
steps:
3737
- name: Install pre-commit, uv, and pre-commit-uv
3838
shell: bash
39+
env:
40+
UV_VERSION: ${{inputs.uv-version}}
41+
PRE_COMMIT_VERSION: ${{inputs.pre-commit-version}}
42+
PRE_COMMIT_UV_VERSION: ${{inputs.pre-commit-uv-version}}
3943
run: |
40-
pip install uv==${{inputs.uv-version}} || true
41-
uv tool install pre-commit==${{inputs.pre-commit-version}} --with uv==${{inputs.uv-version}} \
42-
--with pre-commit-uv==${{inputs.pre-commit-uv-version}}
44+
pip install uv==${UV_VERSION} || true
45+
uv tool install pre-commit==${PRE_COMMIT_VERSION} --with uv==${UV_VERSION} \
46+
--with pre-commit-uv==${PRE_COMMIT_UV_VERSION}
4347
working-directory: ${{ github.workspace }}
4448
# We need to use tar file with archive to restore all the permissions and symlinks
4549
- name: "Delete ~.cache"

.github/actions/prepare_breeze_and_image/action.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ runs:
5252
key: ${{ inputs.image-type }}-image-save-${{ inputs.platform }}-${{ inputs.python }}
5353
path: "/tmp/"
5454
- name: "Load ${{ inputs.image-type }} image ${{ inputs.platform }}:${{ inputs.python }}"
55+
env:
56+
PLATFORM: ${{ inputs.platform }}
57+
PYTHON: ${{ inputs.python }}
58+
IMAGE_TYPE: ${{ inputs.image-type }}
5559
run: >
56-
breeze ${{ inputs.image-type }}-image load
57-
--platform ${{ inputs.platform }} --python ${{ inputs.python }}
60+
breeze ${IMAGE_TYPE}-image load
61+
--platform ${PLATFORM} --python ${PYTHON}
5862
shell: bash

.github/actions/prepare_single_ci_image/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ runs:
4242
path: "/tmp/"
4343
if: contains(inputs.python-versions-list-as-string, inputs.python)
4444
- name: "Load CI image ${{ inputs.platform }}:${{ inputs.python }}"
45-
run: breeze ci-image load --platform "${{ inputs.platform }}" --python "${{ inputs.python }}"
45+
env:
46+
PLATFORM: ${{ inputs.platform }}
47+
PYTHON: ${{ inputs.python }}
48+
run: breeze ci-image load --platform "${PLATFORM}" --python "${PYTHON}"
4649
shell: bash
4750
if: contains(inputs.python-versions-list-as-string, inputs.python)

.github/workflows/additional-ci-image-checks.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ jobs:
146146
with:
147147
use-uv: ${{ inputs.use-uv }}
148148
- name: "Login to ghcr.io"
149-
run: echo "${{ env.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
149+
env:
150+
actor: ${{ github.actor }}
151+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152+
run: echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$actor" --password-stdin
150153
- name: "Check that image builds quickly"
151154
run: breeze shell --max-time 600 --platform "linux/amd64"
152155

.github/workflows/additional-prod-image-tests.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,15 @@ jobs:
123123
python: ${{ inputs.default-python-version }}
124124
use-uv: ${{ inputs.use-uv }}
125125
- name: "Test examples of PROD image building"
126+
env:
127+
GITHUB_REPOSITORY: ${{ github.repository }}
128+
DEFAULT_BRANCH: ${{ inputs.default-branch }}
129+
DEFAULT_PYTHON_VERSION: ${{ inputs.default-python-version }}
126130
run: "
127131
cd ./docker_tests && \
128132
python -m pip install -r requirements.txt && \
129-
TEST_IMAGE=\"ghcr.io/${{ github.repository }}/${{ inputs.default-branch }}\
130-
/prod/python${{ inputs.default-python-version }}\" \
133+
TEST_IMAGE=\"ghcr.io/$GITHUB_REPOSITORY/$DEFAULT_BRANCH\
134+
/prod/python$DEFAULT_PYTHON_VERSION\" \
131135
python -m pytest test_examples_of_prod_image_building.py -n auto --color=yes"
132136

133137
test-docker-compose-quick-start:

.github/workflows/backport-cli.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,28 @@ jobs:
6464
id: execute-backport
6565
env:
6666
GH_AUTH: ${{ secrets.GITHUB_TOKEN }}
67+
TARGET_BRANCH: ${{ inputs.target-branch }}
68+
COMMIT_SHA: ${{ inputs.commit-sha }}
6769
run: |
6870
git config --global user.email "[email protected]"
6971
git config --global user.name "Your Name"
7072
set +e
7173
{
7274
echo 'cherry_picker_output<<EOF'
73-
cherry_picker ${{ inputs.commit-sha }} ${{ inputs.target-branch }}
75+
cherry_picker ${COMMIT_SHA} ${TARGET_BRANCH}
7476
echo EOF
7577
} >> "${GITHUB_OUTPUT}"
7678
continue-on-error: true
7779

7880
- name: Parse backport output
7981
id: parse-backport-output
82+
env:
83+
CHERRY_PICKER_OUTPUT: ${{ steps.execute-backport.outputs.cherry_picker_output }}
8084
run: |
8185
set +e
82-
echo "${{ steps.execute-backport.outputs.cherry_picker_output }}"
86+
echo "${CHERRY_PICKER_OUTPUT}"
8387
84-
url=$(echo "${{ steps.execute-backport.outputs.cherry_picker_output }}" | \
88+
url=$(echo "${CHERRY_PICKER_OUTPUT}" | \
8589
grep -o 'Backport PR created at https://[^ ]*' | \
8690
awk '{print $5}')
8791
@@ -99,17 +103,20 @@ jobs:
99103
GH_TOKEN: ${{ github.token }}
100104
REPOSITORY: ${{ github.repository }}
101105
RUN_ID: ${{ github.run_id }}
106+
COMMIT_SHA: ${{ inputs.commit-sha }}
107+
TARGET_BRANCH: ${{ inputs.target-branch }}
108+
BACKPORT_URL: ${{ steps.parse-backport-output.outputs.backport-url }}
102109
run: |
103-
COMMIT_INFO_URL="https://api.github.com/repos/${{ github.repository }}/commits/"
104-
COMMIT_INFO_URL="${COMMIT_INFO_URL}${{ inputs.commit-sha }}/pulls"
110+
COMMIT_INFO_URL="https://api.github.com/repos/$REPOSITORY/commits/"
111+
COMMIT_INFO_URL="${COMMIT_INFO_URL}$COMMIT_SHA/pulls"
105112
106113
PR_NUMBER=$(gh api \
107114
-H "Accept: application/vnd.github+json" \
108115
-H "X-GitHub-Api-Version: 2022-11-28" \
109-
/repos/${{ github.repository }}/commits/${{ inputs.commit-sha }}/pulls \
116+
/repos/$REPOSITORY/commits/$COMMIT_SHA/pulls \
110117
--jq '.[0].number')
111118
112119
python ./dev/backport/update_backport_status.py \
113-
${{ steps.parse-backport-output.outputs.backport-url }} \
114-
${{ inputs.commit-sha }} ${{ inputs.target-branch }} \
120+
$BACKPORT_URL \
121+
$COMMIT_SHA $TARGET_BRANCH \
115122
"$PR_NUMBER"

.github/workflows/ci-image-build.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,22 @@ jobs:
140140
path: "/tmp/"
141141
id: restore-cache-mount
142142
- name: "Import mount-cache ${{ inputs.platform }}:${{ env.PYTHON_MAJOR_MINOR_VERSION }}"
143+
env:
144+
PYTHON_MAJOR_MINOR_VERSION: ${{ env.PYTHON_MAJOR_MINOR_VERSION }}
143145
run: >
144146
breeze ci-image import-mount-cache
145-
--cache-file /tmp/ci-cache-mount-save-v2-${{ env.PYTHON_MAJOR_MINOR_VERSION }}.tar.gz
147+
--cache-file /tmp/ci-cache-mount-save-v2-${PYTHON_MAJOR_MINOR_VERSION}.tar.gz
146148
if: steps.restore-cache-mount.outputs.stash-hit == 'true'
147149
- name: "Login to ghcr.io"
148-
run: echo "${{ env.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
150+
env:
151+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152+
ACTOR: ${{ github.actor }}
153+
run: echo "${GITHUB_TOKEN}" | docker login ghcr.io -u ${ACTOR} --password-stdin
149154
- name: >
150155
Build ${{ inputs.push-image == 'true' && ' & push ' || '' }}
151156
${{ inputs.platform }}:${{ env.PYTHON_MAJOR_MINOR_VERSION }} image
152157
run: >
153-
breeze ci-image build --platform "${{ inputs.platform }}"
158+
breeze ci-image build --platform "${PLATFORM}"
154159
env:
155160
DOCKER_CACHE: ${{ inputs.docker-cache }}
156161
DISABLE_AIRFLOW_REPO_CACHE: ${{ inputs.disable-airflow-repo-cache }}
@@ -167,8 +172,11 @@ jobs:
167172
GITHUB_USERNAME: ${{ github.actor }}
168173
PUSH: ${{ inputs.push-image }}
169174
VERBOSE: "true"
175+
PLATFORM: ${{ inputs.platform }}
170176
- name: "Export CI docker image ${{ env.PYTHON_MAJOR_MINOR_VERSION }}"
171-
run: breeze ci-image save --platform "${{ inputs.platform }}"
177+
env:
178+
PLATFORM: ${{ inputs.platform }}
179+
run: breeze ci-image save --platform "${PLATFORM}"
172180
if: inputs.upload-image-artifact == 'true'
173181
- name: "Stash CI docker image ${{ env.PYTHON_MAJOR_MINOR_VERSION }}"
174182
uses: apache/infrastructure-actions/stash/save@c94b890bbedc2fc61466d28e6bd9966bc6c6643c
@@ -179,9 +187,11 @@ jobs:
179187
retention-days: '2'
180188
if: inputs.upload-image-artifact == 'true'
181189
- name: "Export mount cache ${{ inputs.platform }}:${{ env.PYTHON_MAJOR_MINOR_VERSION }}"
190+
env:
191+
PYTHON_MAJOR_MINOR_VERSION: ${{ env.PYTHON_MAJOR_MINOR_VERSION }}
182192
run: >
183193
breeze ci-image export-mount-cache
184-
--cache-file /tmp/ci-cache-mount-save-v2-${{ env.PYTHON_MAJOR_MINOR_VERSION }}.tar.gz
194+
--cache-file /tmp/ci-cache-mount-save-v2-${PYTHON_MAJOR_MINOR_VERSION}.tar.gz
185195
if: inputs.upload-mount-cache-artifact == 'true'
186196
- name: "Stash cache mount ${{ inputs.platform }}:${{ env.PYTHON_MAJOR_MINOR_VERSION }}"
187197
uses: apache/infrastructure-actions/stash/save@c94b890bbedc2fc61466d28e6bd9966bc6c6643c

.github/workflows/ci-image-checks.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,15 @@ jobs:
228228
with:
229229
python-version: ${{steps.breeze.outputs.host-python-version}}
230230
- name: "MyPy checks for ${{ matrix.mypy-check }}"
231-
run: pre-commit run --color always --verbose --hook-stage manual ${{matrix.mypy-check}} --all-files
231+
run: pre-commit run --color always --verbose --hook-stage manual "$MYPY_CHECK" --all-files
232232
env:
233233
VERBOSE: "false"
234234
COLUMNS: "250"
235235
SKIP_GROUP_OUTPUT: "true"
236236
DEFAULT_BRANCH: ${{ inputs.branch }}
237237
RUFF_FORMAT: "github"
238238
INCLUDE_MYPY_VOLUME: "false"
239+
MYPY_CHECK: ${{ matrix.mypy-check }}
239240

240241
build-docs:
241242
timeout-minutes: 150
@@ -276,8 +277,10 @@ jobs:
276277
key: cache-docs-inventory-v1-${{ hashFiles('pyproject.toml') }}
277278
id: restore-docs-inventory-cache
278279
- name: "Building docs with ${{ matrix.flag }} flag"
280+
env:
281+
DOCS_LIST_AS_STRING: ${{ inputs.docs-list-as-string }}
279282
run: >
280-
breeze build-docs ${{ inputs.docs-list-as-string }} ${{ matrix.flag }}
283+
breeze build-docs ${DOCS_LIST_AS_STRING} ${{ matrix.flag }}
281284
- name: "Save docs inventory cache"
282285
uses: apache/infrastructure-actions/stash/save@c94b890bbedc2fc61466d28e6bd9966bc6c6643c
283286
with:
@@ -339,9 +342,11 @@ jobs:
339342
python: ${{ inputs.default-python-version }}
340343
use-uv: ${{ inputs.use-uv }}
341344
- name: "Publish docs"
345+
env:
346+
DOCS_LIST_AS_STRING: ${{ inputs.docs-list-as-string }}
342347
run: >
343348
breeze release-management publish-docs --override-versioned --run-in-parallel
344-
${{ inputs.docs-list-as-string }}
349+
${DOCS_LIST_AS_STRING}
345350
- name: Check disk space available
346351
run: df -h
347352
- name: "Generate back references for providers"

.github/workflows/ci.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ on: # yamllint disable-line rule:truthy
3434
permissions:
3535
# All other permissions are set to none by default
3636
contents: read
37-
# Technically read access while waiting for images should be more than enough. However,
38-
# there is a bug in GitHub Actions/Packages and in case private repositories are used, you get a permission
39-
# denied error when attempting to just pull private image, changing the token permission to write solves the
40-
# issue. This is not dangerous, because if it is for "apache/airflow", only maintainers can push ci.yml
41-
# changes. If it is for a fork, then the token is read-only anyway.
42-
packages: write
4337
env:
4438
GITHUB_REPOSITORY: ${{ github.repository }}
4539
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -228,6 +222,9 @@ jobs:
228222
name: "Additional CI image checks"
229223
needs: [build-info, build-ci-images]
230224
uses: ./.github/workflows/additional-ci-image-checks.yml
225+
permissions:
226+
contents: read
227+
packages: write
231228
if: needs.build-info.outputs.canary-run == 'true'
232229
with:
233230
runs-on-as-json-default: ${{ needs.build-info.outputs.runs-on-as-json-default }}

0 commit comments

Comments
 (0)