Skip to content

Commit 860d758

Browse files
authored
feat(ci): allow PRs from repo forks to use depot (#15243)
1 parent e67f02c commit 860d758

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

.github/workflows/docker-unified.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212
- master
1313
- releases/**
1414
pull_request:
15+
types: [opened, synchronize, reopened, labeled]
1516
branches:
1617
- "**"
1718
release:
@@ -29,7 +30,9 @@ env:
2930
PROFILE_NAME: "${{ github.event.inputs.profileName || 'quickstart-consumers' }}"
3031

3132
DOCKER_CACHE: "DEPOT"
32-
DEPOT_PROJECT_ID: "${{ vars.DEPOT_PROJECT_ID }}"
33+
DEPOT_PROJECT_ID: "s0gr1cr3jd"
34+
HAS_DEPOT_LABEL: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'depot') }}
35+
IS_FORK: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
3336
DEPOT_TOKEN: "${{ secrets.DEPOT_TOKEN }}"
3437

3538
permissions:
@@ -39,6 +42,7 @@ permissions:
3942
jobs:
4043
setup:
4144
runs-on: depot-ubuntu-24.04-small
45+
if: ${{ github.event_name != 'pull_request' || github.event.action != 'labeled' || github.event.label.name == 'depot' }}
4246
outputs:
4347
# TODO: Many of the vars below should not be required anymore.
4448
tag: ${{ steps.tag.outputs.tag }}
@@ -135,22 +139,25 @@ jobs:
135139
- name: Determine runner type
136140
id: set-runner
137141
# This needs to handle two scenarios:
138-
# 1. Running on a PR from a fork. There are some auth issues that prevent us from using depot in that case.
139-
# So, Its easier to just use the regular github actions cache and build all images for each parallel job running smoke test.
140-
# Note, concurrency is lower when using github runners, queue times can be longer, test time is longer due to fewer parallel jobs.
141-
# 2. Running on a PR from a branch in the datahub-project org and push/schedule events on master.
142+
# 1. Running on a PR from a fork. We use github runners, unless the "depot" label exists -- in which case, we run
143+
# it on depotNote, concurrency is lower when using github runners, queue times can be longer, test time is longer
144+
# due to fewer parallel jobs.
145+
# 3. Running on a PR from a branch in the datahub-project org and push/schedule events on master.
142146
# Depot is used here for remote container builds in base_build and also for all runners. Depot runners support unlimited concurrency
143147
# and hence short queue times and higher parallelism of smoke tests
144-
145148
run: |
146-
if [[ "${{ env.DOCKER_CACHE }}" == "DEPOT" && "${{ env.DEPOT_PROJECT_ID }}" != "" ]]; then
149+
if [[ "${{ env.DOCKER_CACHE }}" == "DEPOT" && "${{ env.IS_FORK }}" == "false" ]]; then
147150
echo "build_runner_type=depot-ubuntu-24.04-4" >> "$GITHUB_OUTPUT"
148151
echo "test_runner_type=depot-ubuntu-24.04-4" >> "$GITHUB_OUTPUT"
149152
echo "test_runner_type_small=depot-ubuntu-24.04-small" >> "$GITHUB_OUTPUT"
150153
echo "use_depot_cache=true" >> "$GITHUB_OUTPUT"
151154
else
152155
echo "build_runner_type=ubuntu-latest" >> "$GITHUB_OUTPUT"
153-
echo "test_runner_type=ubuntu-latest" >> "$GITHUB_OUTPUT"
156+
if [[ "${{ env.HAS_DEPOT_LABEL }}" == "true" ]]; then
157+
echo "test_runner_type=depot-ubuntu-24.04-4" >> "$GITHUB_OUTPUT"
158+
else
159+
echo "test_runner_type=ubuntu-latest" >> "$GITHUB_OUTPUT"
160+
fi
154161
echo "test_runner_type_small=ubuntu-latest" >> "$GITHUB_OUTPUT"
155162
echo "use_depot_cache=false" >> "$GITHUB_OUTPUT"
156163
# publishing is currently only supported via depot
@@ -392,7 +399,7 @@ jobs:
392399
# python_batch_count is used to split pytests in the smoke-test (batches of actual test functions)
393400
# cypress_batch_count is used to split the collection of cypress test specs into batches.
394401
run: |
395-
if [[ "${{ needs.setup.outputs.test_runner_type }}" == "ubuntu-latest" ]]; then
402+
if [[ "${{ env.IS_FORK }}" == "true" ]]; then
396403
echo "cypress_batch_count=5" >> "$GITHUB_OUTPUT"
397404
echo "python_batch_count=3" >> "$GITHUB_OUTPUT"
398405
else

0 commit comments

Comments
 (0)