From 2ce9330e7d571e31ca5f66c170a8b8cca4f1e1bf Mon Sep 17 00:00:00 2001 From: Igor Wodiany Date: Tue, 28 May 2024 12:50:19 +0100 Subject: [PATCH 1/4] Add support for GitHub Actions --- .github/workflows/main.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..b26dd716 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,22 @@ +name: build-and-run-mambo +run-name: Running GitHub Action +on: [push] +jobs: + build-and-run-mambo: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + path: mambo + submodules: true + - run: sudo apt-get update + # - run: sudo apt-get upgrade + - run: sudo apt-get install -y debootstrap + - run: sudo apt-get install -y qemu-user-static + - run: mkdir -p /tmp/chroot/ + - run: sudo debootstrap --arch=riscv64 --foreign focal /tmp/chroot/riscv64 http://ports.ubuntu.com/ubuntu-ports + - run: sudo cp /usr/bin/qemu-riscv64-static /tmp/chroot/riscv64/usr/bin/ + - run: sudo chroot /tmp/chroot/riscv64/ /usr/bin/qemu-riscv64-static /bin/bash -c '/debootstrap/debootstrap --second-stage' + - run: sudo cp -r $GITHUB_WORKSPACE/mambo /tmp/chroot/riscv64/root + - run: sudo chroot /tmp/chroot/riscv64/ /usr/bin/qemu-riscv64-static /bin/bash -c 'sudo apt-get update; sudo apt-get upgrade -y; sudo apt-get -y install build-essential libelf-dev ruby; cd /root/mambo/; make' + - run: sudo chroot /tmp/chroot/riscv64/ /usr/bin/qemu-riscv64-static /bin/bash -c '/root/mambo/dbm /bin/ls' From cefddaadf1dd03bc8a689252a4a02ab4feed5e43 Mon Sep 17 00:00:00 2001 From: Igor Wodiany Date: Tue, 28 May 2024 18:13:00 +0100 Subject: [PATCH 2/4] Add configuration matrix for GitHub Actions --- .github/workflows/main.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b26dd716..22850821 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,6 +3,11 @@ run-name: Running GitHub Action on: [push] jobs: build-and-run-mambo: + strategy: + matrix: + os: [focal] + arch: [ {os: arm64, qemu: aarch64}, {os: riscv64, qemu: riscv64}, {os: armhf, qemu: arm} ] + fail-fast: false runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -10,13 +15,13 @@ jobs: path: mambo submodules: true - run: sudo apt-get update - # - run: sudo apt-get upgrade + - run: sudo apt-get upgrade - run: sudo apt-get install -y debootstrap - run: sudo apt-get install -y qemu-user-static - run: mkdir -p /tmp/chroot/ - - run: sudo debootstrap --arch=riscv64 --foreign focal /tmp/chroot/riscv64 http://ports.ubuntu.com/ubuntu-ports - - run: sudo cp /usr/bin/qemu-riscv64-static /tmp/chroot/riscv64/usr/bin/ - - run: sudo chroot /tmp/chroot/riscv64/ /usr/bin/qemu-riscv64-static /bin/bash -c '/debootstrap/debootstrap --second-stage' - - run: sudo cp -r $GITHUB_WORKSPACE/mambo /tmp/chroot/riscv64/root - - run: sudo chroot /tmp/chroot/riscv64/ /usr/bin/qemu-riscv64-static /bin/bash -c 'sudo apt-get update; sudo apt-get upgrade -y; sudo apt-get -y install build-essential libelf-dev ruby; cd /root/mambo/; make' - - run: sudo chroot /tmp/chroot/riscv64/ /usr/bin/qemu-riscv64-static /bin/bash -c '/root/mambo/dbm /bin/ls' + - run: sudo debootstrap --arch=${{ matrix.arch.os }} --foreign ${{ matrix.os }} /tmp/chroot/${{ matrix.arch.os }} http://ports.ubuntu.com/ubuntu-ports + - run: sudo cp /usr/bin/qemu-${{ matrix.arch.qemu }}-static /tmp/chroot/${{ matrix.arch.os }}/usr/bin/ + - run: sudo chroot /tmp/chroot/${{ matrix.arch.os }}/ /usr/bin/qemu-${{ matrix.arch.qemu }}-static /bin/bash -c '/debootstrap/debootstrap --second-stage' + - run: sudo cp -r $GITHUB_WORKSPACE/mambo /tmp/chroot/${{ matrix.arch.os }}/root + - run: sudo chroot /tmp/chroot/${{ matrix.arch.os }}/ /usr/bin/qemu-${{ matrix.arch.qemu }}-static /bin/bash -c 'sudo apt-get update; sudo apt-get upgrade -y; sudo apt-get -y install build-essential libelf-dev ruby; cd /root/mambo/; make' + - run: sudo chroot /tmp/chroot/${{ matrix.arch.os }}/ /usr/bin/qemu-${{ matrix.arch.qemu }}-static /bin/bash -c '/root/mambo/dbm /bin/ls' From f0d1d51ec83aff91812af3e7a69e500963d922ce Mon Sep 17 00:00:00 2001 From: Igor Wodiany Date: Wed, 29 May 2024 11:31:51 +0100 Subject: [PATCH 3/4] Add triggers for GitHub Actions --- .github/workflows/main.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 22850821..ea7a9f51 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,10 @@ name: build-and-run-mambo -run-name: Running GitHub Action -on: [push] +run-name: Building and running MAMBO triggered by ${{ github.actor }} on ${{ github.ref }} +on: + push: + branches: [master] + pull_request: + types: [opened, synchronize, reopened] jobs: build-and-run-mambo: strategy: @@ -8,7 +12,7 @@ jobs: os: [focal] arch: [ {os: arm64, qemu: aarch64}, {os: riscv64, qemu: riscv64}, {os: armhf, qemu: arm} ] fail-fast: false - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 with: From e90e4bce00e2bbfa8e6b5676fcf7fd52d999177c Mon Sep 17 00:00:00 2001 From: Igor Wodiany Date: Thu, 30 May 2024 10:11:26 +0100 Subject: [PATCH 4/4] Cache sysroot in GitHub Actions --- .github/workflows/main.yml | 41 ++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ea7a9f51..07c562f0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,14 +18,33 @@ jobs: with: path: mambo submodules: true - - run: sudo apt-get update - - run: sudo apt-get upgrade - - run: sudo apt-get install -y debootstrap - - run: sudo apt-get install -y qemu-user-static - - run: mkdir -p /tmp/chroot/ - - run: sudo debootstrap --arch=${{ matrix.arch.os }} --foreign ${{ matrix.os }} /tmp/chroot/${{ matrix.arch.os }} http://ports.ubuntu.com/ubuntu-ports - - run: sudo cp /usr/bin/qemu-${{ matrix.arch.qemu }}-static /tmp/chroot/${{ matrix.arch.os }}/usr/bin/ - - run: sudo chroot /tmp/chroot/${{ matrix.arch.os }}/ /usr/bin/qemu-${{ matrix.arch.qemu }}-static /bin/bash -c '/debootstrap/debootstrap --second-stage' - - run: sudo cp -r $GITHUB_WORKSPACE/mambo /tmp/chroot/${{ matrix.arch.os }}/root - - run: sudo chroot /tmp/chroot/${{ matrix.arch.os }}/ /usr/bin/qemu-${{ matrix.arch.qemu }}-static /bin/bash -c 'sudo apt-get update; sudo apt-get upgrade -y; sudo apt-get -y install build-essential libelf-dev ruby; cd /root/mambo/; make' - - run: sudo chroot /tmp/chroot/${{ matrix.arch.os }}/ /usr/bin/qemu-${{ matrix.arch.qemu }}-static /bin/bash -c '/root/mambo/dbm /bin/ls' + - name: Set up host environment + run: | + sudo apt-get update + sudo apt-get upgrade + sudo apt-get install -y debootstrap + sudo apt-get install -y qemu-user-static + sudo mkdir -p /tmp/chroot/ + sudo chown root /bin/tar + sudo chmod u+s /bin/tar + - uses: actions/cache/restore@v4 + id: cache + with: + path: /tmp/chroot/${{ matrix.arch.os }} + key: ${{ matrix.os }}.${{ matrix.arch.os }} + - name: Install and configure sysroot + if: steps.cache.outputs.cache-hit != 'true' + run: | + sudo debootstrap --arch=${{ matrix.arch.os }} --foreign ${{ matrix.os }} /tmp/chroot/${{ matrix.arch.os }} http://ports.ubuntu.com/ubuntu-ports + sudo cp /usr/bin/qemu-${{ matrix.arch.qemu }}-static /tmp/chroot/${{ matrix.arch.os }}/usr/bin/ + sudo chroot /tmp/chroot/${{ matrix.arch.os }}/ /usr/bin/qemu-${{ matrix.arch.qemu }}-static /bin/bash -c '/debootstrap/debootstrap --second-stage' + - uses: actions/cache/save@v4 + if: steps.cache.outputs.cache-hit != 'true' + with: + path: /tmp/chroot/${{ matrix.arch.os }} + key: ${{ matrix.os }}.${{ matrix.arch.os }} + - name: Build and run MAMBO inside chroot + run: | + sudo cp -r $GITHUB_WORKSPACE/mambo /tmp/chroot/${{ matrix.arch.os }}/root + sudo chroot /tmp/chroot/${{ matrix.arch.os }}/ /usr/bin/qemu-${{ matrix.arch.qemu }}-static /bin/bash -c 'sudo apt-get update; sudo apt-get upgrade -y; sudo apt-get -y install build-essential libelf-dev ruby; cd /root/mambo/; make' + sudo chroot /tmp/chroot/${{ matrix.arch.os }}/ /usr/bin/qemu-${{ matrix.arch.qemu }}-static /bin/bash -c '/root/mambo/dbm /bin/ls'