Files
carbon-lang/.github/actions/build-setup-ubuntu/action.yml
T
dependabot[bot] 4e4b35e6e7 Bump the github-actions-major group across 5 directories with 9 updates (#8098)
- `actions/cache` 5.0.3 -> 6.1.0 (major)
- `actions/checkout` 6.0.2 -> 7.0.1 (major)
- `actions/configure-pages` 5.0.0 -> 6.0.0 (major)
- `actions/deploy-pages` 4.0.5 -> 5.0.1 (major)
- `actions/stale` 9.0.0 -> 11.0.0 (major)
- `actions/upload-pages-artifact` 4.0.0 -> 5.0.0 (major)
- `astral-sh/setup-uv` 8.1.0 -> 10.3.3 (major)
- `dorny/paths-filter` 3.0.2 -> 4.0.3 (major)
- `jlumbroso/free-disk-space` 1.3.1 -> 2.0.0 (major)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-06 03:12:37 +00:00

95 lines
3.9 KiB
YAML

# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
name: Setup build environment (Ubuntu)
runs:
using: composite
steps:
# Ubuntu images start with ~23GB available; this takes a few seconds to add
# ~22GB more.
#
# Although we could delete more, if we run into a limit, not deleting
# everything provides a little flexibility to get space while trying
# to shrink the build.
- name: Free up disk space
uses: jlumbroso/free-disk-space@ceedf095f4ec1a097402bc6bd80831f2e1a6fde6 # v2.0.0
with:
android: true
dotnet: true
haskell: true
# Enabling large-packages adds ~3 minutes to save ~4GB, so turn it off
# to save time.
large-packages: false
# The image's Android environment variables still point into the SDK and
# NDK deleted above, which confuses tools that look for them, such as
# rules_android. `$GITHUB_ENV` can't unset variables, so set them to empty,
# which rules_android treats as unset.
- name: Clear Android environment variables
shell: bash
run: |
for var in ANDROID_HOME ANDROID_SDK_ROOT ANDROID_NDK ANDROID_NDK_HOME \
ANDROID_NDK_LATEST_HOME ANDROID_NDK_ROOT; do
echo "$var=" >> "$GITHUB_ENV"
done
# Select the LLVM release - by the cache key and the download.
- name: Select LLVM release
shell: bash
run: |
if [[ "${{ runner.arch }}" == "ARM64" ]]; then
echo "LLVM_RELEASE=21.1.8" >> "$GITHUB_ENV"
else
echo "LLVM_RELEASE=21.1.8" >> "$GITHUB_ENV"
fi
# Cache and install a recent version of LLVM. This uses the GitHub action
# cache to avoid directly downloading on each iteration and improve
# reliability.
- name: Cache LLVM and Clang installation
id: cache-llvm-ubuntu
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/llvm
key: LLVM-${{ env.LLVM_RELEASE }}-Cache-ubuntu-${{ runner.arch }}
- name: Download LLVM and Clang installation
if: steps.cache-llvm-ubuntu.outputs.cache-hit != 'true'
shell: bash
run: |
cd ~
# `LLVM_RELEASE` comes from the "Select LLVM release" step; `runner.arch`
# (`X64`/`ARM64`) matches the package's arch suffix.
LLVM_TARBALL_NAME=LLVM-$LLVM_RELEASE-Linux-${{ runner.arch }}
LLVM_PATH=~/llvm
echo "*** Downloading $LLVM_RELEASE"
wget --show-progress=off "https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_RELEASE/$LLVM_TARBALL_NAME.tar.xz"
echo "*** Extracting $LLVM_TARBALL_NAME.tar.xz"
mkdir $LLVM_PATH
tar -xJf $LLVM_TARBALL_NAME.tar.xz --strip-components=1 -C $LLVM_PATH
echo "*** Deleting $LLVM_TARBALL_NAME.tar.xz"
rm $LLVM_TARBALL_NAME.tar.xz
echo "*** Testing `clang++ --version`"
$LLVM_PATH/bin/clang++ --version
# The installation contains *huge* parts of LLVM we don't need for the
# toolchain. Prune them here to keep our cache small. x86-64 and
# AArch64 use different LLVM releases whose tool sets differ, so `-f`
# ignores entries that are absent from a given package.
echo "*** Cleaning the 'llvm' directory"
rm -f $LLVM_PATH/lib/{*.a,*.so,*.so.*}
rm -f $LLVM_PATH/bin/{flang-*,mlir-*,clang-{scan-deps,check,repl},*-test,llvm-{lto*,reduce,bolt*,exegesis,jitlink},bugpoint,opt,llc}
echo "*** Size of the 'llvm' directory"
du -hs $LLVM_PATH
- name: Setup LLVM and Clang paths
shell: bash
run: |
LLVM_PATH=~/llvm
echo "Using ${LLVM_PATH}"
echo "${LLVM_PATH}/bin" >> $GITHUB_PATH
echo '*** ls "${LLVM_PATH}"'
ls "${LLVM_PATH}"
echo '*** ls "${LLVM_PATH}/bin"'
ls "${LLVM_PATH}/bin"