armbian-build/.github/workflows/build-kernel-on-merge-request.yml
2021-12-20 00:41:50 +01:00

165 lines
6.3 KiB
YAML

name: Build at pull request
on:
workflow_dispatch:
pull_request:
types: [review_requested, ready_for_review]
jobs:
Prepare:
name: "Find changed kernels"
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'Armbian' }}
outputs:
matrix: ${{steps.list_dirs.outputs.matrix}}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: armbian/build
path: build
ref: ${{ github.event.pull_request.head.sha }}
clean: false
- name: Checkout support scripts
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: armbian/scripts
path: scripts
clean: true
- name: Sync
run: |
mkdir -p build/userpatches
sudo cp scripts/configs/* build/userpatches/
echo "SHA: ${{ github.event.pull_request.head.sha }}"
- name: Pull Docker image
run: |
# make sure to cut what is after trunk in case we start from nightly
sudo docker pull ghcr.io/armbian/build:$(cat build/VERSION | sed 's/trunk.*/trunk/')"-$(dpkg --print-architecture)"
- name: Determine changed kernels
run: |
cd build
# we need to fix this once but fake toolchain will prevent downloading it each time
mkdir -p cache/toolchain/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu
touch cache/toolchain/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu/.download-complete
mkdir -p cache/toolchain/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi
touch cache/toolchain/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi/.download-complete
mkdir -p cache/toolchain/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux
touch cache/toolchain/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/.download-complete
mkdir -p cache/toolchain/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux
touch cache/toolchain/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/.download-complete
mkdir -p cache/toolchain/gcc-linaro-arm-none-eabi-4.8-2014.04_linux
touch cache/toolchain/gcc-linaro-arm-none-eabi-4.8-2014.04_linux/.download-complete
mkdir -p cache/toolchain/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu
touch cache/toolchain/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/.download-complete
mkdir -p cache/toolchain/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf
touch cache/toolchain/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/.download-complete
mkdir -p cache/toolchain/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu
touch cache/toolchain/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/.download-complete
mkdir -p cache/toolchain/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf
touch cache/toolchain/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/.download-complete
[[ ! -f .ignore_changes ]] && sudo touch .ignore_changes
mkdir -p cache/hash-beta
sudo rsync -ar --delete ../scripts/hash-beta/. cache/hash-beta/ 2> /dev/null
sudo cp ../scripts/configs/* userpatches/
sudo rm -f userpatches/targets.conf
sed -i "s/-it --rm/-i --rm/" userpatches/config-docker.conf
sed -i "s/COMPRESS_OUTPUTIMAGE=.*/COMPRESS_OUTPUTIMAGE=\"no\"/" userpatches/lib.config
- name: Prepare build matrix
id: list_dirs
run: |
MATRIX=$(cd build;./compile.sh docker all-new-beta-kernels BUILD_ALL="demo" | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" | egrep "^[0-9]" | awk '{ print $2 ":" $4 ":" $3 }' | tr -d '(),' | sort | uniq)
mkdir -p build-kernel
echo "no" > build-kernel/skip
if [[ -z "$MATRIX" ]]; then
MATRIX="none:none:none"
echo "yes" > build-kernel/skip
fi
echo ::set-output name=matrix::$(for x in $(echo "${MATRIX}"); do echo $x; done|jq -cnR '[inputs | select(length>0)]' | jq)
Linux:
name: "Build Linux"
needs: [ Prepare ]
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'armbian' }}
timeout-minutes: 480
strategy:
fail-fast: false
matrix:
node: ${{fromJson(needs.Prepare.outputs.matrix)}}
steps:
- name: Checkout Armbian support scripts
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: armbian/scripts
path: scripts
clean: true
- name: Checkout Armbian build script
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: armbian/build
path: build
ref: ${{ github.event.pull_request.head.sha }}
clean: false
- name: Sync
run: |
mkdir -p build/userpatches
sudo cp scripts/configs/* build/userpatches/
- name: Pull Docker image
if: ${{ matrix.node != 'none:none:none' }}
run: |
sudo docker pull ghcr.io/armbian/build:$(cat build/VERSION | sed 's/trunk.*/trunk/')"-$(dpkg --print-architecture)"
- name: Build
if: ${{ matrix.node != 'none:none:none' }}
run: |
CHUNK="${{ matrix.node }}"
BOARD=$(echo $CHUNK | cut -d":" -f1)
BRANCH=$(echo $CHUNK | cut -d":" -f2)
FAMILY=$(echo $CHUNK | cut -d":" -f2)
echo "FILE_NAME=${FAMILY}-${BRANCH}" >> $GITHUB_ENV
cd build
[[ ! -f .ignore_changes ]] && sudo touch .ignore_changes
sed -i "s/-it --rm/-i --rm/" userpatches/config-docker.conf
sed -i "s/COMPRESS_OUTPUTIMAGE=.*/COMPRESS_OUTPUTIMAGE=\"no\"/" userpatches/lib.config
./compile.sh docker ARMBIAN_MIRROR="https://github.com/armbian/mirror/releases/download/" BOARD="$BOARD" \
BETA="yes" KERNEL_ONLY="yes" BRANCH="$BRANCH" KERNEL_CONFIGURE="no" OFFLINE="no"
- name: Upload build artifacts
if: ${{ matrix.node != 'none:none:none' }}
uses: actions/upload-artifact@v2
with:
name: ${{ env.FILE_NAME }}
path: build/output/debs-beta/linux-*
if-no-files-found: ignore
retention-days: 30