mirror of
https://github.com/servo/servo
synced 2026-04-26 01:25:32 +02:00
ci: Extract fast checkout steps into composite action (#40234)
this patch extracts the “faster checkout” steps we use for jobs that may
run on self-hosted runners into a composite action. the action is stored
in [servo/ci-runners](https://github.com/servo/ci-runners), to avoid an
extra checkout step, and the action calls are locked to a commit, to
avoid problems when making breaking changes.
while [servo/actions](https://github.com/servo/actions) is a reasonable
place to store this action, i’m planning to document our self-hosted CI
system and potentially make it usable by other projects, and this action
is effectively part of that system. that said, actions in that repo will
undergo
[review](00deefd2be)
as if they were in this repo.
Testing:
- self-hosted:
[windows](https://github.com/servo/servo/actions/runs/19125076579/job/54653625055#step:2:25),
[lint](https://github.com/servo/servo/actions/runs/19125076579/job/54653630737#step:2:21)
- GitHub-hosted:
[windows](https://github.com/delan/servo/actions/runs/19125003933/job/54653410264#step:2:25),
[lint](https://github.com/delan/servo/actions/runs/19125003933/job/54653410010#step:2:21)
---------
Signed-off-by: Delan Azabani <dazabani@igalia.com>
This commit is contained in:
41
.github/workflows/linux.yml
vendored
41
.github/workflows/linux.yml
vendored
@@ -152,26 +152,7 @@ jobs:
|
||||
name: Linux Build [${{ needs.runner-select.outputs.unique-id }}]
|
||||
runs-on: ${{ needs.runner-select.outputs.selected-runner-label }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
if: ${{ runner.environment != 'self-hosted' && github.event_name != 'pull_request_target' }}
|
||||
# This is necessary to checkout the pull request if this run was triggered via a
|
||||
# `pull_request_target` event.
|
||||
- uses: actions/checkout@v4
|
||||
if: ${{ runner.environment != 'self-hosted' && github.event_name == 'pull_request_target' }}
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
# Faster checkout for self-hosted runner that uses prebaked repo.
|
||||
- if: ${{ runner.environment == 'self-hosted' && github.event_name != 'pull_request_target' }}
|
||||
run: git fetch --depth=1 origin $GITHUB_SHA
|
||||
- if: ${{ runner.environment == 'self-hosted' && github.event_name == 'pull_request_target' }}
|
||||
run: git fetch --depth=1 origin ${{ github.event.pull_request.head.sha }}
|
||||
- if: ${{ runner.environment == 'self-hosted' }}
|
||||
# Same as `git switch --detach FETCH_HEAD`, but fixes up dirty working
|
||||
# trees, in case the runner image was baked with a dirty working tree.
|
||||
run: |
|
||||
git switch --detach
|
||||
git reset --hard FETCH_HEAD
|
||||
- uses: servo/ci-runners/actions/checkout@0b9edd49381b22c14e5b123f21377269864ddf54
|
||||
- name: Free Disk Space (Ubuntu)
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
if: ${{ runner.environment != 'self-hosted' }}
|
||||
@@ -362,25 +343,7 @@ jobs:
|
||||
runs-on: ${{ needs.runner-select-coverage.outputs.selected-runner-label }}
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
if: ${{ runner.environment != 'self-hosted' && github.event_name != 'pull_request_target' }}
|
||||
# This is necessary to checkout the pull request if this run was triggered via a
|
||||
# `pull_request_target` event.
|
||||
- uses: actions/checkout@v4
|
||||
if: ${{ runner.environment != 'self-hosted' && github.event_name == 'pull_request_target' }}
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
# Faster checkout for self-hosted runner that uses prebaked repo.
|
||||
- if: ${{ runner.environment == 'self-hosted' && github.event_name != 'pull_request_target' }}
|
||||
run: git fetch --depth=1 origin $GITHUB_SHA
|
||||
- if: ${{ runner.environment == 'self-hosted' && github.event_name == 'pull_request_target' }}
|
||||
run: git fetch --depth=1 origin ${{ github.event.pull_request.head.sha }}
|
||||
- if: ${{ runner.environment == 'self-hosted' }}
|
||||
# Same as `git switch --detach FETCH_HEAD`, but fixes up dirty working
|
||||
# trees, in case the runner image was baked with a dirty working tree.
|
||||
run: |
|
||||
git switch --detach
|
||||
git reset --hard FETCH_HEAD
|
||||
- uses: servo/ci-runners/actions/checkout@0b9edd49381b22c14e5b123f21377269864ddf54
|
||||
- name: Free Disk Space (Ubuntu)
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
if: ${{ runner.environment != 'self-hosted' }}
|
||||
|
||||
Reference in New Issue
Block a user