From 3ed1f1fb835b6db138dee2b6a7f4b8225e872378 Mon Sep 17 00:00:00 2001 From: daspk Date: Tue, 27 Aug 2024 22:56:25 +0700 Subject: [PATCH 1/5] [CI] Add AArch64 GitHub Action Workflow * Add a new GitHub Actions workflow for AArch64 builds using ArchLinux example from https://github.com/marketplace/actions/arm-runner. This prepares an ArchLinux image, sets up the nix environment, and builds the project for AArch64. --- .github/workflows/aarch64.yml | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/aarch64.yml diff --git a/.github/workflows/aarch64.yml b/.github/workflows/aarch64.yml new file mode 100644 index 0000000..e810c87 --- /dev/null +++ b/.github/workflows/aarch64.yml @@ -0,0 +1,84 @@ +# https://github.com/pguyot/arm-runner-action/blob/main/.github/workflows/test-archlinux.yml +name: OTB Arch64 + +on: + pull_request: + push: + branches: [main] + workflow_dispatch: + +jobs: + # ArchLinux does not come with an image combining root and boot partitions + # This shows how to proceed and could be combined with cache. + test_archlinux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Prepare ArchLinux image + run: | + # https://archlinuxarm.org/platforms/armv7/broadcom/raspberry-pi-2 + # Install dependency + sudo apt-get -y install libarchive-tools + # Create a 1.5 GB image + dd if=/dev/zero of=$RUNNER_TEMP/archlinux.img bs=1M count=1536 + # 2. At the fdisk prompt, delete old partitions and create a new one: + # using the sed comment trick of https://superuser.com/a/984637 + sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk $RUNNER_TEMP/archlinux.img + o # clear the in memory partition table + n # new partition + p # primary partition + 1 # partition number 1 + # default - start at beginning of disk + +200M # 200 MB boot partition + t # type + c # W95 FAT32 (LBA) + n # new partition + p # primary partition + 2 # partion number 2 + # default, start immediately after preceding partition + # default, extend partition to end of disk + w # write the partition table + q # and we're done + EOF + # create loopdev + loopdev=$(sudo losetup --find --show --partscan $RUNNER_TEMP/archlinux.img) + # 3. Create and mount the FAT filesystem: + sudo mkfs.vfat ${loopdev}p1 + mkdir boot + sudo mount ${loopdev}p1 boot + # 4. Create and mount the ext4 filesystem: + sudo mkfs.ext4 ${loopdev}p2 + mkdir root + sudo mount ${loopdev}p2 root + # 5. Download and extract the root filesystem: + wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz + sudo -u root bsdtar -xpf ArchLinuxARM-rpi-armv7-latest.tar.gz -C root + sync + # 6. Move boot files to the first partition: + sudo mv root/boot/* boot + # 7. Unmount the two partitions: + sudo umount boot root + # Cleanup + rm ArchLinuxARM-rpi-armv7-latest.tar.gz + rmdir boot + rmdir root + - uses: pguyot/arm-runner-action@HEAD + with: + base_image: file://$RUNNER_TEMP/archlinux.img + cpu: cortex-a53 + commands: | + # 10. Initialize the pacman keyring and populate the Arch Linux ARM package signing keys: + pacman-key --init + pacman-key --populate archlinuxarm + - uses: DeterminateSystems/nix-installer-action@main + with: + extra-conf: | + fallback = true + http-connections = 128 + max-substitution-jobs = 128 + extra-platforms = aarch64-linux + - name: Build system + - uses: DeterminateSystems/magic-nix-cache-action@main + - run: | + nix build --system ${{ matrix.machine.platform }} .#otb-dev + nix build --system ${{ matrix.machine.platform }} .#otb From 8aaa34691f9a7ff0eec7f0f2247ceef51a743f24 Mon Sep 17 00:00:00 2001 From: daspk Date: Tue, 27 Aug 2024 23:07:08 +0700 Subject: [PATCH 2/5] [FIX] Fix Aarch64 workflow build system * Fix the matrix.machine.platform with aarch64-linux in Nix build commands. --- .github/workflows/aarch64.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/aarch64.yml b/.github/workflows/aarch64.yml index e810c87..129762d 100644 --- a/.github/workflows/aarch64.yml +++ b/.github/workflows/aarch64.yml @@ -80,5 +80,5 @@ jobs: - name: Build system - uses: DeterminateSystems/magic-nix-cache-action@main - run: | - nix build --system ${{ matrix.machine.platform }} .#otb-dev - nix build --system ${{ matrix.machine.platform }} .#otb + nix build --system aarch64-linux .#otb-dev + nix build --system aarch64-linux .#otb From d2ae7a2f699374c282176bbd38fd8dc431efd311 Mon Sep 17 00:00:00 2001 From: daspk Date: Tue, 27 Aug 2024 23:17:05 +0700 Subject: [PATCH 3/5] [FIX] Fix build steps in aarch64 workflow * Move the 'Build system' task to correctly follow the cache setup. --- .github/workflows/aarch64.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/aarch64.yml b/.github/workflows/aarch64.yml index 129762d..d4ba0ee 100644 --- a/.github/workflows/aarch64.yml +++ b/.github/workflows/aarch64.yml @@ -77,8 +77,8 @@ jobs: http-connections = 128 max-substitution-jobs = 128 extra-platforms = aarch64-linux - - name: Build system - uses: DeterminateSystems/magic-nix-cache-action@main - - run: | + - name: Build system + run: | nix build --system aarch64-linux .#otb-dev nix build --system aarch64-linux .#otb From 5591dbe587f0a219fa961dcbae524ad2cbf437ca Mon Sep 17 00:00:00 2001 From: daspk Date: Wed, 28 Aug 2024 07:56:50 +0700 Subject: [PATCH 4/5] [CI] Add permissions to CI workflows and update build steps * Updated the CI workflows to include `contents: read` and `id-token: write` permissions. Also adjusted build commands to focus on `otb-dev` target and included the use of `magic-nix-cache-action`. --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b279816..fd4cbeb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,9 @@ on: jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + id-token: write strategy: fail-fast: false matrix: @@ -28,7 +31,7 @@ jobs: http-connections = 128 max-substitution-jobs = 128 extra-platforms = aarch64-linux + - uses: DeterminateSystems/magic-nix-cache-action@main - name: Build system run: | nix build --system ${{ matrix.machine.platform }} .#otb-dev - nix build --system ${{ matrix.machine.platform }} .#otb From dddf3dade90c15a74e9f81743651cba6bd10475b Mon Sep 17 00:00:00 2001 From: daspk Date: Wed, 28 Aug 2024 08:10:53 +0700 Subject: [PATCH 5/5] [CI] Remove deprecated aarch64 GitHub Actions workflow * The aarch64 GitHub Actions workflow file (.github/workflows/aarch64.yml) was deleted. * This action is no more needed as the ci.yml works fine with Nix-Magic-Cache * Rather than building 2 derivation i.e. otb-dev (all modules) and otb (minimal modules) which takes a lot of time for ARM64 build and gets timed out so we build only one derivation i.e otb-dev which contains all the modules. --- .github/workflows/aarch64.yml | 84 ----------------------------------- 1 file changed, 84 deletions(-) delete mode 100644 .github/workflows/aarch64.yml diff --git a/.github/workflows/aarch64.yml b/.github/workflows/aarch64.yml deleted file mode 100644 index d4ba0ee..0000000 --- a/.github/workflows/aarch64.yml +++ /dev/null @@ -1,84 +0,0 @@ -# https://github.com/pguyot/arm-runner-action/blob/main/.github/workflows/test-archlinux.yml -name: OTB Arch64 - -on: - pull_request: - push: - branches: [main] - workflow_dispatch: - -jobs: - # ArchLinux does not come with an image combining root and boot partitions - # This shows how to proceed and could be combined with cache. - test_archlinux: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Prepare ArchLinux image - run: | - # https://archlinuxarm.org/platforms/armv7/broadcom/raspberry-pi-2 - # Install dependency - sudo apt-get -y install libarchive-tools - # Create a 1.5 GB image - dd if=/dev/zero of=$RUNNER_TEMP/archlinux.img bs=1M count=1536 - # 2. At the fdisk prompt, delete old partitions and create a new one: - # using the sed comment trick of https://superuser.com/a/984637 - sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | fdisk $RUNNER_TEMP/archlinux.img - o # clear the in memory partition table - n # new partition - p # primary partition - 1 # partition number 1 - # default - start at beginning of disk - +200M # 200 MB boot partition - t # type - c # W95 FAT32 (LBA) - n # new partition - p # primary partition - 2 # partion number 2 - # default, start immediately after preceding partition - # default, extend partition to end of disk - w # write the partition table - q # and we're done - EOF - # create loopdev - loopdev=$(sudo losetup --find --show --partscan $RUNNER_TEMP/archlinux.img) - # 3. Create and mount the FAT filesystem: - sudo mkfs.vfat ${loopdev}p1 - mkdir boot - sudo mount ${loopdev}p1 boot - # 4. Create and mount the ext4 filesystem: - sudo mkfs.ext4 ${loopdev}p2 - mkdir root - sudo mount ${loopdev}p2 root - # 5. Download and extract the root filesystem: - wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-armv7-latest.tar.gz - sudo -u root bsdtar -xpf ArchLinuxARM-rpi-armv7-latest.tar.gz -C root - sync - # 6. Move boot files to the first partition: - sudo mv root/boot/* boot - # 7. Unmount the two partitions: - sudo umount boot root - # Cleanup - rm ArchLinuxARM-rpi-armv7-latest.tar.gz - rmdir boot - rmdir root - - uses: pguyot/arm-runner-action@HEAD - with: - base_image: file://$RUNNER_TEMP/archlinux.img - cpu: cortex-a53 - commands: | - # 10. Initialize the pacman keyring and populate the Arch Linux ARM package signing keys: - pacman-key --init - pacman-key --populate archlinuxarm - - uses: DeterminateSystems/nix-installer-action@main - with: - extra-conf: | - fallback = true - http-connections = 128 - max-substitution-jobs = 128 - extra-platforms = aarch64-linux - - uses: DeterminateSystems/magic-nix-cache-action@main - - name: Build system - run: | - nix build --system aarch64-linux .#otb-dev - nix build --system aarch64-linux .#otb