Skip to content

Commit 6283073

Browse files
authored
refactor: Build based on OOS versions, refine filters & validation (WildKernels#79)
Added OOS16 Support Workflow Unification: OOS14, OOS15 and OOS16 have been merged into a single build-kernel-release.yml. JSON Support: Added support for the configs/oos1*/ directorys and input options to handle OOS1* kernels. New JSON Fields: Introduced the fields bbg, manual_hooks, bbr, ttl, ip in the configuration JSON files. Updated Filter Logic: The op_model input options now include OOS combinations (e.g., OOS14+15+16, OOS15+16) and androidX.Y filters (e.g., android14-6.1). The androidX.Y filters have been updated to apply only to files found in configs/oos15/ and configs/oos16/. Unique Artifact Names: Artifact names uploaded are now unique (kernel-<model>-<OS>) to prevent conflicts when building the same model for different OS versions in a single run. Validation Improvements: Updated validation logic in the action to include the new fields and handle the new filters correctly. Bug Fixes: Resolved bugs related to the FILTERED_FOR_ANDROID variable usage and the extraction of av/kv values in androidX.Y filters. Config Discovery Simplification: Optimized the initial JSON file reading in the Setup OnePlus Model step using find configs/.
1 parent 5ac1c25 commit 6283073

33 files changed

+417
-134
lines changed

.github/actions/action.yml

Lines changed: 145 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -55,45 +55,134 @@ runs:
5555
soc="$OP_SOC"
5656
branch="$OP_BRANCH"
5757
manifest="$OP_MANIFEST"
58+
android_version="$OP_ANDROID_VERSION"
59+
kernel_version="$OP_KERNEL_VERSION"
60+
os_version="$OP_OS_VERSION"
61+
hmbird="$OP_HMBIRD"
62+
bbg="$OP_BBG"
63+
bbr="$OP_BBR"
64+
ttl="$OP_TTL"
65+
ip_set="$OP_IP_SET"
5866
optimize='${{ inputs.optimize_level }}'
59-
60-
# Non-empty checks
61-
[[ -n "$model" ]] || { echo "Input 'model' cannot be empty"; exit 1; }
62-
[[ -n "$soc" ]] || { echo "Input 'soc' cannot be empty"; exit 1; }
63-
[[ -n "$branch" ]] || { echo "Input 'branch' cannot be empty"; exit 1; }
64-
[[ -n "$manifest" ]] || { echo "Input 'manifest' cannot be empty"; exit 1; }
65-
66-
# Basic format checks
67+
68+
# Initialize an array to collect errors
69+
errors=()
70+
71+
# Non-empty checks & Basic format checks
72+
# model: allow start with 'OP'
73+
if [[ -z "$model" ]]; then
74+
errors+=("Input 'model' cannot be empty")
75+
elif [[ ! "$model" =~ ^OP ]]; then
76+
errors+=("Input 'model' does not start with 'OP'. Got: '$model'")
77+
fi
78+
6779
# soc: allow letters, digits, underscores, dashes (e.g., sm8650)
68-
if ! [[ "$soc" =~ ^[A-Za-z0-9_-]+$ ]]; then
69-
echo "Input 'soc' contains invalid characters. Allowed: letters, digits, underscore, dash"; exit 1
70-
fi
80+
if [[ -z "$soc" ]]; then
81+
errors+=("Input 'soc' cannot be empty")
82+
elif [[ ! "$soc" =~ ^[A-Za-z0-9_-]+$ ]]; then
83+
errors+=("Input 'soc' contains invalid characters. Allowed: letters, digits, underscore, dash. Got: '$soc'")
84+
fi
85+
7186
# branch: allow common ref patterns; spaces not allowed
72-
if ! [[ "$branch" =~ ^[A-Za-z0-9._/-]+$ ]]; then
73-
echo "Input 'branch' contains invalid characters. Allowed: letters, digits, ., _, -, /"; exit 1
74-
fi
87+
if [[ -z "$branch" ]]; then
88+
errors+=("Input 'branch' cannot be empty")
89+
elif [[ ! "$branch" =~ ^[A-Za-z0-9._/-]+$ ]]; then
90+
errors+=("Input 'branch' contains invalid characters. Allowed: letters, digits, ., _, -, /. Got: '$branch'")
91+
fi
92+
7593
# manifest: either HTTPS URL ending with .xml, or a filename ending with .xml (no spaces)
76-
if [[ "$manifest" == http*://* ]]; then
77-
if ! [[ "$manifest" =~ ^https:// ]]; then
78-
echo "Manifest URL must be HTTPS"; exit 1
94+
if [[ -z "$manifest" ]]; then
95+
errors+=("Input 'manifest' cannot be empty")
96+
elif [[ "$manifest" == http*://* ]]; then
97+
if [[ ! "$manifest" =~ ^https:// ]]; then
98+
errors+=("Manifest URL must be HTTPS. Got: '$manifest'")
7999
fi
80-
if ! [[ "$manifest" =~ \.xml($|\?) ]]; then
81-
echo "Manifest URL should point to an XML file (.xml)"; exit 1
100+
if [[ ! "$manifest" =~ \.xml($|\?) ]]; then
101+
errors+=("Manifest URL should point to an XML file (.xml). Got: '$manifest'")
82102
fi
83103
else
84-
if ! [[ "$manifest" =~ \.xml$ ]]; then
85-
echo "Manifest filename must end with .xml"; exit 1
104+
if [[ ! "$manifest" =~ \.xml$ ]]; then
105+
errors+=("Manifest filename must end with .xml. Got: '$manifest'")
86106
fi
87107
if [[ "$manifest" =~ [[:space:]] ]]; then
88-
echo "Manifest filename cannot contain spaces"; exit 1
108+
errors+=("Manifest filename cannot contain spaces. Got: '$manifest'")
89109
fi
90110
fi
111+
112+
# android_version: allow android followed by a number
113+
if [[ -z "$android_version" ]]; then
114+
errors+=("Input 'android_version' cannot be empty")
115+
elif [[ ! "$android_version" =~ ^android[0-9]+$ ]]; then
116+
# Se non è vuoto, controlla il formato specifico
117+
errors+=("Input 'android_version' contains invalid characters. Allowed: android followed by a number. Got: '$android_version'")
118+
fi
119+
120+
# kernel_version: allow number in X.Y format
121+
if [[ -z "$kernel_version" ]]; then
122+
errors+=("Input 'kernel_version' cannot be empty")
123+
elif [[ ! "$kernel_version" =~ ^[0-9]+\.[0-9]+$ ]]; then
124+
errors+=("Input 'kernel_version' contains invalid characters. Allowed: number in X.Y format. Got: '$kernel_version'")
125+
fi
126+
127+
# os_version: allow start with 'OOS'
128+
if [[ -z "$os_version" ]]; then
129+
errors+=("Input 'os_version' cannot be empty")
130+
elif [[ ! "$os_version" =~ ^OOS ]]; then
131+
errors+=("Input 'os_version' does not start with 'OOS'. Got: '$os_version'")
132+
fi
133+
134+
# hmbird: allow 'true' or 'false'
135+
if [[ -z "$hmbird" ]]; then
136+
errors+=("Input 'hmbird' cannot be empty")
137+
elif [[ "$hmbird" != "true" && "$hmbird" != "false" ]]; then
138+
errors+=("Input 'hmbird' contains invalid characters. Allowed: 'true' or 'false'. Got: '$hmbird'")
139+
fi
140+
141+
# bbg: allow 'true' or 'false'
142+
if [[ -z "$bbg" ]]; then
143+
errors+=("Input 'bbg' cannot be empty")
144+
elif [[ "$bbg" != "true" && "$bbg" != "false" ]]; then
145+
errors+=("Input 'bbg' contains invalid characters. Allowed: 'true' or 'false'. Got: '$bbg'")
146+
fi
147+
148+
# bbr: allow 'true' or 'false'
149+
if [[ -z "$bbr" ]]; then
150+
errors+=("Input 'bbr' cannot be empty")
151+
elif [[ "$bbr" != "true" && "$bbr" != "false" ]]; then
152+
errors+=("Input 'bbr' contains invalid characters. Allowed: 'true' or 'false'. Got: '$bbr'")
153+
fi
154+
155+
# ttl: allow 'true' or 'false'
156+
if [[ -z "$ttl" ]]; then
157+
errors+=("Input 'ttl' cannot be empty")
158+
elif [[ "$ttl" != "true" && "$ttl" != "false" ]]; then
159+
errors+=("Input 'ttl' contains invalid characters. Allowed: 'true' or 'false'. Got: '$ttl'")
160+
fi
161+
162+
# ip_set: allow 'true' or 'false'
163+
if [[ -z "$ip_set" ]]; then
164+
errors+=("Input 'ip_set' cannot be empty")
165+
elif [[ "$ip_set" != "true" && "$ip_set" != "false" ]]; then
166+
errors+=("Input 'ip_set' contains invalid characters. Allowed: 'true' or 'false'. Got: '$ip_set'")
167+
fi
168+
91169
# Optimize level validation
92170
case "$optimize" in
93171
O2|O3) ;;
94-
*) echo "optimize_level must be O2 or O3; got '$optimize'"; exit 1 ;;
172+
*) errors+=("optimize_level must be O2 or O3. Got: '$optimize'"); ;;
95173
esac
96-
echo "Input validation OK."
174+
175+
# Check for errors and act accordingly
176+
if [ ${#errors[@]} -ne 0 ]; then
177+
echo "Found ${#errors[@]} validation error(s):" >&2
178+
for error in "${errors[@]}"; do
179+
echo " - $error" >&2
180+
done
181+
echo "::error::Input validation failed. See logs for details."
182+
exit 1
183+
else
184+
echo "Input validation OK."
185+
fi
97186
echo "::endgroup::"
98187
99188
- name: Install Minimal Dependencies
@@ -182,7 +271,8 @@ runs:
182271
SUBLEVEL=$(grep '^SUBLEVEL *=' Makefile | awk '{print $3}')
183272
FULL_VERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
184273
cd "$ARTIFACTS_DIR"
185-
echo "$ANDROID_VERSION-$FULL_VERSION" > "${OP_MODEL}.txt"
274+
echo "$ANDROID_VERSION-$FULL_VERSION" > "${OP_MODEL}_${OP_OS_VERSION}.txt"
275+
echo "$OP_OS_VERSION" >> "${OP_MODEL}_${OP_OS_VERSION}.txt"
186276
echo "ANDROID_VER=$ANDROID_VERSION" >> "$GITHUB_ENV"
187277
echo "KERNEL_VER=$VERSION.$PATCHLEVEL" >> "$GITHUB_ENV"
188278
echo "KERNEL_FULL_VER=$ANDROID_VERSION-$FULL_VERSION" >> "$GITHUB_ENV"
@@ -224,6 +314,7 @@ runs:
224314
df -h
225315
226316
- name: Add BBG
317+
if: ${{ env.OP_BBG == 'true' }}
227318
shell: bash
228319
run: |
229320
set -euo pipefail
@@ -233,6 +324,7 @@ runs:
233324
echo "CONFIG_BBG=y" >> common/arch/arm64/configs/gki_defconfig
234325
sed -i '/^config LSM$/,/^help$/{ /^[[:space:]]*default/ { /baseband_guard/! s/lockdown/lockdown,baseband_guard/ } }' common/security/Kconfig
235326
327+
236328
- name: Add KernelSU Next
237329
shell: bash
238330
run: |
@@ -307,7 +399,7 @@ runs:
307399
sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c
308400
fi
309401
fi
310-
402+
311403
# Fake kernel patch to fix failures
312404
fake_patched=0
313405
if [ "${{ env.ANDROID_VER }}" = "android15" ] && [ "${{ env.KERNEL_VER }}" = "6.6" ]; then
@@ -329,9 +421,9 @@ runs:
329421
fake_patched=1
330422
fi
331423
fi
332-
424+
333425
patch -p1 < 50_add_susfs_in_${{ env.SUSFS_KERNEL_BRANCH }}.patch
334-
426+
335427
# Revert Fake kernel patch
336428
if [ "$fake_patched" = 1 ]; then
337429
if [ "${{ env.ANDROID_VER }}" = "android15" ] && [ "${{ env.KERNEL_VER }}" = "6.6" ]; then
@@ -353,7 +445,7 @@ runs:
353445
fi
354446
fi
355447
fi
356-
448+
357449
KERNEL_VERSION="${{ env.KERNEL_VER }}"
358450
MIN_VERSION="5.16"
359451
if [ "$(printf '%s\n' "$KERNEL_VERSION" "$MIN_VERSION" | sort -V | head -n1)" = "$KERNEL_VERSION" ]; then
@@ -412,6 +504,7 @@ runs:
412504
EOF
413505
414506
- name: Add Oneplus BBR
507+
if: ${{ env.OP_BBR == 'true' }}
415508
shell: bash
416509
run: |
417510
set -euo pipefail
@@ -424,6 +517,7 @@ runs:
424517
EOF
425518
426519
- name: Add TTL Target Support
520+
if: ${{ env.OP_TTL == 'true' }}
427521
shell: bash
428522
run: |
429523
set -euo pipefail
@@ -435,6 +529,7 @@ runs:
435529
EOF
436530
437531
- name: Add IP SET Support
532+
if: ${{ env.OP_IP_SET == 'true' }}
438533
shell: bash
439534
run: |
440535
set -euo pipefail
@@ -531,10 +626,10 @@ runs:
531626
COMMON="$KERNEL_PATH/common"
532627
cd "$COMMON"
533628
: > "$COMMON/.scmversion"
534-
629+
535630
# Ensure Python warnings are suppressed for scripts invoked by make
536631
export PYTHONWARNINGS="${PYTHONWARNINGS}"
537-
632+
538633
if [ -n "${CLANG_BIN_PATH:-}" ] && [ -x "${CLANG_BIN_PATH}/clang" ]; then
539634
export PATH="${CLANG_BIN_PATH}:$PATH"
540635
fi
@@ -547,14 +642,14 @@ runs:
547642
OUT=out
548643
mkdir -p "$OUT"
549644
make O="$OUT" gki_defconfig
550-
645+
551646
# LOCALVERSION branding
552647
if [ -n "${CUSTOM_LOCALVERSION:-}" ]; then
553648
scripts/config --file "$OUT/.config" --set-str LOCALVERSION "${CUSTOM_LOCALVERSION}"
554649
scripts/config --file "$OUT/.config" -d LOCALVERSION_AUTO || true
555650
sed -i 's/scm_version="$(scm_version --short)"/scm_version=""/' scripts/setlocalversion
556651
fi
557-
652+
558653
# Optimize level config and flags
559654
if [ "${{ inputs.optimize_level }}" = "O3" ]; then
560655
scripts/config --file "$OUT/.config" -d CC_OPTIMIZE_FOR_PERFORMANCE
@@ -565,18 +660,18 @@ runs:
565660
scripts/config --file "$OUT/.config" -d CC_OPTIMIZE_FOR_PERFORMANCE_O3
566661
KCFLAGS_EXTRA="-O2"
567662
fi
568-
663+
569664
# Consistent flags; include -pipe and disable stack protector
570665
KCFLAGS="-Wno-error -pipe -fno-stack-protector ${KCFLAGS_EXTRA}"
571666
KCPPFLAGS="-DCONFIG_OPTIMIZE_INLINING"
572-
667+
573668
# Regenerate defaults after config edits
574669
make O="$OUT" olddefconfig
575-
670+
576671
echo "Starting build with $(nproc --all) threads..."
577672
set -o pipefail
578673
make -j"$(nproc --all)" O="$OUT" KCFLAGS="$KCFLAGS" KCPPFLAGS="$KCPPFLAGS" 2>&1 | tee build.log
579-
674+
580675
IMG="$OUT/arch/arm64/boot/Image"
581676
if [ ! -f "$IMG" ]; then
582677
echo "Kernel Image missing"
@@ -626,27 +721,27 @@ runs:
626721
echo "ERROR: Built Image not found"
627722
exit 1
628723
fi
629-
724+
630725
# Put Image into AnyKernel3
631726
cp "$IMAGE_PATH" "$GITHUB_WORKSPACE/AnyKernel3/Image"
632727
cd "$GITHUB_WORKSPACE/AnyKernel3"
633-
728+
634729
# Optional hmbird patch logic
635730
if [ "$OP_HMBIRD" = true ]; then
636731
cp "$GITHUB_WORKSPACE/kernel_patches/oneplus/hmbird/bins/"* ./tools/ 2>/dev/null || true
637732
patch -F 3 < "$GITHUB_WORKSPACE/kernel_patches/oneplus/hmbird/ak3_hmbird_patch.patch"
638733
fi
639-
640-
ZIP_NAME="AnyKernel3_${OP_MODEL}_${{ env.KERNEL_FULL_VER }}_Next_${KSUVER}_${SUSVER}.zip"
734+
735+
ZIP_NAME="AK3_${OP_MODEL}_${OP_OS_VERSION}_${KERNEL_FULL_VER}_Next_${KSUVER}_${SUSVER}.zip"
641736
ARTIFACTS_DIR="$CONFIG_DIR/artifacts"
642737
mkdir -p "$ARTIFACTS_DIR"
643-
738+
644739
echo "Creating flashable zip: $ZIP_NAME"
645740
( cd "$GITHUB_WORKSPACE/AnyKernel3" && zip -r "$ARTIFACTS_DIR/$ZIP_NAME" ./* >/dev/null )
646-
741+
647742
# Keep only the flashable zip and the model metadata file (assumed already created earlier)
648-
find "$ARTIFACTS_DIR" -maxdepth 1 -type f ! -name "$ZIP_NAME" ! -name "${OP_MODEL}.txt" -delete
649-
743+
find "$ARTIFACTS_DIR" -maxdepth 1 -type f ! -name "$ZIP_NAME" ! -name "${OP_MODEL}_${OP_OS_VERSION}.txt" -delete
744+
650745
# Output for later steps (optional)
651746
echo "zip_name=$ZIP_NAME" >> "$GITHUB_OUTPUT"
652747
@@ -655,7 +750,8 @@ runs:
655750
run: |
656751
set -euo pipefail
657752
{
658-
echo "Model: ${OP_MODEL}"
753+
echo "Model: ${{ env.OP_MODEL }}"
754+
echo "OS Version: ${{ env.OP_OS_VERSION }}"
659755
echo "Android: ${{ env.ANDROID_VER }}"
660756
echo "Kernel base: ${{ env.KERNEL_VER }}"
661757
echo "Kernel full: ${{ env.KERNEL_FULL_VER }}"
@@ -672,8 +768,8 @@ runs:
672768
{
673769
echo "### Kernel Build Summary"
674770
echo ""
675-
echo "- Model: ${OP_MODEL}"
676-
echo "- Android: ${{ env.ANDROID_VER }}"
771+
echo "- Model: ${{ env.OP_MODEL }}"
772+
echo "- OS Version: ${{ env.OP_OS_VERSION }}"
677773
echo "- Kernel Version: ${{ steps.save_metadata.outputs.kernel_version }}"
678774
echo "- Kernel Uname: ${{ env.KERNEL_UNAME }}"
679775
echo "- KSUN Version: ${KSUVER:-unknown}"
@@ -689,5 +785,5 @@ runs:
689785
if: success() && steps.create_zip.conclusion == 'success'
690786
uses: actions/upload-artifact@v4
691787
with:
692-
name: kernel-${{ env.CONFIG }}
788+
name: kernel-${{ env.CONFIG }}_${{ env.OP_OS_VERSION }}
693789
path: ${{ env.CONFIG }}/artifacts/

0 commit comments

Comments
 (0)