Skip to content

Commit

Permalink
CI: migrate each workflow to use reusable workflow from dedicated repo
Browse files Browse the repository at this point in the history
Migrate each workflow to use reusable workflow from dedicated repo to
skip pushing CI related commits to openwrt and better track versioning
of CI workflow.

Signed-off-by: Christian Marangi <[email protected]>
  • Loading branch information
Ansuel committed Jun 25, 2023
1 parent acd9981 commit 38cc091
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 670 deletions.
51 changes: 1 addition & 50 deletions .github/workflows/coverity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,53 +16,4 @@ jobs:
contents: read
packages: read
actions: write
uses: ./.github/workflows/build.yml
with:
container_name: toolchain
target: x86
subtarget: 64
build_full: true
include_feeds: true
use_ccache_cache: false
coverity_compiler_template_list: >-
x86_64-openwrt-linux-gcc
x86_64-openwrt-linux-musl-gcc
# qosify fails to build with cov-build
coverity_check_packages: >-
cgi-io
dnsmasq
dropbear
firewall
fstools
fwtool
iwinfo
jsonfilter
libnl-tiny
libubox
mtd
netifd
odhcp6c
odhcpd
opkg
procd
relayd
rpcd
swconfig
ubox
ubus
ucert
uci
uclient
ucode
ugps
uhttpd
umbim
umdns
unetd
uqmi
urngd
usbmode
usign
usteer
ustp
ustream-ssl
uses: openwrt/actions-shared-workflows/.github/workflows/coverity.yml@main
121 changes: 3 additions & 118 deletions .github/workflows/kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,128 +28,13 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
determine_targets:
name: Set targets
runs-on: ubuntu-latest
outputs:
targets_subtargets: ${{ steps.find_targets.outputs.targets_subtargets }}
targets: ${{ steps.find_targets.outputs.targets }}

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35

- name: Set targets
id: find_targets
run: |
ALL_TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null)"
CHANGED_FILES="$(echo ${{ steps.changed-files.outputs.all_changed_files }} | tr ' ' '\n')"
TARGETS_SUBTARGETS="$(echo "$ALL_TARGETS" | sort -u -t '/' -k1 | awk '{ print $1 }')"
TARGETS="$(echo "$ALL_TARGETS" | sort -u -t '/' -k1,1 | awk '{ print $1 }')"
# On testing non-specific target, skip testing each subtarget if we are testing pr
if [ ${{ github.event_name }} != 'push' ]; then
if echo "$CHANGED_FILES" | grep -v -q target/linux ||
echo "$CHANGED_FILES" | grep -q target/linux/generic; then
TARGETS_SUBTARGETS=$TARGETS
fi
fi
JSON_TARGETS_SUBTARGETS='['
FIRST=1
for TARGET in $TARGETS_SUBTARGETS; do
if echo "$CHANGED_FILES" | grep -v -q target/linux ||
echo "$CHANGED_FILES" | grep -q target/linux/generic ||
echo "$CHANGED_FILES" | grep -q $(echo $TARGET | cut -d "/" -f 1); then
TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}'
[[ $FIRST -ne 1 ]] && JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"','
JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS""$TUPLE"
FIRST=0
fi
done
JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"']'
JSON_TARGETS='['
FIRST=1
for TARGET in $TARGETS; do
if echo "$CHANGED_FILES" | grep -v -q target/linux ||
echo "$CHANGED_FILES" | grep -q target/linux/generic ||
echo "$CHANGED_FILES" | grep -q $(echo $TARGET | cut -d "/" -f 1); then
TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}'
[[ $FIRST -ne 1 ]] && JSON_TARGETS="$JSON_TARGETS"','
JSON_TARGETS="$JSON_TARGETS""$TUPLE"
FIRST=0
fi
done
JSON_TARGETS="$JSON_TARGETS"']'
echo -e "\n---- targets to build ----\n"
echo "$JSON_TARGETS_SUBTARGETS"
echo -e "\n---- targets to build ----\n"
echo -e "\n---- targets to check patch ----\n"
echo "$JSON_TARGETS"
echo -e "\n---- targets to check patch ----\n"
echo "targets_subtargets=$JSON_TARGETS_SUBTARGETS" >> $GITHUB_OUTPUT
echo "targets=$JSON_TARGETS" >> $GITHUB_OUTPUT
build:
name: Build Kernel with external toolchain
needs: determine_targets
build-kernels:
name: Build all affected Kernels
permissions:
contents: read
packages: read
actions: write
strategy:
fail-fast: False
matrix:
include: ${{fromJson(needs.determine_targets.outputs.targets_subtargets)}}
uses: ./.github/workflows/build.yml
with:
container_name: toolchain
target: ${{ matrix.target }}
subtarget: ${{ matrix.subtarget }}
build_kernel: true
build_all_kmods: true
upload_ccache_cache: ${{ github.repository_owner == 'openwrt' }}

check-kernel-patches:
name: Check Kernel patches
needs: determine_targets
permissions:
contents: read
packages: read
strategy:
fail-fast: False
matrix:
include: ${{fromJson(needs.determine_targets.outputs.targets)}}
uses: ./.github/workflows/check-kernel-patches.yml
with:
target: ${{ matrix.target }}
subtarget: ${{ matrix.subtarget }}

upload-ccache-cache-in-s3:
if: github.event_name == 'push' && github.repository_owner == 'openwrt'
name: Upload ccache cache to s3
needs: [determine_targets, build]
strategy:
fail-fast: False
matrix:
include: ${{fromJson(needs.determine_targets.outputs.targets_subtargets)}}
secrets:
s3_access_key: ${{ secrets.GCS_S3_ACCESS_KEY }}
s3_secret_key: ${{ secrets.GCS_S3_SECRET_KEY }}
uses: ./.github/workflows/upload-file-s3.yml
with:
endpoint: https://storage.googleapis.com
bucket: openwrt-ci-cache
download_id: ${{ matrix.target }}-${{ matrix.subtarget }}-ccache-cache
filename: ccache-kernel-${{ matrix.target }}-${{ matrix.subtarget }}.tar
uses: openwrt/actions-shared-workflows/.github/workflows/kernel.yml@main
119 changes: 3 additions & 116 deletions .github/workflows/label-kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,123 +7,10 @@ on:
- labeled

jobs:
set_target:
if: startsWith(github.event.label.name, 'ci:kernel:')
name: Set target
runs-on: ubuntu-latest
outputs:
targets_subtargets: ${{ steps.set_target.outputs.targets_subtargets }}
targets: ${{ steps.set_target.outputs.targets }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Parse label
id: parse_label
env:
CI_EVENT_LABEL_NAME: ${{ github.event.label.name }}
run: |
echo "$CI_EVENT_LABEL_NAME" | sed -n 's/ci:kernel:\([^:]*\):\([^:]*\):*\([^:]*\)$/target=\1/p' | tee --append $GITHUB_OUTPUT
echo "$CI_EVENT_LABEL_NAME" | sed -n 's/ci:kernel:\([^:]*\):\([^:]*\):*\([^:]*\)$/subtarget=\2/p' | tee --append $GITHUB_OUTPUT
echo "$CI_EVENT_LABEL_NAME" | sed -n 's/ci:kernel:\([^:]*\):\([^:]*\):*\([^:]*\)$/testing=\3/p' | tee --append $GITHUB_OUTPUT
- name: Set targets
id: set_target
run: |
ALL_TARGETS="$(perl ./scripts/dump-target-info.pl kernels 2>/dev/null)"
TARGETS_SUBTARGETS="$(echo "$ALL_TARGETS" | sort -u -t '/' -k1)"
TARGETS="$(echo "$ALL_TARGETS" | sort -u -t '/' -k1,1)"
[ "${{ steps.parse_label.outputs.subtarget }}" = "first" ] && TARGETS_SUBTARGETS=$TARGETS
JSON_TARGETS_SUBTARGETS='['
FIRST=1
while IFS= read -r line; do
TARGET_SUBTARGET=$(echo $line | cut -d " " -f 1)
TARGET=$(echo $TARGET_SUBTARGET | cut -d "/" -f 1)
SUBTARGET=$(echo $TARGET_SUBTARGET | cut -d "/" -f 2)
[ "${{ steps.parse_label.outputs.target }}" != "all" ] && [ "${{ steps.parse_label.outputs.target }}" != "$TARGET" ] && continue
[ "${{ steps.parse_label.outputs.subtarget }}" != "all" ] && [ "${{ steps.parse_label.outputs.subtarget }}" != "first" ] &&
[ "${{ steps.parse_label.outputs.subtarget }}" != $SUBTARGET ] && continue
if [ "${{ steps.parse_label.outputs.testing }}" = "testing" ]; then
TESTING_KERNEL_VER=$(echo $line | cut -d " " -f 3)
[ -z "$TESTING_KERNEL_VER" ] && continue
fi
TUPLE='{"target":"'"$TARGET"'","subtarget":"'"$SUBTARGET"'","testing":"'"$TESTING_KERNEL_VER"'"}'
[[ $FIRST -ne 1 ]] && JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"','
JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS""$TUPLE"
FIRST=0
done <<< "$TARGETS_SUBTARGETS"
JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"']'
JSON_TARGETS='['
FIRST=1
while IFS= read -r line; do
TARGET_SUBTARGET=$(echo $line | cut -d " " -f 1)
TARGET=$(echo $TARGET_SUBTARGET | cut -d "/" -f 1)
SUBTARGET=$(echo $TARGET_SUBTARGET | cut -d "/" -f 2)
[ "${{ steps.parse_label.outputs.target }}" != "all" ] && [ "${{ steps.parse_label.outputs.target }}" != $TARGET ] && continue
if [ "${{ steps.parse_label.outputs.testing }}" = "testing" ]; then
TESTING_KERNEL_VER=$(echo $line | cut -d " " -f 3)
[ -z "$TESTING_KERNEL_VER" ] && continue
fi
TUPLE='{"target":"'"$TARGET"'","subtarget":"'"$SUBTARGET"'","testing":"'"$TESTING_KERNEL_VER"'"}'
[[ $FIRST -ne 1 ]] && JSON_TARGETS="$JSON_TARGETS"','
JSON_TARGETS="$JSON_TARGETS""$TUPLE"
FIRST=0
done <<< "$TARGETS"
JSON_TARGETS="$JSON_TARGETS"']'
echo -e "\n---- targets to build ----\n"
echo "$JSON_TARGETS_SUBTARGETS"
echo -e "\n---- targets to build ----\n"
echo -e "\n---- targets to check patch ----\n"
echo "$JSON_TARGETS"
echo -e "\n---- targets to check patch ----\n"
echo "targets_subtargets=$JSON_TARGETS_SUBTARGETS" >> $GITHUB_OUTPUT
echo "targets=$JSON_TARGETS" >> $GITHUB_OUTPUT
build_kernel:
name: Build Kernel with external toolchain
needs: set_target
permissions:
contents: read
packages: read
actions: write
uses: ./.github/workflows/build.yml
strategy:
fail-fast: False
matrix:
include: ${{fromJson(needs.set_target.outputs.targets_subtargets)}}
with:
container_name: toolchain
target: ${{ matrix.target }}
subtarget: ${{ matrix.subtarget }}
testing: ${{ matrix.testing != '' && true }}
build_kernel: true
build_all_kmods: true

check-kernel-patches:
name: Check Kernel patches
needs: set_target
build-kernels-label:
name: Build all affected Kernels from defined label
permissions:
contents: read
packages: read
actions: write
strategy:
fail-fast: False
matrix:
include: ${{fromJson(needs.set_target.outputs.targets)}}
uses: ./.github/workflows/check-kernel-patches.yml
with:
target: ${{ matrix.target }}
subtarget: ${{ matrix.subtarget }}
testing: ${{ matrix.testing != '' && true }}
uses: openwrt/actions-shared-workflows/.github/workflows/label-kernel.yml@main
32 changes: 3 additions & 29 deletions .github/workflows/label-target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,10 @@ on:
- labeled

jobs:
set_target:
if: startsWith(github.event.label.name, 'ci:target:')
name: Set target
runs-on: ubuntu-latest
outputs:
target: ${{ steps.set_target.outputs.target }}
subtarget: ${{ steps.set_target.outputs.subtarget }}

steps:
- name: Set target
id: set_target
env:
CI_EVENT_LABEL_NAME: ${{ github.event.label.name }}
run: |
echo "$CI_EVENT_LABEL_NAME" | sed -n 's/.*:\(.*\):\(.*\)$/target=\1/p' | tee --append $GITHUB_OUTPUT
echo "$CI_EVENT_LABEL_NAME" | sed -n 's/.*:\(.*\):\(.*\)$/subtarget=\2/p' | tee --append $GITHUB_OUTPUT
build_target:
name: Build target
needs: set_target
build-target-label:
name: Build target from defined label
permissions:
contents: read
packages: read
actions: write
uses: ./.github/workflows/build.yml
with:
container_name: toolchain
target: ${{ needs.set_target.outputs.target }}
subtarget: ${{ needs.set_target.outputs.subtarget }}
build_full: true
build_all_kmods: true
build_all_boards: true
build_all_modules: true
uses: openwrt/actions-shared-workflows/.github/workflows/label-target.yml@main
Loading

0 comments on commit 38cc091

Please sign in to comment.