CI: Use GitHub actions for snapshot builds
authorPaul Spooren <mail@aparcar.org>
Tue, 31 Aug 2021 21:23:05 +0000 (11:23 -1000)
committerPaul Spooren <mail@aparcar.org>
Tue, 29 Mar 2022 12:41:53 +0000 (13:41 +0100)
This commits adds a GitHub actions CI workflow file which builds all
targets every week. To do so it imitates most steps of the
buildbot.git[0] and uploads created binaries and kmods to a storage
server.

[0]: https://git.openwrt.org/?p=buildbot.git

Signed-off-by: Paul Spooren <mail@aparcar.org>
.ci/default.config [new file with mode: 0644]
.ci/gcc10.config [new file with mode: 0644]
.ci/nls.config [new file with mode: 0644]
.ci/selinux.config [new file with mode: 0644]
.github/workflows/build-openwrt.yml [new file with mode: 0644]
package/system/procd/files/procd.sh

diff --git a/.ci/default.config b/.ci/default.config
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/.ci/gcc10.config b/.ci/gcc10.config
new file mode 100644 (file)
index 0000000..4142be8
--- /dev/null
@@ -0,0 +1,3 @@
+CONFIG_GCC_USE_VERSION_10=y
+CONFIG_DEVEL=y
+CONFIG_TOOLCHAINOPTS=y
diff --git a/.ci/nls.config b/.ci/nls.config
new file mode 100644 (file)
index 0000000..adbc4ca
--- /dev/null
@@ -0,0 +1 @@
+CONFIG_BUILD_NLS=y
diff --git a/.ci/selinux.config b/.ci/selinux.config
new file mode 100644 (file)
index 0000000..8520705
--- /dev/null
@@ -0,0 +1,2 @@
+CONFIG_KERNEL_SECURITY_SELINUX_DEVELOP=y
+CONFIG_SELINUX=y
diff --git a/.github/workflows/build-openwrt.yml b/.github/workflows/build-openwrt.yml
new file mode 100644 (file)
index 0000000..b941323
--- /dev/null
@@ -0,0 +1,163 @@
+name: Build OpenWrt snapshot
+
+on:
+  schedule:
+    - cron: "0 4 * * 0"
+  workflow_dispatch:
+
+jobs:
+  determine_targets:
+    name: Find available targets
+    runs-on: ubuntu-latest
+    outputs:
+      targets: ${{ steps.find_targets.outputs.targets }}
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Find targets
+        id: find_targets
+        run: |
+          TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null | awk '{ print $1 }')"
+          JSON='{"config": ["selinux"], "targets":['
+          FIRST=1
+          for TARGET in $TARGETS; do
+            [[ $FIRST -ne 1 ]] && JSON="$JSON"','
+            JSON="$JSON"'"'"${TARGET}"'"'
+            FIRST=0
+          done
+          JSON="$JSON"']}'
+
+          echo -e "\n---- targets ----\n"
+          echo "$JSON"
+          echo -e "\n---- targets ----\n"
+
+          echo "::set-output name=targets::$JSON"
+
+  build:
+    name: Build ${{ matrix.targets }}
+    needs: determine_targets
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: False
+      matrix: ${{fromJson(needs.determine_targets.outputs.targets)}}
+
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+        with:
+          repository: "openwrt/openwrt"
+          fetch-depth: 0
+
+      - name: Cache sources
+        uses: davidsbond/cache@master
+        with:
+          path: dl/
+          key: Sources
+          update: True
+
+      - name: Initialization environment
+        env:
+          DEBIAN_FRONTEND: noninteractive
+        run: |
+          sudo apt-get -y install libncurses-dev qemu-utils
+          TARGET=$(echo ${{ matrix.targets }} | cut -d "/" -f 1)
+          SUBTARGET=$(echo ${{ matrix.targets }} | cut -d "/" -f 2)
+          echo "TARGET=$TARGET" >> "$GITHUB_ENV"                                          
+          echo "SUBTARGET=$SUBTARGET" >> "$GITHUB_ENV"
+
+      - name: Update & Install feeds
+        run: |
+          ./scripts/feeds update -a
+          ./scripts/feeds install -a
+
+      - name: Set configuration
+        run: |
+          curl "https://downloads.openwrt.org/snapshots/targets/${{ matrix.targets }}/config.buildinfo" > .config
+          curl "https://raw.githubusercontent.com/aparcar/openwrt/staging/.ci/${{ matrix.config }}.config" >> .config
+                                                                                          
+          echo -e "\n---- config input ----\n"                                            
+          cat .config                                                                     
+          echo -e "\n---- config input ----\n"                                            
+                                                                                          
+          make defconfig                                                                  
+                                                                                          
+          echo -e "\n---- config post-defconfig ----\n"                                   
+          cat .config                                                                     
+          echo -e "\n---- config post-defconfig ----\n"
+
+      - name: Download package
+        run: |
+          make download -j$(nproc)
+
+      - name: Build tools
+        run: |
+          make tools/install -j$(nproc) || \
+            make tools/install V=s
+
+      - name: Build toolchain
+        run: |
+          make toolchain/install -j$(nproc) || \
+            make toolchain/install V=s
+
+      - name: Build target
+        run: |
+          make target/compile -j$(nproc) IGNORE_ERRORS='n m' || \
+            make target/compile IGNORE_ERRORS='n m' V=s
+
+      - name: Build packages
+        run: |
+          make package/compile -j$(nproc) IGNORE_ERRORS='n m' || \
+            make package/compile IGNORE_ERRORS='n m' V=s
+
+          make package/install -j$(nproc) || \
+            make package/install V=s
+
+          make package/index CONFIG_SIGNED_PACKAGES= V=s
+
+      - name: Add kmods feed
+        run: |
+          TOPDIR=$(pwd)
+          export TOPDIR
+          STAGE_ROOT="$(make --no-print-directory val.STAGING_DIR_ROOT)"
+          KERNEL_VERSION="$(make --no-print-directory -C target/linux \
+              val.LINUX_VERSION val.LINUX_RELEASE val.LINUX_VERMAGIC | \
+              tr '\n' '-' | head -c -1)"
+
+          mkdir -p files/etc/opkg/
+          sed -e 's#^\(src/gz .*\)_core \(.*\)/packages$#&\n\1_kmods \2/kmods/'"${KERNEL_VERSION}#" \
+            "${STAGE_ROOT}/etc/opkg/distfeeds.conf" > files/etc/opkg/distfeeds.conf
+
+          echo -e "\n---- distfeeds.conf ----\n"
+          cat files/etc/opkg/distfeeds.conf
+          echo -e "\n---- distfeeds.conf ----\n"
+
+      - name: Build firmware
+        run: |
+          make target/install -j$(nproc) || \
+            make target/install V=s
+
+      - name: Buildinfo
+        run: |
+          make buildinfo V=s
+
+      - name: JSON overview
+        run: |
+          make json_overview_image_info V=s
+
+      - name: Checksum
+        run: |
+          make checksum V=s
+
+      - name: Upload kmods to S3
+        uses: jakejarvis/s3-sync-action@master
+        with:
+          args: --acl public-read --follow-symlinks --delete
+        env:
+          AWS_S3_BUCKET: openwrt-ci
+          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
+          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+          AWS_S3_ENDPOINT: https://s3.asu.aparcar.org
+          SOURCE_DIR: bin/targets/${{ matrix.targets }}/
+          DEST_DIR: ${{ matrix.config }}/targtes/${{ matrix.targets }}/
index 5148b2f03c3511ee5c3de1d5d631ecd5a26c730a..6e4c6f07d94231c7a03a216bf22ea4f95d091909 100644 (file)
@@ -261,7 +261,7 @@ _procd_set_param() {
                        json_add_int "$type" $(kill -l "$1")
                ;;
                pidfile|user|group|seccomp|capabilities|facility|\
-               extroot|overlaydir|tmpoverlaysize)
+               extroot|overlaydir|tmpoverlaysize|context)
                        json_add_string "$type" "$1"
                ;;
                stdout|stderr|no_new_privs)