187 lines
6.3 KiB
YAML
187 lines
6.3 KiB
YAML
name: 'Setup action'
|
|
description: 'Sets up shared CI tooling'
|
|
author: 'Andrew Kaster <akaster@serenityos.org>'
|
|
inputs:
|
|
os:
|
|
description: 'Operating System to set up'
|
|
required: true
|
|
default: 'Linux'
|
|
arch:
|
|
description: 'Target Architecture to set up'
|
|
required: true
|
|
default: 'x86_64'
|
|
toolchain:
|
|
description: 'Toolchain to use'
|
|
required: true
|
|
default: 'Clang'
|
|
type:
|
|
description: 'Whether the setup is for building or linting'
|
|
required: false
|
|
default: 'build'
|
|
outputs:
|
|
ccache_path:
|
|
description: 'Path to the ccache directory'
|
|
value: ${{ steps.workspace.outputs.ccache_path }}
|
|
vcpkg_cache_path:
|
|
description: 'Path to the vcpkg binary cache'
|
|
value: ${{ steps.workspace.outputs.vcpkg_cache_path }}
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: 'Set workspace environment'
|
|
id: 'workspace'
|
|
shell: bash
|
|
run: |
|
|
echo "LADYBIRD_SOURCE_DIR=${GITHUB_WORKSPACE}" >> "$GITHUB_ENV"
|
|
echo "CCACHE_DIR=${GITHUB_WORKSPACE}/.ccache" >> "$GITHUB_ENV"
|
|
echo "VCPKG_ROOT=${GITHUB_WORKSPACE}/Build/vcpkg" >> "$GITHUB_ENV"
|
|
echo "ccache_path=${GITHUB_WORKSPACE}/.ccache" >> "$GITHUB_OUTPUT"
|
|
echo "vcpkg_cache_path=${GITHUB_WORKSPACE}/Build/caches/vcpkg-binary-cache" >> "$GITHUB_OUTPUT"
|
|
echo "GIT_CONFIG_GLOBAL=${RUNNER_TEMP}/gitconfig" >> "$GITHUB_ENV"
|
|
git config --file "${RUNNER_TEMP}/gitconfig" --add safe.directory "${GITHUB_WORKSPACE}"
|
|
mkdir -p "${RUNNER_TEMP}/pip-cache"
|
|
echo "PIP_CACHE_DIR=${RUNNER_TEMP}/pip-cache" >> "$GITHUB_ENV"
|
|
|
|
- uses: actions/setup-python@v6
|
|
if: ${{ inputs.os != 'Linux' }}
|
|
with:
|
|
python-version: 3.12
|
|
cache: 'pip'
|
|
|
|
# actions/setup-python can fail to find its tool-cache pip inside job containers.
|
|
- name: 'Set up Python environment'
|
|
if: ${{ inputs.os == 'Linux' }}
|
|
shell: bash
|
|
run: |
|
|
python3 -m venv "${RUNNER_TEMP}/ladybird-python"
|
|
echo "${RUNNER_TEMP}/ladybird-python/bin" >> "$GITHUB_PATH"
|
|
echo "pythonLocation=${RUNNER_TEMP}/ladybird-python" >> "$GITHUB_ENV"
|
|
|
|
- name: 'Install Python dependencies'
|
|
shell: bash
|
|
run: |
|
|
python3 -m pip install --upgrade pip
|
|
|
|
if ${{ inputs.type == 'build' }} ; then
|
|
pip3 install pyyaml requests six
|
|
else
|
|
pip3 install pyright ruff
|
|
fi
|
|
|
|
- name: Ensure clang-cl is available
|
|
if: ${{ inputs.os == 'Windows' && inputs.toolchain == 'ClangCL' }}
|
|
shell: bash
|
|
run: |
|
|
if ! where clang-cl > /dev/null 2>&1 ; then
|
|
# Keep the LLVM version in sync with GitHub's Windows runner image:
|
|
# https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-Readme.md
|
|
choco install -y llvm --no-progress --version=20.1.8
|
|
|
|
echo "C:/Program Files/LLVM/bin" >> "${GITHUB_PATH}"
|
|
export PATH="/c/Program Files/LLVM/bin:${PATH}"
|
|
fi
|
|
clang-cl --version
|
|
|
|
- name: 'Select latest Xcode'
|
|
if: ${{ inputs.os == 'macOS' || inputs.os == 'Android' }}
|
|
uses: maxim-lobanov/setup-xcode@v1
|
|
with:
|
|
xcode-version: 26.2
|
|
|
|
- name: 'Install Dependencies'
|
|
if: ${{ inputs.os == 'macOS' || inputs.os == 'Android' }}
|
|
shell: bash
|
|
run: |
|
|
brew update
|
|
|
|
brew install \
|
|
autoconf \
|
|
autoconf-archive \
|
|
automake \
|
|
bash \
|
|
ccache \
|
|
coreutils \
|
|
libtool \
|
|
llvm@21 \
|
|
nasm \
|
|
ninja \
|
|
pkg-config \
|
|
qt \
|
|
unzip
|
|
|
|
- name: 'Install Rust toolchain'
|
|
if: ${{ inputs.os == 'macOS' || inputs.os == 'Android' }}
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
- name: 'Resolve wasm-tools release'
|
|
id: 'wasm-tools'
|
|
if: ${{ inputs.type == 'build' && inputs.os != 'Linux' }}
|
|
shell: bash
|
|
run: |
|
|
VERSION=1.243.0
|
|
if ${{ inputs.arch == 'arm64' }} ; then
|
|
ARCH=aarch64
|
|
else
|
|
ARCH=${{ inputs.arch }}
|
|
fi
|
|
LOWERCASE_OS=$( echo -n '${{ inputs.os }}' | tr '[:upper:]' '[:lower:]')
|
|
if ${{ inputs.os == 'Windows' }} ; then
|
|
EXTENSION=zip
|
|
else
|
|
EXTENSION=tar.gz
|
|
fi
|
|
NAME="wasm-tools-${VERSION}-${ARCH}-${LOWERCASE_OS}"
|
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
echo "name=${NAME}" >> "$GITHUB_OUTPUT"
|
|
echo "filename=${NAME}.${EXTENSION}" >> "$GITHUB_OUTPUT"
|
|
echo "extension=${EXTENSION}" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: 'Cache wasm-tools'
|
|
id: 'wasm-tools-cache'
|
|
if: ${{ inputs.type == 'build' && inputs.os != 'Linux' }}
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: ${{ github.workspace }}/${{ steps.wasm-tools.outputs.name }}
|
|
key: ${{ steps.wasm-tools.outputs.name }}
|
|
|
|
- name: 'Install wasm-tools'
|
|
if: ${{ inputs.type == 'build' && inputs.os != 'Linux' && steps.wasm-tools-cache.outputs.cache-hit != 'true' }}
|
|
shell: bash
|
|
run: |
|
|
FILENAME="${{ steps.wasm-tools.outputs.filename }}"
|
|
URL="https://github.com/bytecodealliance/wasm-tools/releases/download/v${{ steps.wasm-tools.outputs.version }}/${FILENAME}"
|
|
|
|
delays=(5 15 45)
|
|
attempt=1
|
|
until curl --fail --location --output "${FILENAME}" "${URL}"; do
|
|
if (( attempt > ${#delays[@]} )); then
|
|
echo "wasm-tools download failed after $(( ${#delays[@]} + 1 )) attempts" >&2
|
|
exit 1
|
|
fi
|
|
echo "wasm-tools download failed; retrying in ${delays[attempt-1]}s" >&2
|
|
sleep "${delays[attempt-1]}"
|
|
attempt=$(( attempt + 1 ))
|
|
done
|
|
|
|
if [ "${{ steps.wasm-tools.outputs.extension }}" == 'zip' ]; then
|
|
unzip "${FILENAME}"
|
|
else
|
|
tar -xzf "${FILENAME}"
|
|
fi
|
|
rm "${FILENAME}"
|
|
|
|
- name: 'Add wasm-tools to PATH'
|
|
if: ${{ inputs.type == 'build' && inputs.os != 'Linux' }}
|
|
shell: bash
|
|
run: echo "${GITHUB_WORKSPACE}/${{ steps.wasm-tools.outputs.name }}" >> "$GITHUB_PATH"
|
|
|
|
- name: 'Set required environment variables'
|
|
if: ${{ inputs.os == 'Linux' && inputs.arch == 'arm64' }}
|
|
shell: bash
|
|
run: echo "VCPKG_FORCE_SYSTEM_BINARIES=1" >> "$GITHUB_ENV"
|
|
|
|
- name: 'Install vcpkg'
|
|
if: ${{ inputs.type == 'build' }}
|
|
shell: bash
|
|
run: ./Meta/Utils/build_vcpkg.py
|