ci: set correct arch for rootfs tests
[feed/routing.git] / .github / workflows / multi-arch-test-build.yml
1 name: Test Build
2
3 on:
4 pull_request:
5
6 concurrency:
7 group: ${{ github.workflow }}-${{ github.ref }}
8 cancel-in-progress: ${{ github.event_name == 'pull_request' }}
9
10 jobs:
11 build:
12 name: Test ${{ matrix.arch }}
13 runs-on: ubuntu-latest
14 strategy:
15 fail-fast: false
16 matrix:
17 include:
18 - arch: aarch64_generic
19 target: armsr-armv8
20 runtime_test: true
21
22 - arch: arm_cortex-a15_neon-vfpv4
23 target: armsr-armv7
24 runtime_test: true
25
26 - arch: arm_cortex-a9_vfpv3-d16
27 target: mvebu-cortexa9
28 runtime_test: false
29
30 - arch: i386_pentium-mmx
31 target: x86-geode
32 runtime_test: true
33
34 - arch: mips_24kc
35 target: ath79-generic
36 runtime_test: true
37
38 - arch: powerpc_464fp
39 target: apm821xx-nand
40 runtime_test: false
41
42 - arch: powerpc_8548
43 target: mpc85xx-p1010
44 runtime_test: false
45
46 - arch: riscv64_riscv64
47 target: sifiveu-generic
48 runtime_test: false
49
50 - arch: x86_64
51 target: x86-64
52 runtime_test: true
53
54 steps:
55 - uses: actions/checkout@v3
56 with:
57 fetch-depth: 0
58
59 - name: Determine branch name
60 run: |
61 BRANCH="${GITHUB_BASE_REF#refs/heads/}"
62 echo "Building for $BRANCH"
63 echo "BRANCH=$BRANCH" >> $GITHUB_ENV
64
65 - name: Determine changed packages
66 run: |
67 # only detect packages with changes
68 PKG_ROOTS=$(find . -name Makefile | \
69 grep -v ".*/src/Makefile" | \
70 sed -e 's@./\(.*\)/Makefile@\1/@')
71 CHANGES=$(git diff --diff-filter=d --name-only origin/$BRANCH)
72
73 for ROOT in $PKG_ROOTS; do
74 for CHANGE in $CHANGES; do
75 if [[ "$CHANGE" == "$ROOT"* ]]; then
76 PACKAGES+=$(echo "$ROOT" | sed -e 's@\(.*\)/@\1 @')
77 break
78 fi
79 done
80 done
81
82 # fallback to test packages if nothing explicitly changes this is
83 # should run if other mechanics in packages.git changed
84 PACKAGES="${PACKAGES:-bird2 cjdns olsrd}"
85
86 echo "Building $PACKAGES"
87 echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
88
89 - name: Generate build keys
90 run: |
91 sudo apt-get update
92 sudo apt-get install -y signify-openbsd
93 signify-openbsd -G -n -c 'DO NOT USE - OpenWrt packages feed CI' -p packages_ci.pub -s packages_ci.sec
94 EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
95 echo "KEY_BUILD<<$EOF" >> $GITHUB_ENV
96 cat packages_ci.sec >> $GITHUB_ENV
97 echo "$EOF" >> $GITHUB_ENV
98
99 - name: Build
100 uses: openwrt/gh-action-sdk@v5
101 env:
102 ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
103 FEEDNAME: packages_ci
104 INDEX: 1
105 KEY_BUILD: ${{ env.KEY_BUILD }}
106
107 - name: Move created packages to project dir
108 run: cp bin/packages/${{ matrix.arch }}/packages_ci/* . || true
109
110 - name: Store packages
111 uses: actions/upload-artifact@v3
112 with:
113 name: ${{env.ARCHIVE_NAME}}-packages
114 path: |
115 Packages
116 Packages.*
117 *.ipk
118 PKG-INFO
119
120 - name: Store logs
121 uses: actions/upload-artifact@v3
122 with:
123 name: ${{ matrix.arch}}-logs
124 path: logs/
125
126 - name: Remove logs
127 run: sudo rm -rf logs/ || true
128
129 - name: Check if any packages were built
130 run: |
131 if [ -n "$(find . -maxdepth 1 -type f -name '*.ipk' -print -quit)" ]; then
132 echo "Found *.ipk files"
133 HAVE_IPKS=true
134 else
135 echo "No *.ipk files found"
136 HAVE_IPKS=false
137 fi
138 echo "HAVE_IPKS=$HAVE_IPKS" >> $GITHUB_ENV
139
140 - name: Register QEMU
141 if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
142 run: |
143 sudo apt-get update
144 sudo apt-get install -y qemu-user-static binfmt-support
145 sudo update-binfmts --import
146
147 - name: Build Docker container
148 if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
149 run: |
150 docker build --platform linux/${{ matrix.arch }} -t test-container --build-arg ARCH .github/workflows/
151 env:
152 ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
153
154 - name: Test via Docker container
155 if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
156 run: |
157 docker run --platform linux/${{ matrix.arch }} --rm -v $GITHUB_WORKSPACE:/ci test-container