Snapshot Build #274
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# thinRoot Snapshot build | |
# yamllint disable rule:truthy | |
--- | |
name: Snapshot Build | |
on: | |
schedule: | |
- cron: '0 0 * * *' # run at 0 AM UTC | |
workflow_dispatch: | |
inputs: | |
skip_build: | |
description: 'Skip build (for testing workflow)?' | |
required: true | |
default: "false" | |
# default read-only permission | |
permissions: | |
contents: read | |
jobs: | |
repo-check: | |
name: Check for Changes | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- id: commit-check | |
run: echo "has-commits=$(git --no-pager log --pretty='format:%an' --since='24 hours ago' | grep -v github-actions | wc -l)" >> $GITHUB_OUTPUT | |
outputs: | |
has-commits: ${{ steps.commit-check.outputs.has-commits }} | |
build: | |
permissions: | |
contents: write # actions/upload-artifact | |
name: Snapshot build [${{ matrix.platform }}] | |
if: ${{ github.repository == 'jens-maus/thinRoot' && (github.event_name != 'schedule' || needs.repo-check.outputs.has-commits > 0) }} | |
runs-on: self-hosted | |
needs: repo-check | |
timeout-minutes: 300 | |
outputs: | |
build_datetime: ${{ steps.env.outputs.build_datetime }} | |
build_version: ${{ steps.env.outputs.build_version }} | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: [generic-x86_64] | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Install Dependencies | |
run: | | |
if ! dpkg-query -l wget bc cpio rsync zip python3 file >/dev/null 2>&1; then | |
apt update | |
apt install -y --no-install-recommends wget bc cpio rsync zip python3 file | |
fi | |
if ! getent group | grep -q ^builder:; then groupadd -g 48 builder; fi | |
if ! getent passwd | grep -q ^builder:; then useradd -m -u 1003 -g 48 -G sudo builder; fi | |
if ! grep -q ^builder; then echo "builder ALL=(ALL:ALL) NOPASSWD: ALL" >>/etc/sudoers; fi | |
chown -R builder:builder /home/builder | |
- name: Setup Environment | |
id: env | |
run: | | |
echo "DATE=$(date +%Y%m%d)" >> $GITHUB_ENV | |
echo "VERSION=$(date +%Y%m%d)" >> $GITHUB_ENV | |
echo "GITHUB_SHA7=$(echo ${GITHUB_SHA::7})" >> $GITHUB_ENV | |
echo "FAKE_BUILD=${{ github.event.inputs.skip_build }}" >> $GITHUB_ENV | |
JLEVEL=0 | |
if [[ -f /sys/fs/cgroup/cpu.max ]]; then # cgroups v2 | |
CPU_QUOTA=$(cut -d ' ' -f1 /sys/fs/cgroup/cpu.max) | |
if [[ "${CPU_QUOTA}" != "max" ]]; then | |
CPU_PERIOD=$(cut -d ' ' -f2 /sys/fs/cgroup/cpu.max) | |
JLEVEL=$((CPU_QUOTA / CPU_PERIOD + 1)) | |
fi | |
elif [[ -f /sys/fs/cgroup/cpu/cpu.cfs_quota_us ]]; then # cgroups v1 | |
CPU_QUOTA=$(cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us) | |
if [[ "${CPU_QUOTA}" != "-1" ]]; then | |
CPU_PERIOD=$(cat /sys/fs/cgroup/cpu/cpu.cfs_period_us) | |
JLEVEL=$((CPU_QUOTA / CPU_PERIOD + 1)) | |
fi | |
fi | |
echo "JLEVEL=${JLEVEL}" >> $GITHUB_ENV | |
echo "build_datetime=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT | |
echo "build_version=$(date +%Y%m%d)" >> $GITHUB_OUTPUT | |
# - name: remote debug tmate session | |
# uses: mxschmitt/action-tmate@v1 | |
# if: matrix.platform == 'ova' | |
# major build step | |
- name: Build | |
timeout-minutes: 300 | |
shell: bash | |
run: | | |
rm -rf release/thinroot-* buildroot-????.* | |
sudo -H -E -u builder nice -n 19 make DATE=${{ env.DATE }} BR2_DL_DIR=/mnt/download BR2_CCACHE_DIR=/mnt/ccache/${{ matrix.platform }} BR2_JLEVEL=${{ env.JLEVEL }} clean-all ${{ matrix.platform }}-release | |
# check linux kernel config consistency | |
- name: Check Linux Kconfig | |
run: | | |
sudo -H -E -u builder nice -n 19 make DATE=${{ env.DATE }} BR2_DL_DIR=/mnt/download BR2_CCACHE_DIR=/mnt/ccache/${{ matrix.platform }} BR2_JLEVEL=${{ env.JLEVEL }} PRODUCT=${{ matrix.platform }} linux-check-dotconfig | |
######################## | |
# upload build artifacts | |
- name: Upload build artifact [generic-x86_64] | |
uses: actions/upload-artifact@v4 | |
with: | |
path: release/thinroot-${{ env.VERSION }}-${{ matrix.platform }}.img* | |
name: thinroot-${{ env.VERSION }}-${{ env.GITHUB_SHA7 }}-${{ matrix.platform }}.img | |
continue-on-error: true | |
# cleanup | |
- name: Cleanup | |
run: | | |
make clean-all | |
rm -rf release/thinroot-* buildroot-????.* | |
cleanup: | |
permissions: | |
contents: write # c-hive/gha-remove-artifacts | |
packages: write # smartsquaregmbh/delete-old-packages | |
actions: write # c-hive/gha-remove-artifacts | |
name: Cleanup artifacts/packages | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Remove old artifacts | |
uses: c-hive/[email protected] | |
with: | |
age: '2 months' | |
skip-tags: true | |
skip-recent: 15 | |
continue-on-error: true |