mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 12:33:02 +02:00
There are 2 main reasons for this:
1) It's almost impossible to write complex logical expressions in GH
workflows. I wanted to pass "" as flavor when not building _minimal.
So that the end target string would become TARGET + FLAVOR where
FLAVOR is empty, making it x86_64 for example.
As it turns out "" is false in GH workflow logical expressions, this
in conjunction with the limitations the interpreter has made it hard
to actually write sane expressions in the "with:" variables when
calling downstream jobs via workflow calls.
Here's an example of what I was trying to do and could not:
with:
flavor: ${{ (
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'ci:main')
) && '' || '_minimal' }}
As '' is false, the first sets of expressions always evaluates to
false making the string "_minimal". I tried bracing this in various
ways and to use "null" or various JSON objects, all in vain.
2) It reduces complexity instead of adding additional.
Signed-off-by: Richard Alpe <richard@bit42.se>
166 lines
5.2 KiB
YAML
166 lines
5.2 KiB
YAML
name: Build
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
target:
|
|
description: "Build target (e.g. aarch64 or aarch64_minimal)"
|
|
default: "x86_64"
|
|
type: string
|
|
parallel:
|
|
description: 'Massive parallel build of each image'
|
|
default: true
|
|
type: boolean
|
|
name:
|
|
description: "Name (for spin overrides)"
|
|
default: "infix"
|
|
type: string
|
|
infix_repo:
|
|
description: 'Repo to checkout (for spin overrides)'
|
|
default: kernelkit/infix
|
|
type: string
|
|
|
|
workflow_call:
|
|
inputs:
|
|
target:
|
|
required: true
|
|
type: string
|
|
name:
|
|
required: true
|
|
type: string
|
|
infix_repo:
|
|
required: false
|
|
type: string
|
|
default: kernelkit/infix
|
|
parallel:
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
|
|
env:
|
|
NAME: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.name || inputs.name }}
|
|
TARGET: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target || inputs.target }}
|
|
INFIX_REPO: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.infix_repo || inputs.infix_repo }}
|
|
|
|
jobs:
|
|
build:
|
|
name: Build ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.name || inputs.name }} ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target || inputs.target }}
|
|
runs-on: [ self-hosted, latest ]
|
|
env:
|
|
PARALLEL: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.parallel == 'true' || github.event_name != 'workflow_dispatch' && inputs.parallel == true }}
|
|
strategy:
|
|
fail-fast: false
|
|
outputs:
|
|
build_id: ${{ steps.vars.outputs.INFIX_BUILD_ID }}
|
|
steps:
|
|
- name: Cleanup Build Folder
|
|
run: |
|
|
ls -la ./
|
|
rm -rf ./* || true
|
|
rm -rf ./.??* || true
|
|
ls -la ./
|
|
|
|
- name: Checkout infix repo
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: ${{ env.INFIX_REPO }}
|
|
ref: ${{ github.ref }}
|
|
clean: true
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
|
|
- name: Set Build Variables
|
|
id: vars
|
|
run: |
|
|
if [ -n "${{ github.event.pull_request.head.sha }}" ]; then
|
|
# Since PRs are built from an internally generated merge
|
|
# commit, reverse lookups of PRs and/or commits from
|
|
# image version information are cumbersome. Therefore:
|
|
# explicitly set a build id that references both the PR
|
|
# and the commit.
|
|
printf "INFIX_BUILD_ID=pr%d.%.7s\n" \
|
|
"${{ github.event.number }}" "${{ github.event.pull_request.head.sha }}" \
|
|
| tee -a $GITHUB_OUTPUT $GITHUB_ENV
|
|
fi
|
|
|
|
target=${{ env.TARGET }}
|
|
name=${{ env.NAME }}
|
|
echo "dir=${name}-${target}" >> $GITHUB_OUTPUT
|
|
echo "tgz=${name}-${target}.tar.gz" >> $GITHUB_OUTPUT
|
|
echo "Building target ${target}_defconfig"
|
|
|
|
- name: Restore Cache of dl/
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: dl/
|
|
key: dl-${{ hashFiles('.git/modules/buildroot/HEAD', 'configs/*', 'package/*/*.hash') }}
|
|
restore-keys: |
|
|
dl-
|
|
|
|
- name: Restore Cache of .ccache/
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .ccache/
|
|
key: ccache-${{ env.TARGET }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }}
|
|
restore-keys: |
|
|
ccache-${{ env.TARGET }}-
|
|
ccache-
|
|
|
|
- name: Configure ${{ env.TARGET }}
|
|
run: |
|
|
make ${{ env.TARGET }}_defconfig
|
|
|
|
- name: Unit Test ${{ env.TARGET }}
|
|
run: |
|
|
make test-unit
|
|
|
|
- name: Prepare parallel build
|
|
id: parallel
|
|
run: |
|
|
|
|
if [ "$PARALLEL" == "true" ]; then
|
|
echo "BR2_PER_PACKAGE_DIRECTORIES=y" >> output/.config
|
|
MAKE="make -j$((`getconf _NPROCESSORS_ONLN` / 2 + 2))"
|
|
echo "Building in parallel with -j$((`getconf _NPROCESSORS_ONLN` / 2 + 2))"
|
|
else
|
|
echo "Disabling parallel build"
|
|
MAKE="make"
|
|
fi
|
|
echo "MAKE=$MAKE" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build ${{ env.TARGET }}
|
|
run: |
|
|
echo "Building ${{ env.TARGET }}_defconfig ..."
|
|
eval "${{ steps.parallel.outputs.MAKE }}"
|
|
|
|
- name: Check SBOM from Build
|
|
run: |
|
|
make legal-info
|
|
|
|
- name: Build test specification
|
|
run: |
|
|
make test-spec
|
|
|
|
- name: Resulting size of build
|
|
run: |
|
|
printf "Size of complete tree : "
|
|
du -sh .
|
|
printf "Size of output/ : "
|
|
du -sh output
|
|
printf "Size of dl/ : "
|
|
du -sh dl
|
|
printf "Size of output/images/: "
|
|
ls -l output/images/
|
|
|
|
- name: Prepare ${{ env.TARGET }} Artifact
|
|
run: |
|
|
cd output/
|
|
mv images ${{ steps.vars.outputs.dir }}
|
|
ln -s ${{ steps.vars.outputs.dir }} images
|
|
tar cfz ${{ steps.vars.outputs.tgz }} ${{ steps.vars.outputs.dir }}
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
path: output/${{ steps.vars.outputs.tgz }}
|
|
name: artifact-${{ env.TARGET }}
|