Skip to content

Commit

Permalink
CI: Don't run bootstrap if we restored from cache (#32610)
Browse files Browse the repository at this point in the history
* CI: Don't run bootstrap if we restored from cache

Handle caching and log upload directly within the bootstrap action, and don't
perform the actual bootstrap if we have a cache hit. Include the platform name
in the cache key.

* Silabs requirements are for non-Docker builds
  • Loading branch information
ksperling-apple authored Mar 19, 2024
1 parent f4f1e19 commit 8228705
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/actions/bootstrap-cache/action.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Bootstrap cache
description: Bootstrap cache
description: Bootstrap cache (deprecated)
runs:
using: "composite"
steps:
Expand Down
35 changes: 33 additions & 2 deletions .github/actions/bootstrap/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,40 @@ inputs:
description: "Platform name"
required: false
default: none
bootstrap-log-name:
description: "Bootstrap log name"
required: false
default: bootstrap-logs-${{ github.job }}

runs:
using: "composite"
steps:
- name: Bootstrap
- uses: Wandalen/[email protected]
name: Bootstrap from cache
id: bootstrap-cache
continue-on-error: true
with:
action: buildjet/cache@v4
attempt_limit: 3
attempt_delay: 2000
with: |
key: ${{ runner.os }}-${{ inputs.platform }}-env-${{ hashFiles('scripts/setup/*', 'third_party/pigweed/**') }}
path: |
.environment
build_overrides/pigweed_environment.gni
- name: Run bootstrap
if: fromJSON(steps.bootstrap-cache.outputs.outputs).cache-hit != 'true' # retry returns all outputs in `outputs`
env:
PW_NO_CIPD_CACHE_DIR: Y
shell: bash
run: bash scripts/bootstrap.sh -p all,${{ inputs.platform }}
run: source scripts/bootstrap.sh -p all,${{ inputs.platform }}

- name: Uploading bootstrap logs
uses: actions/upload-artifact@v3
if: always() && !env.ACT && fromJSON(steps.bootstrap-cache.outputs.outputs).cache-hit != 'true'
with:
name: ${{ inputs.bootstrap-log-name }}
path: |
.environment/gn_out/.ninja_log
.environment/pigweed-venv/*.log
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,14 @@ runs:
with:
platform: ${{ inputs.platform }}
extra-parameters: ${{ inputs.extra-submodule-parameters }}
- name: Bootstrap Cache
uses: ./.github/actions/bootstrap-cache
- name: Bootstrap
uses: ./.github/actions/bootstrap
env:
PW_NO_CIPD_CACHE_DIR: Y
with:
platform: ${{ inputs.platform }}
bootstrap-log-name: ${{ inputs.bootstrap-log-name }}
- name: Dump disk info after checkout submodule & Bootstrap
shell: bash
run: scripts/dump_diskspace_info.sh
- name: Upload Bootstrap Logs
uses: ./.github/actions/upload-bootstrap-logs
with:
bootstrap-log-name: ${{ inputs.bootstrap-log-name }}
- name: Work around TSAN ASLR issues
if: runner.os == 'Linux' && !env.ACT
shell: bash
Expand Down
18 changes: 0 additions & 18 deletions .github/actions/upload-bootstrap-logs/action.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/cirque.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
with:
platform: linux

# TODO: Is what's being cached here actually compatible with a regular bootstrap?
- name: Bootstrap Cache
uses: ./.github/actions/bootstrap-cache
- name: Bootstrap Cirque
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/fuzzing-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ jobs:
run: |
mkdir objdir-clone || true
- name: Bootstrap Cache
uses: ./.github/actions/bootstrap-cache
- name: Bootstrap
uses: ./.github/actions/bootstrap
- name: Upload Bootstrap Logs
uses: ./.github/actions/upload-bootstrap-logs

- name: Build all-clusters-app
run: |
Expand Down Expand Up @@ -84,12 +80,8 @@ jobs:
run: |
mkdir objdir-clone || true
- name: Bootstrap Cache
uses: ./.github/actions/bootstrap-cache
- name: Bootstrap
uses: ./.github/actions/bootstrap
- name: Upload Bootstrap Logs
uses: ./.github/actions/upload-bootstrap-logs

- name: Build all-clusters-app
run: |
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/release_artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,8 @@ jobs:
uses: actions/checkout@v4
with:
ref: "${{ github.event.inputs.releaseTag }}"
- name: Bootstrap Cache
uses: ./.github/actions/bootstrap-cache
- name: Bootstrap
uses: ./.github/actions/bootstrap
- name: Upload Bootstrap Logs
uses: ./.github/actions/upload-bootstrap-logs

- name: Build
run: scripts/examples/esp_example.sh all-clusters-app
Expand Down Expand Up @@ -74,12 +70,8 @@ jobs:
uses: actions/checkout@v4
with:
ref: "${{ github.event.inputs.releaseTag }}"
- name: Bootstrap Cache
uses: ./.github/actions/bootstrap-cache
- name: Bootstrap
uses: ./.github/actions/bootstrap
- name: Upload Bootstrap Logs
uses: ./.github/actions/upload-bootstrap-logs

- name: Build example EFR32 Lock App
run: scripts/examples/gn_silabs_example.sh examples/lock-app/efr32/
Expand Down
20 changes: 10 additions & 10 deletions scripts/setup/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ _install_additional_pip_requirements() {
# figure out additional pip install items
while [ $# -gt 0 ]; do
case $1 in
-p | --platform)
_SETUP_PLATFORM=$2
shift # argument
shift # value
;;
*)
shift
;;
-p | --platform)
_SETUP_PLATFORM=$2
shift # argument
shift # value
;;
*)
shift
;;
esac
done

Expand All @@ -41,7 +41,7 @@ _install_additional_pip_requirements() {

for platform in ${_SETUP_PLATFORM}; do
# Allow none as an alias of nothing extra installed (like -p none)
if [ "$platform" != "none" ]; then
if [ "$platform" != "none" -a -e "$_CHIP_ROOT/scripts/setup/requirements.$platform.txt" ]; then
echo "Installing pip requirements for $platform..."
pip install -q \
-r "$_CHIP_ROOT/scripts/setup/requirements.$platform.txt" \
Expand All @@ -66,7 +66,7 @@ _bootstrap_or_activate() {
local _BOOTSTRAP_NAME="${_BOOTSTRAP_PATH##*/}"
local _BOOTSTRAP_DIR="${_BOOTSTRAP_PATH%/*}"
# Strip off the 'scripts[/setup]' directory, leaving the root of the repo.
_CHIP_ROOT="$(cd "${_BOOTSTRAP_DIR%/setup}/.." > /dev/null && pwd)"
_CHIP_ROOT="$(cd "${_BOOTSTRAP_DIR%/setup}/.." >/dev/null && pwd)"

local _CONFIG_FILE="scripts/setup/environment.json"

Expand Down
File renamed without changes.

0 comments on commit 8228705

Please sign in to comment.