Merge pull request #982 from PolynomialDivision/23-05-ci-backports

[23.05] CI - GitHub actions sync with the latest changes from OpenWrt packages repository
This commit is contained in:
Josef Schlehofer 2023-07-05 20:03:49 +02:00 committed by GitHub
commit 1b720129f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 172 additions and 29 deletions

View File

@ -0,0 +1,91 @@
name: Check autorelease deprecation
on:
pull_request_target:
types: [opened, synchronize, converted_to_draft, ready_for_review, edited]
jobs:
build:
name: Check autorelease deprecation
runs-on: ubuntu-latest
strategy:
fail-fast: false
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Determine branch name
run: |
BRANCH="${GITHUB_BASE_REF#refs/heads/}"
echo "Building for $BRANCH"
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Determine changed packages
run: |
RET=0
# only detect packages with changes
PKG_ROOTS=$(find . -name Makefile | \
grep -v ".*/src/Makefile" | \
sed -e 's@./\(.*\)/Makefile@\1/@')
CHANGES=$(git diff --diff-filter=d --name-only origin/$BRANCH...)
for ROOT in $PKG_ROOTS; do
for CHANGE in $CHANGES; do
if [[ "$CHANGE" == "$ROOT"* ]]; then
if grep -q '$(AUTORELEASE)' "$ROOT/Makefile"; then
CONTAINS_AUTORELEASE+="$ROOT"
fi
break
fi
done
done
if [ -n "$CONTAINS_AUTORELEASE" ]; then
RET=1
cat > "$GITHUB_WORKSPACE/pr_comment.md" << EOF
Please do no longer set *PKG_RELEASE* to *AUTORELEASE* as the
feature is deprecated. Please use an integer instead. Below is a
list of affected packages including correct *PKG_RELEASE*:
EOF
fi
for ROOT in $CONTAINS_AUTORELEASE; do
echo -n " - ${ROOT}Makefile: PKG_RELEASE:=" >> "$GITHUB_WORKSPACE/pr_comment.md"
last_bump="$(git log --pretty=format:'%h %s' "$ROOT" |
grep --max-count=1 -e ': [uU]pdate to ' -e ': [bB]ump to ' |
cut -f 1 -d ' ')"
if [ -n "$last_bump" ]; then
echo -n $(($(git rev-list --count "$last_bump..HEAD" "$ROOT") + 2)) >> "$GITHUB_WORKSPACE/pr_comment.md"
else
echo -n $(($(git rev-list --count HEAD "$ROOT") + 2)) >> "$GITHUB_WORKSPACE/pr_comment.md"
fi
echo >> "$GITHUB_WORKSPACE/pr_comment.md"
done
exit $RET
- name: Find Comment
uses: peter-evans/find-comment@v2
if: ${{ failure() }}
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
if: ${{ failure() }}
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-file: 'pr_comment.md'
edit-mode: replace

View File

@ -2,7 +2,12 @@
# not enabling `errtrace` and `pipefail` since those are bash specific
set -o errexit # failing commands causes script to fail
set -o nounset # undefined variables causes script to fail
set -o nounset # undefined variables causes script to fail
echo "src/gz packages_ci file:///ci" >> /etc/opkg/distfeeds.conf
FINGERPRINT="$(usign -F -p /ci/packages_ci.pub)"
cp /ci/packages_ci.pub "/etc/opkg/keys/$FINGERPRINT"
mkdir -p /var/lock/
@ -11,7 +16,7 @@ opkg update
[ -n "${CI_HELPER:=''}" ] || CI_HELPER="/ci/.github/workflows/ci_helpers.sh"
for PKG in /ci/*.ipk; do
tar -xzOf "$PKG" ./control.tar.gz | tar xzf - ./control
tar -xzOf "$PKG" ./control.tar.gz | tar xzf - ./control
# package name including variant
PKG_NAME=$(sed -ne 's#^Package: \(.*\)$#\1#p' ./control)
# package version without release
@ -21,10 +26,24 @@ for PKG in /ci/*.ipk; do
echo "Testing package $PKG_NAME in version $PKG_VERSION from $PKG_SOURCE"
opkg install "$PKG"
export PKG_NAME PKG_VERSION CI_HELPER
PRE_TEST_SCRIPT=$(find /ci/ -name "$PKG_SOURCE" -type d)/pre-test.sh
if [ -f "$PRE_TEST_SCRIPT" ]; then
echo "Use package specific pre-test.sh"
if sh "$PRE_TEST_SCRIPT" "$PKG_NAME" "$PKG_VERSION"; then
echo "Pre-test successful"
else
echo "Pre-test failed"
exit 1
fi
else
echo "No pre-test.sh script available"
fi
opkg install "$PKG"
TEST_SCRIPT=$(find /ci/ -name "$PKG_SOURCE" -type d)/test.sh
if [ -f "$TEST_SCRIPT" ]; then
@ -39,5 +58,5 @@ for PKG in /ci/*.ipk; do
echo "No test.sh script available"
fi
opkg remove "$PKG_NAME" --force-removal-of-dependent-packages --force-remove
opkg remove "$PKG_NAME" --force-removal-of-dependent-packages --force-remove --autoremove || true
done

View File

@ -3,6 +3,10 @@ name: Test Build
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build:
name: Test ${{ matrix.arch }}
@ -11,37 +15,37 @@ jobs:
fail-fast: false
matrix:
include:
- arch: arc_archs
target: archs38-generic
runtime_test: false
- arch: aarch64_generic
target: armsr-armv8
runtime_test: true
- arch: arm_cortex-a15_neon-vfpv4
target: armsr-armv7
runtime_test: true
- arch: arm_cortex-a9_vfpv3-d16
target: mvebu-cortexa9
runtime_test: false
- arch: i386_pentium-mmx
target: x86-geode
runtime_test: true
- arch: mips_24kc
target: ath79-generic
runtime_test: false
runtime_test: true
- arch: powerpc_464fp
target: apm821xx-nand
runtime_test: false
- arch: powerpc_8540
- arch: powerpc_8548
target: mpc85xx-p1010
runtime_test: false
- arch: aarch64_cortex-a53
target: mvebu-cortexa53
runtime_test: true
- arch: arm_cortex-a15_neon-vfpv4
target: armvirt-32
runtime_test: true
- arch: i386_pentium-mmx
target: x86-geode
runtime_test: true
- arch: riscv64_riscv64
target: sifiveu-generic
runtime_test: false
- arch: x86_64
target: x86-64
@ -82,20 +86,36 @@ jobs:
echo "Building $PACKAGES"
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
- name: Generate build keys
run: |
sudo apt-get update
sudo apt-get install -y signify-openbsd
signify-openbsd -G -n -c 'DO NOT USE - OpenWrt packages feed CI' -p packages_ci.pub -s packages_ci.sec
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "KEY_BUILD<<$EOF" >> $GITHUB_ENV
cat packages_ci.sec >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Build
uses: openwrt/gh-action-sdk@v5
env:
ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
FEEDNAME: packages_ci
INDEX: 1
KEY_BUILD: ${{ env.KEY_BUILD }}
- name: Move created packages to project dir
run: cp bin/packages/${{ matrix.arch }}/packages_ci/*.ipk . || true
run: cp bin/packages/${{ matrix.arch }}/packages_ci/* . || true
- name: Store packages
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.arch}}-packages
path: "*.ipk"
name: ${{env.ARCHIVE_NAME}}-packages
path: |
Packages
Packages.*
*.ipk
PKG-INFO
- name: Store logs
uses: actions/upload-artifact@v3
@ -106,19 +126,32 @@ jobs:
- name: Remove logs
run: sudo rm -rf logs/ || true
- name: Register QEMU
if: ${{ matrix.runtime_test }}
- name: Check if any packages were built
run: |
sudo docker run --rm --privileged aptman/qus -s -- -p
if [ -n "$(find . -maxdepth 1 -type f -name '*.ipk' -print -quit)" ]; then
echo "Found *.ipk files"
HAVE_IPKS=true
else
echo "No *.ipk files found"
HAVE_IPKS=false
fi
echo "HAVE_IPKS=$HAVE_IPKS" >> $GITHUB_ENV
- name: Register QEMU
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static binfmt-support
sudo update-binfmts --import
- name: Build Docker container
if: ${{ matrix.runtime_test }}
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
run: |
docker build -t test-container --build-arg ARCH .github/workflows/
env:
ARCH: ${{ matrix.arch }}-${{ env.BRANCH }}
- name: Test via Docker container
if: ${{ matrix.runtime_test }}
if: ${{ matrix.runtime_test && fromJSON(env.HAVE_IPKS) }}
run: |
docker run --rm -v $GITHUB_WORKSPACE:/ci test-container