mirror of
https://github.com/Zxilly/UA2F.git
synced 2025-12-29 14:39:19 +00:00
275 lines
8.0 KiB
YAML
275 lines
8.0 KiB
YAML
name: Build OpenWRT Package
|
|
|
|
on:
|
|
push:
|
|
paths-ignore:
|
|
- '**.md'
|
|
branches:
|
|
- master
|
|
workflow_dispatch:
|
|
pull_request:
|
|
paths-ignore:
|
|
- '**.md'
|
|
release:
|
|
types:
|
|
- created
|
|
|
|
jobs:
|
|
test:
|
|
name: Run unit tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y cmake libnetfilter-queue-dev libmnl-dev libnetfilter-conntrack-dev libjson-c-dev
|
|
|
|
- name: Build and install libubox
|
|
working-directory: /tmp
|
|
run: |
|
|
git clone https://github.com/openwrt/libubox.git
|
|
cd libubox
|
|
mkdir build
|
|
cd build
|
|
cmake .. -DBUILD_LUA=OFF -DBUILD_EXAMPLES=OFF
|
|
make
|
|
sudo make install
|
|
|
|
- name: Build and install libuci
|
|
working-directory: /tmp
|
|
run: |
|
|
git clone https://github.com/openwrt/uci.git
|
|
cd uci
|
|
mkdir build
|
|
cd build
|
|
cmake .. -DBUILD_LUA=OFF
|
|
make
|
|
sudo make install
|
|
|
|
- name: Run unit tests
|
|
run: |
|
|
cmake -S . -B build -DUA2F_BUILD_TESTS=ON
|
|
cmake --build build
|
|
./build/ua2f_test
|
|
|
|
- name: Generate unit test coverage
|
|
run: |
|
|
cmake -S . -B build-coverage -DUA2F_BUILD_TESTS=ON
|
|
cmake --build build-coverage
|
|
cd build-coverage
|
|
make coverage
|
|
|
|
- name: Upload unit test coverage to Codecov
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
directory: build-coverage
|
|
flags: unittests
|
|
fail_ci_if_error: true
|
|
verbose: true
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
test-standalone:
|
|
name: Run unit tests without uci support
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y cmake libnetfilter-queue-dev libmnl-dev libnetfilter-conntrack-dev
|
|
|
|
- name: Run unit tests
|
|
run: |
|
|
cmake -S . -B build -DUA2F_BUILD_TESTS=ON -DUA2F_ENABLE_UCI=OFF
|
|
cmake --build build
|
|
./build/ua2f_test
|
|
|
|
- name: Generate unit test coverage (standalone)
|
|
run: |
|
|
cmake -S . -B build-coverage -DUA2F_BUILD_TESTS=ON -DUA2F_ENABLE_UCI=OFF
|
|
cmake --build build-coverage
|
|
cd build-coverage
|
|
make coverage
|
|
|
|
- name: Upload unit test coverage to Codecov (standalone)
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
directory: build-coverage
|
|
flags: unittests-standalone
|
|
fail_ci_if_error: true
|
|
verbose: true
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
|
|
test-integration:
|
|
name: Run integration tests
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
cache: [ "-DUA2F_NO_CACHE=ON", "-DUA2F_NO_CACHE=OFF" ]
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y cmake libnetfilter-queue-dev libmnl-dev libnetfilter-conntrack-dev
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: '3.13'
|
|
|
|
- name: Install requirements
|
|
run: |
|
|
pip install -r scripts/requirements.txt --break-system-packages
|
|
|
|
- name: Enable ipv6
|
|
uses: fscarmen/warp-on-actions@v1.3
|
|
with:
|
|
stack: dual
|
|
mode: client
|
|
|
|
- name: Configure ipv6
|
|
run: |
|
|
echo "net.ipv6.conf.all.disable_ipv6=0" | sudo tee -a /etc/sysctl.conf
|
|
echo "net.ipv6.conf.default.disable_ipv6=0" | sudo tee -a /etc/sysctl.conf
|
|
echo "net.ipv6.conf.lo.disable_ipv6=0" | sudo tee -a /etc/sysctl.conf
|
|
sudo sysctl -p
|
|
|
|
- name: Debug IPv6
|
|
run: |
|
|
ip -6 addr
|
|
sudo sysctl net.ipv6.conf.all.disable_ipv6
|
|
sudo sysctl net.ipv6.conf.default.disable_ipv6
|
|
sudo sysctl net.ipv6.conf.lo.disable_ipv6
|
|
|
|
ping6 -c 4 ::1 || { echo "::1 is not reachable"; exit 1; }
|
|
|
|
- name: Run integration tests
|
|
run: |
|
|
cmake -S . -B build -DUA2F_BUILD_TESTS=OFF -DUA2F_ENABLE_UCI=OFF -DUA2F_ENABLE_ASAN=ON ${{ matrix.cache }}
|
|
cmake --build build
|
|
sudo ./build/ua2f --version
|
|
sudo -E $(which python3) scripts/test.py ./build/ua2f
|
|
|
|
- name: Generate integration test coverage
|
|
run: |
|
|
# Build with coverage enabled for integration testing
|
|
cmake -S . -B build-coverage -DUA2F_BUILD_TESTS=OFF -DUA2F_ENABLE_UCI=OFF ${{ matrix.cache }}
|
|
cmake --build build-coverage
|
|
cd build-coverage
|
|
|
|
# Reset coverage counters
|
|
make coverage-integration
|
|
|
|
# Run integration tests with coverage-enabled binary
|
|
sudo ./ua2f --version
|
|
sudo -E $(which python3) ../scripts/test.py ./ua2f
|
|
|
|
# Fix ownership of all coverage files recursively
|
|
sudo chown -R $(whoami):$(whoami) .
|
|
|
|
# Ensure coverage files are readable
|
|
find . -name "*.gcno" -o -name "*.gcda" | xargs chmod 644
|
|
|
|
# Debug: List coverage files and their permissions
|
|
echo "Coverage files generated:"
|
|
find . -name "*.gcno" -o -name "*.gcda" | head -10 | xargs ls -la
|
|
|
|
# Count coverage files
|
|
gcno_count=$(find . -name "*.gcno" | wc -l)
|
|
gcda_count=$(find . -name "*.gcda" | wc -l)
|
|
echo "Found $gcno_count .gcno files and $gcda_count .gcda files"
|
|
|
|
- name: Upload integration test coverage to Codecov
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
directory: build-coverage
|
|
flags: integration
|
|
fail_ci_if_error: true
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
verbose: true
|
|
|
|
- name: Upload log
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: syslog-cache-${{ matrix.cache }}
|
|
path: /var/log/syslog
|
|
|
|
build:
|
|
name: Build ${{ matrix.arch }} on ${{ matrix.version }}
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- test
|
|
- test-standalone
|
|
- test-integration
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
arch:
|
|
- aarch64_cortex-a53
|
|
- aarch64_cortex-a72
|
|
- aarch64_generic
|
|
- arm_cortex-a7_neon-vfpv4
|
|
- arm_cortex-a9_vfpv3-d16
|
|
- arm_cortex-a15_neon-vfpv4
|
|
- mips_24kc
|
|
- mipsel_24kc
|
|
- x86_64
|
|
version:
|
|
- 23.05.5
|
|
- 24.10.0
|
|
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Build
|
|
uses: openwrt/gh-action-sdk@v9
|
|
env:
|
|
ARCH: ${{ matrix.arch }}-${{ matrix.version }}
|
|
FEEDNAME: packages_ci
|
|
PACKAGES: openwrt
|
|
V: sc
|
|
|
|
- name: Move created packages to project dir
|
|
run: |
|
|
mkdir -p tmp
|
|
cp bin/packages/${{ matrix.arch }}/packages_ci/*.ipk tmp/ || true
|
|
for f in tmp/*.ipk; do mv "$f" "${f/.ipk/-${{ matrix.version }}.ipk}" 2>/dev/null || true; done
|
|
mv tmp/*.ipk . 2>/dev/null || true
|
|
rm -rf tmp
|
|
|
|
- name: Store packages
|
|
uses: actions/upload-artifact@v4
|
|
if: "!startsWith(github.ref, 'refs/tags/v')"
|
|
with:
|
|
name: ${{ matrix.arch }}-${{ github.sha }}-${{ matrix.version }}-packages
|
|
path: "*.ipk"
|
|
|
|
- name: Upload packages
|
|
uses: svenstaro/upload-release-action@v2
|
|
if: "startsWith(github.ref, 'refs/tags/v')"
|
|
with:
|
|
repo_token: ${{ github.token }}
|
|
file: "*.ipk"
|
|
tag: ${{ github.ref }}
|
|
file_glob: true
|
|
|
|
- name: Store logs
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.arch }}-${{ github.sha }}-${{ matrix.version }}-logs
|
|
path: logs/
|
|
|
|
- name: Remove logs
|
|
run: rm -rf logs/ || true |