Skip to content

Commit

Permalink
Use NFS cache as a mirror only
Browse files Browse the repository at this point in the history
Change-type: minor
Signed-off-by: Kyle Harding <[email protected]>
  • Loading branch information
klutchell committed Nov 1, 2024
1 parent aa8c9d7 commit 41a0399
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions .github/workflows/yocto-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,6 @@ jobs:
automation_dir: "${{ github.workspace }}/balena-yocto-scripts/automation"
BALENARC_BALENA_URL: ${{ vars.BALENA_HOST || inputs.deploy-environment || 'balena-cloud.com' }}
API_ENV: ${{ vars.BALENA_HOST || inputs.deploy-environment || 'balena-cloud.com' }}

# Yocto NFS sstate cache host
YOCTO_CACHE_HOST: ${{ vars.YOCTO_CACHE_HOST || 'nfs.product-os.io' }}
YOCTO_CACHE_DIR: ${{ github.workspace }}/shared/yocto-cache
BARYS_ARGUMENTS_VAR: ""

outputs:
Expand Down Expand Up @@ -446,17 +442,31 @@ jobs:
BARYS_ARGUMENTS_VAR="${BARYS_ARGUMENTS_VAR} --bitbake-args --no-setscene"
echo "BARYS_ARGUMENTS_VAR=${BARYS_ARGUMENTS_VAR}" >>"${GITHUB_ENV}"
# the directory is required even if we don't mount the NFS share
- name: Create shared cache mount point
run: |
sudo mkdir -p "${YOCTO_CACHE_DIR}/$(whoami)"
sudo chown -R "$(id -u):$(id -g)" "${YOCTO_CACHE_DIR}"
# https://wiki.yoctoproject.org/wiki/Enable_sstate_cache
# https://docs.yoctoproject.org/4.0.10/ref-manual/variables.html#term-MIRRORS
# https://docs.yoctoproject.org/4.0.10/ref-manual/variables.html#term-SSTATE_MIRRORS
- name: Mount shared NFS cache
if: env.YOCTO_CACHE_HOST != '' && contains(fromJSON(inputs.build-runs-on), 'self-hosted')
if: vars.YOCTO_CACHE_HOST && contains(fromJSON(inputs.build-runs-on), 'self-hosted')
# continue-on-error: true
env:
YOCTO_CACHE_HOST: ${{ vars.YOCTO_CACHE_HOST }}
MOUNTPOINT: /nfs/yocto
run: |
sudo mount -t nfs "${YOCTO_CACHE_HOST}:/" "${YOCTO_CACHE_DIR}" -o fsc,nolock
ls -al "${YOCTO_CACHE_DIR}/$(whoami)"
sudo mkdir -p "${MOUNTPOINT}"
sudo mount -t nfs "${YOCTO_CACHE_HOST}:/" "${MOUNTPOINT}" -o fsc,nolock
sudo chown -R "$(id -u):$(id -g)" "${MOUNTPOINT}/$(whoami)/"
_sstate_mirror="file://.* file://${MOUNTPOINT}/$(whoami)/${MACHINE}/sstate/PATH"
_git_mirror="git://.*/.* file://${MOUNTPOINT}/$(whoami)/shared-downloads/"
_ftp_mirror="ftp://.*/.* file://${MOUNTPOINT}/$(whoami)/shared-downloads/"
_http_mirror="http://.*/.* file://${MOUNTPOINT}/$(whoami)/shared-downloads/"
_https_mirror="https://.*/.* file://${MOUNTPOINT}/$(whoami)/shared-downloads/"
BARYS_ARGUMENTS_VAR="${BARYS_ARGUMENTS_VAR} -a 'SSTATE_MIRRORS:prepend=${_sstate_mirror}'" >> "${GITHUB_ENV}"
BARYS_ARGUMENTS_VAR="${BARYS_ARGUMENTS_VAR} -a 'MIRRORS:prepend=${_git_mirror}'" >> "${GITHUB_ENV}"
BARYS_ARGUMENTS_VAR="${BARYS_ARGUMENTS_VAR} -a 'MIRRORS:prepend=${_ftp_mirror}'" >> "${GITHUB_ENV}"
BARYS_ARGUMENTS_VAR="${BARYS_ARGUMENTS_VAR} -a 'MIRRORS:prepend=${_http_mirror}'" >> "${GITHUB_ENV}"
BARYS_ARGUMENTS_VAR="${BARYS_ARGUMENTS_VAR} -a 'MIRRORS:prepend=${_https_mirror}'" >> "${GITHUB_ENV}"
# All preperation complete before this step
# Start building balenaOS
Expand All @@ -466,6 +476,7 @@ jobs:
id: build
env:
HELPER_IMAGE_REPO: ghcr.io/balena-os/balena-yocto-scripts
SHARED_BUILD_DIR: ${{ github.workspace }}/shared/yocto-cache
run: |
# When building for non-x86 device types, meson, after building binaries must try to run them via qemu if possible , maybe as some sanity check or test?
# Therefore qemu must be used - and our runner mmap_min_addr is set to 4096 (default, set here: https://github.com/product-os/github-runner-kernel/blob/ef5a66951599dc64bf2920d896c36c6d9eda8df6/config/5.10/microvm-kernel-x86_64-5.10.config#L858
Expand All @@ -475,10 +486,12 @@ jobs:
sudo sysctl -w vm.mmap_min_addr=65536
sysctl vm.mmap_min_addr
mkdir -p "${SHARED_BUILD_DIR}"
./balena-yocto-scripts/build/balena-build.sh \
-d "${MACHINE}" \
-t "${{ secrets.BALENA_API_DEPLOY_KEY }}" \
-s "${YOCTO_CACHE_DIR}/$(whoami)" \
-s "${SHARED_BUILD_DIR}" \
-g "${BARYS_ARGUMENTS_VAR}"
if grep -R "ERROR: " build/tmp/log/*; then
Expand Down

0 comments on commit 41a0399

Please sign in to comment.