Skip to content

Commit 5e1f0a1

Browse files
committed
fix: add JFrog OIDC fallback when dependency cache is cold
setup-python-deps now outputs cache-hit. On cache miss, main.yml falls back to setup-jfrog-pypi for package resolution. Also fixes YAML parse error from unindented heredoc by using printf instead.
1 parent 4f48c9e commit 5e1f0a1

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

.github/actions/setup-python-deps/action.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
name: "Setup Python Dependencies"
22
description: |
33
Restores pre-cached Python dependencies and enables offline mode.
4-
All package installs (uv, pip, pre-commit) use only the local cache
5-
populated by the warmDepsCache workflow — no registry access needed.
4+
Outputs cache-hit so callers can fall back to setup-jfrog-pypi on miss.
5+
6+
outputs:
7+
cache-hit:
8+
description: "Whether the dependency cache was restored"
9+
value: ${{ steps.uv-cache.outputs.cache-matched-key != '' }}
610

711
runs:
812
using: "composite"
913
steps:
1014
- name: Restore uv and pip cache
15+
id: uv-cache
1116
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
1217
with:
1318
path: |
@@ -24,10 +29,12 @@ runs:
2429
restore-keys: pre-commit-deps-
2530

2631
- name: Enable offline mode
32+
if: steps.uv-cache.outputs.cache-matched-key != ''
2733
shell: bash
2834
run: |
2935
echo "UV_OFFLINE=true" >> "$GITHUB_ENV"
3036
# verify env uses pip, not uv
3137
echo "PIP_NO_INDEX=1" >> "$GITHUB_ENV"
3238
mkdir -p ~/.config/pip
3339
printf '[global]\nno-index = true\n' > ~/.config/pip/pip.conf
40+
echo "Cache restored — offline mode enabled"

.github/workflows/main.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# **what?**
22
# Runs code quality checks, unit tests, and verifies python build on
3-
# all code commited to the repository. This workflow does not require
4-
# any secrets — dependencies are served from a pre-populated cache
5-
# (see warmDepsCache.yml), so it works for both internal and fork PRs.
3+
# all code commited to the repository. Dependencies are served from a
4+
# pre-populated cache (see warmDepsCache.yml) when available, with a
5+
# JFrog OIDC fallback when the cache is cold.
66

77
# **why?**
88
# Ensure code for dbt meets a certain quality standard.
@@ -29,6 +29,7 @@ on:
2929
workflow_dispatch:
3030

3131
permissions:
32+
id-token: write
3233
contents: read
3334

3435
# will cancel previous workflows triggered by the same event and for the same ref for PRs or same SHA otherwise
@@ -60,8 +61,13 @@ jobs:
6061
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
6162

6263
- name: Setup Python Dependencies
64+
id: deps
6365
uses: ./.github/actions/setup-python-deps
6466

67+
- name: Setup JFrog PyPI Proxy (fallback)
68+
if: steps.deps.outputs.cache-hit != 'true'
69+
uses: ./.github/actions/setup-jfrog-pypi
70+
6571
- name: Set up Python
6672
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
6773
with:
@@ -85,6 +91,7 @@ jobs:
8591
timeout-minutes: 15
8692

8793
permissions:
94+
id-token: write
8895
# Gives the action the necessary permissions for publishing new
8996
# comments in pull requests.
9097
pull-requests: write
@@ -106,8 +113,13 @@ jobs:
106113
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
107114

108115
- name: Setup Python Dependencies
116+
id: deps
109117
uses: ./.github/actions/setup-python-deps
110118

119+
- name: Setup JFrog PyPI Proxy (fallback)
120+
if: steps.deps.outputs.cache-hit != 'true'
121+
uses: ./.github/actions/setup-jfrog-pypi
122+
111123
- name: Set up Python ${{ matrix.python-version }}
112124
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
113125
with:
@@ -150,8 +162,13 @@ jobs:
150162
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
151163

152164
- name: Setup Python Dependencies
165+
id: deps
153166
uses: ./.github/actions/setup-python-deps
154167

168+
- name: Setup JFrog PyPI Proxy (fallback)
169+
if: steps.deps.outputs.cache-hit != 'true'
170+
uses: ./.github/actions/setup-jfrog-pypi
171+
155172
- name: Set up Python
156173
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
157174
with:

0 commit comments

Comments
 (0)