blob: cd88bea34f71763660dbd1f2cc8d7a82203b26d6 [file] [log] [blame]
name: Bootstrap
description: Bootstrap
inputs:
platform:
description: "Platform name"
required: false
default: none
bootstrap-log-name:
description: "Bootstrap log name"
required: false
default: bootstrap-logs-${{ github.job }}
outputs:
cache-hit:
description: "Bootstrap environment was restored from cache"
value: ${{ fromJSON(steps.restore.outputs.outputs).cache-hit }} # dynamic action returns all outputs in `outputs`
runs:
using: "composite"
steps:
- name: Determine bootstrap cache configuration
id: prepare
shell: bash
run: |
# Determine bootstrap cache configuration
# In addition to the various setup files, the work directory matters as well,
# because the bootstrapped Pigweed environment contains absolute paths.
echo "Calculating bootstrap cache key for '$PWD'"
echo "Runner info:"
echo " RUNNER_OS=$RUNNER_OS"
echo " RUNNER_ARCH=$RUNNER_ARCH"
echo " inputs.platform=${{ inputs.platform }}"
echo " ImageOS=${ImageOS:-unknown}"
echo " ImageVersion=${ImageVersion:-unknown}"
FILES_HASH="${{ hashFiles('scripts/setup/*', 'scripts/tests/requirements.txt', 'scripts/py_matter_idl/*', 'third_party/pigweed/**') }}"
case "$RUNNER_OS" in
macOS)
echo "+ sw_vers output:"
sw_vers || true
echo "+ uname -a:"
uname -a || true
echo "+ Xcode version:"
xcodebuild -version || true
OS_HASH="$(sw_vers | shasum -a 256 | cut -d' ' -f1)"
;;
*)
echo "+ /etc/lsb-release:"
cat /etc/lsb-release || true
echo "+ uname -a:"
uname -a || true
OS_HASH="$(shasum -a 256 /etc/lsb-release | cut -d' ' -f1)"
;;
esac
echo "+ python details:"
echo " which python: $(command -v python || true)"
echo " python --version: $(python --version 2>&1 || true)"
PYTHON_HASH="$(python --version | shasum -a 256 | cut -d' ' -f1)"
FINAL_HASH="$(echo "$PWD:$FILES_HASH:$OS_HASH:$PYTHON_HASH" | shasum -a 256 | cut -d' ' -f1)"
echo "Hash components:"
echo " FILES_HASH=$FILES_HASH"
echo " OS_HASH=$OS_HASH"
echo " PYTHON_HASH=$PYTHON_HASH"
echo " FINAL_HASH=$FINAL_HASH"
echo key="${RUNNER_OS}-${RUNNER_ARCH}-${{ inputs.platform }}-${FINAL_HASH}" | tee -a "$GITHUB_OUTPUT"
# Split caches across backends
case "$RUNNER_OS" in
macOS) echo backend=actions;;
*) echo backend=buildjet;;
esac | tee -a "$GITHUB_OUTPUT"
- name: Bootstrap from cache
id: restore
uses: ./.github/actions/dynamic
continue-on-error: true
with:
action: ${{ steps.prepare.outputs.backend }}/cache/restore@v4
with: |
key: ${{ steps.prepare.outputs.key }}
path: |
.environment
build_overrides/pigweed_environment.gni
- name: Run bootstrap
if: ${{ fromJSON(steps.restore.outputs.outputs).cache-hit != 'true' }}
env:
PW_NO_CIPD_CACHE_DIR: 1
PW_ENVSETUP_NO_BANNER: 1
shell: bash
run: source scripts/bootstrap.sh -p all,${{ inputs.platform }}
- name: Save bootstrap cache
uses: ./.github/actions/dynamic
# Don't save cache if the build is a pull request, to prevent creation of multiple pr-ref caches with the same key.
# PR builds still will be able to restore from cache created by master build.
if: ${{ fromJSON(steps.restore.outputs.outputs).cache-hit != 'true' && github.event_name != 'pull_request' }}
continue-on-error: true
with:
action: ${{ steps.prepare.outputs.backend }}/cache/save@v4
with: |
key: ${{ steps.prepare.outputs.key }}
path: |
.environment
build_overrides/pigweed_environment.gni
- name: Upload bootstrap logs
uses: actions/upload-artifact@v4
if: ${{ always() && !env.ACT && fromJSON(steps.restore.outputs.outputs).cache-hit != 'true' }}
with:
name: ${{ inputs.bootstrap-log-name }}
path: |
.environment/gn_out/.ninja_log
.environment/pigweed-venv/*.log