Files
netshift/.github/workflows/build.yml
yandexru45 a0ae7c64d9 test: add OpenWrt rootfs Docker smoke-test suite
Port the source-level smoke-test harness from the padkap fork, adapted to
NetShift. Runs the shell/jq/config-generation logic against a real OpenWrt
24.10.6 userland (sing-box, jq, nft) before flashing to a router.

- tests/Dockerfile: alpine downloads official OpenWrt rootfs tarball ->
  FROM scratch; opkg installs sing-box curl jq coreutils-base64 bind-dig nftables
- tests/docker-compose.yml: service netshift-test, bind-mounts netshift/files,
  NET_ADMIN/NET_RAW/SYS_ADMIN caps, host network
- tests/entrypoint.sh: 10 test groups (deps, syntax, config, helpers, jq,
  config-manager, sing-box check, nft, diagnostics, subscription); adapted to
  our config options (dns_type/connection_type/proxy_config_type) and helper
  API (url_is_ipv6_literal); updater.sh added to syntax checks
- .github/workflows/openwrt-smoke-tests.yml: standalone CI on push/PR
- build.yml: smoke-tests job gates the release build (needs: smoke-tests)
- .dockerignore + .gitignore (tests/test-results/)

Verified locally: docker compose run netshift-test all -> 44 passed / 0 failed.
2026-06-02 18:24:23 +03:00

137 lines
4.6 KiB
YAML

name: Build packages
on:
push:
tags:
- '*'
permissions:
contents: write
jobs:
smoke-tests:
name: OpenWrt rootfs smoke tests
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v5.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.11.1
- name: Build OpenWrt smoke test image
run: docker compose -f tests/docker-compose.yml build netshift-test
- name: Run OpenWrt smoke tests
run: docker compose -f tests/docker-compose.yml run --rm netshift-test all
preparation:
name: Setup build version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v5.0.0
with:
fetch-depth: 0
- id: version
run: |
VERSION=$(git describe --tags --exact-match 2>/dev/null || echo "0.$(date +%d%m%Y)")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
build:
name: Builder for ${{ matrix.package_type }} netshift and luci-app-netshift
runs-on: ubuntu-latest
needs:
- preparation
- smoke-tests
strategy:
matrix:
include:
- { package_type: ipk }
- { package_type: apk }
steps:
- uses: actions/checkout@v5.0.0
with:
fetch-depth: 0
- name: Build ${{ matrix.package_type }}
uses: docker/build-push-action@v6.18.0
with:
file: ./Dockerfile-${{ matrix.package_type }}
context: .
tags: netshift:ci-${{ matrix.package_type }}
build-args: |
NETSHIFT_VERSION=${{ needs.preparation.outputs.version }}
- name: Create ${{ matrix.package_type }} Docker container
run: docker create --name ${{ matrix.package_type }} netshift:ci-${{ matrix.package_type }}
- name: Copy files from ${{ matrix.package_type }} Docker container
run: |
mkdir -p ./bin/${{ matrix.package_type }}
docker cp ${{ matrix.package_type }}:/builder/bin/packages/x86_64/utilities/. ./bin/${{ matrix.package_type }}/
docker cp ${{ matrix.package_type }}:/builder/bin/packages/x86_64/luci/. ./bin/${{ matrix.package_type }}/
# IPK uses underscore `_` in filenames, while APK uses only dash `-`
- name: Fix naming difference between build for packages (replace _ with -)
if: matrix.package_type == 'ipk'
shell: bash
run: |
for f in ./bin/${{ matrix.package_type }}/*.${{ matrix.package_type }}; do
[ -e "$f" ] || continue
base=$(basename "$f")
newname=$(echo "$base" | sed 's/_/-/g')
mv "$f" "./bin/${{ matrix.package_type }}/$newname"
done
- name: Filter files
shell: bash
run: |
# Use version from preparation job (already without 'v' prefix)
VERSION="${{ needs.preparation.outputs.version }}"
mkdir -p ./filtered-bin/${{ matrix.package_type }}
cp ./bin/${{ matrix.package_type }}/luci-i18n-netshift-ru-*.${{ matrix.package_type }} "./filtered-bin/${{ matrix.package_type }}/luci-i18n-netshift-ru-${VERSION}.${{ matrix.package_type }}"
cp ./bin/${{ matrix.package_type }}/netshift-*.${{ matrix.package_type }} ./filtered-bin/${{ matrix.package_type }}/
cp ./bin/${{ matrix.package_type }}/luci-app-netshift-*.${{ matrix.package_type }} ./filtered-bin/${{ matrix.package_type }}/
- name: Remove Docker container
run: docker rm ${{ matrix.package_type }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4.6.2
with:
name: release-files-${{ github.ref_name }}-${{ matrix.package_type }}
path: ./filtered-bin/${{ matrix.package_type }}/*.${{ matrix.package_type }}
retention-days: 1
if-no-files-found: error
release:
name: Create Release
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v5.0.0
- name: Create release dir
run: mkdir -p ./filtered-bin/release
- name: Download ipk artifacts
uses: actions/download-artifact@v4
with:
name: release-files-${{ github.ref_name }}-ipk
path: ./filtered-bin/release
- name: Download apk artifacts
uses: actions/download-artifact@v4
with:
name: release-files-${{ github.ref_name }}-apk
path: ./filtered-bin/release
- name: Release
uses: softprops/action-gh-release@v2.4.0
with:
files: ./filtered-bin/release/*.*
draft: false
prerelease: false
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}