ci: Add GitHub Actions

Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford 2025-02-27 10:17:19 -07:00 committed by Tim Crawford
parent 5b8094fc92
commit acad945825
5 changed files with 194 additions and 105 deletions

89
.github/workflows/ci.yaml vendored Normal file
View file

@ -0,0 +1,89 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: NONE
name: CI
on:
push:
branches-ignore:
- 'wip/*'
pull_request:
env:
XGCC_DIR: "/opt/xgcc"
XGCCPATH: "/opt/xgcc/bin"
jobs:
toolchain:
runs-on: ubuntu-24.04
timeout-minutes: 60
outputs:
models: ${{ steps.model-matrix.outputs.models }}
steps:
- uses: actions/checkout@v4
with:
lfs: true
submodules: recursive
fetch-tags: true
fetch-depth: 0
- name: Get coreboot toolchain
id: get_coreboot_toolchain
uses: actions/cache@v4
with:
path: ${{ env.XGCC_DIR }}
key: coreboot-${{ hashFiles('coreboot/util/crossgcc/sum/*') }}
- name: Build coreboot toolchain
if: steps.get_coreboot_toolchain.outputs.cache-hit != 'true'
run: ./scripts/coreboot-sdk.sh DEST=$XGCC_DIR
- name: Generate model matrix
id: model-matrix
run: |
FIRMWARE_MODELS=$(find models/ -maxdepth 1 -mindepth 1 -type d -printf "%f\n" | jq -cRSs 'split("\n")[:-1]')
echo "models=$FIRMWARE_MODELS" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-24.04
needs: toolchain
timeout-minutes: 30
strategy:
matrix:
model: ${{ fromJSON(needs.toolchain.outputs.models) }}
steps:
- uses: actions/checkout@v4
with:
lfs: true
submodules: recursive
fetch-tags: true
fetch-depth: 0
- name: Fix coreboot submodules
working-directory: ./coreboot
run: git submodule update --init --checkout --recursive --force
- name: Get coreboot toolchain
id: get_coreboot_toolchain
uses: actions/cache@v4
with:
path: ${{ env.XGCC_DIR }}
key: coreboot-${{ hashFiles('coreboot/util/crossgcc/sum/*') }}
fail-on-cache-miss: true
- name: Install deps
run: |
./scripts/install-deps.sh
./scripts/install-rust.sh
pushd ec; ./scripts/deps.sh; popd
- name: Build firmware
run: ./scripts/build.sh "${{ matrix.model }}"
#- name: Upload artifacts
# if: github.ref == 'refs/heads/master'
# uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.model }}-${{ github.sha }}
# path: build/
# retention-days: 30

View file

@ -1,9 +1,12 @@
# Building # Building
Dependencies can be installed with the provided script. Dependencies can be installed with the provided scripts.
``` ```
./scripts/install-deps.sh ./scripts/install-deps.sh
./scripts/install-rust.sh
./scripts/coreboot-sdk.sh
pushd ec; ./scripts/deps.sh; popd
``` ```
If rustup was installed for the first time, it will be required to source the If rustup was installed for the first time, it will be required to source the

View file

@ -61,6 +61,8 @@ else
exit 1 exit 1
fi fi
make -C coreboot CPUS="$(nproc)" crossgcc-i386 make -C coreboot \
make -C coreboot CPUS="$(nproc)" crossgcc-x64 crossgcc-x64 \
make -C coreboot gitconfig crossgcc-i386 \
CPUS="$(nproc)" \
"${@}"

View file

@ -5,99 +5,96 @@
set -eE set -eE
msg() {
echo -e "\x1B[1m$*\x1B[0m" >&2
}
trap 'msg "\x1B[31mFailed to install dependencies!"' ERR
. /etc/os-release . /etc/os-release
msg "Installing system build dependencies"
if [[ "${ID}" =~ "debian" ]] || [[ "${ID_LIKE}" =~ "debian" ]]; then if [[ "${ID}" =~ "debian" ]] || [[ "${ID_LIKE}" =~ "debian" ]]; then
sudo apt-get --quiet update sudo apt-get --quiet update
sudo apt-get --quiet install \ sudo apt-get --quiet install --no-install-recommends --assume-yes \
--no-install-recommends \ bison \
--assume-yes \ build-essential \
build-essential \ bzip2 \
ccache \ ca-certificates \
cmake \ ccache \
curl \ cmake \
dosfstools \ curl \
flashrom \ dosfstools \
git-lfs \ flashrom \
libncurses-dev \ flex \
libssl-dev \ g++ \
libudev-dev \ gcc \
mtools \ git-lfs \
parted \ gnat \
pkgconf \ libncurses-dev \
python-is-python3 \ libnss3-dev \
uuid-dev \ libssl-dev \
zlib1g-dev libudev-dev \
make \
mtools \
parted \
patch \
pkgconf \
python-is-python3 \
tar \
uuid-dev \
xz-utils \
zlib1g-dev
elif [[ "${ID}" =~ "fedora" ]] || [[ "${ID_LIKE}" =~ "fedora" ]]; then elif [[ "${ID}" =~ "fedora" ]] || [[ "${ID_LIKE}" =~ "fedora" ]]; then
sudo dnf group install c-development sudo dnf group install c-development
sudo dnf install \ sudo dnf install --assumeyes \
--assumeyes \ bison \
ccache \ bzip2 \
cmake \ ca-certificates \
curl \ ccache \
dosfstools \ cmake \
flashrom \ curl \
git-lfs \ dosfstools \
libuuid-devel \ flashrom \
mtools \ flex \
ncurses-devel \ gcc \
openssl-devel \ gcc-c++ \
parted \ gcc-gnat \
patch \ git-lfs \
python-unversioned-command \ libuuid-devel \
python3 \ make \
systemd-devel \ mtools \
zlib-devel ncurses-devel \
nss-devel \
openssl-devel \
parted \
patch \
python-unversioned-command \
python3 \
rustup \
systemd-devel \
tar \
xz \
zlib-devel
elif [[ "${ID}" =~ "arch" ]] || [[ "${ID_LIKE}" =~ "arch" ]]; then elif [[ "${ID}" =~ "arch" ]] || [[ "${ID_LIKE}" =~ "arch" ]]; then
sudo pacman -S \ sudo pacman -S --noconfirm \
--noconfirm \ bison \
ccache \ bzip2 \
cmake \ ca-certificates \
curl \ ccache \
dosfstools \ cmake \
flashrom \ curl \
git-lfs \ dosfstools \
mtools \ flashrom \
ncurses \ flex \
parted \ gcc \
patch \ gcc-ada \
python \ git-lfs \
systemd-libs make \
mtools \
ncurses \
nss \
parted \
patch \
python \
rustup \
systemd-libs \
tar \
xz \
zlib
else else
msg "Unknown system ID: ${ID}" echo "unsupported host: ${ID}"
msg "Please add support for your distribution to: $0" exit 1
exit 1
fi fi
# Don't run on Jenkins
if [ -z "${CI}" ]; then
msg "Installing GIT LFS hooks"
git lfs install
msg "Downloading GIT LFS artifacts"
git lfs pull
fi
msg "Initializing submodules"
git submodule update --init --recursive --checkout --progress
msg "Building coreboot toolchains"
./scripts/coreboot-sdk.sh
msg "Installing Rust toolchain and components"
./scripts/install-rust.sh
msg "Installing EC dependencies"
pushd ec
./scripts/deps.sh
popd
msg "\x1B[32mSuccessfully installed dependencies"
echo "Ready to run ./scripts/build.sh [model]" >&2

View file

@ -8,20 +8,18 @@
set -Ee set -Ee
RUSTUP_NEW_INSTALL=0
# NOTE: rustup is used to allow multiple toolchain installations.
if ! command -v rustup >/dev/null 2>&1; then if ! command -v rustup >/dev/null 2>&1; then
RUSTUP_NEW_INSTALL=1 if command -v rustup-init >/dev/null 2>&1; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ rustup-init -y \
| sh -s -- -y --default-toolchain stable --default-toolchain stable \
--profile minimal \
--no-update-default-toolchain
else
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --default-toolchain stable
fi
. "${HOME}/.cargo/env" . "${HOME}/.cargo/env"
fi fi
rustup show active-toolchain || rustup toolchain install rustup show active-toolchain || rustup toolchain install
if [ "$RUSTUP_NEW_INSTALL" = "1" ]; then
printf "\e[33m>> rustup was just installed. Ensure cargo is on the PATH with:\e[0m\n"
printf " source ~/.cargo/env\n\n"
fi