name: CI # Every push to main and every pull request; also called by build.yml, so a # tag never publishes a release without these checks passing on it. on: push: branches: [main] pull_request: workflow_call: permissions: contents: read concurrency: group: ci-${{ github.ref }} cancel-in-progress: true jobs: web: name: Web (format, types, tests, bundles) runs-on: ubuntu-24.04 defaults: run: working-directory: web steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup Node.js uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: '26' cache: npm cache-dependency-path: web/package-lock.json - name: Install dependencies run: npm ci - name: Check formatting id: format run: | if ! npm run --silent format:check; then echo "::error::Code is not formatted. Run 'npm run format' in web/." exit 1 fi # Sources and the test files (tsconfig.test.json). - name: Type check id: types run: npm run --silent typecheck # oxlint's correctness rules: what the types let through (a stray expression, a needless escape). - name: Lint id: lint run: npm run --silent lint # Exports nobody imports, files nobody reaches, dependencies used but not listed (or listed but unused). - name: Unused code id: knip run: | if ! npm run --silent knip; then echo "::error::knip found unused code or a dependency problem: remove it, or drop the export when only its own file uses it." exit 1 fi # The catalogs follow the code: every string collected, translated, its placeholders kept. - name: Translations id: i18n run: | if ! npm run --silent i18n:check; then echo "::error::The translation catalogs are out of date or incomplete. Run 'npm run i18n' in web/, translate the new entries in each ru.po and commit them (rules/i18n.md)." exit 1 fi - name: Tests id: tests run: npm test # The bundles under package/ are not committed (build.yml builds them # before packaging): a build must touch no tracked file and leave every # output it writes ignored by .gitignore, so none ends up in a commit. - name: Build bundles and check they stay out of git id: build run: | npm run --silent build changed="$(git status --porcelain --untracked-files=all -- ../package)" if [ -n "$changed" ]; then echo "$changed" echo "::error::The build changed a tracked file under package/ or wrote one .gitignore does not cover." exit 1 fi - name: Summary if: always() run: | { echo "## Web" echo "" echo "| Check | Result |" echo "|---|---|" echo "| Formatting | ${{ steps.format.outcome }} |" echo "| Types | ${{ steps.types.outcome }} |" echo "| Lint | ${{ steps.lint.outcome }} |" echo "| Unused code | ${{ steps.knip.outcome }} |" echo "| Translations | ${{ steps.i18n.outcome }} |" echo "| Tests | ${{ steps.tests.outcome }} |" echo "| Bundles | ${{ steps.build.outcome }} |" } >> "$GITHUB_STEP_SUMMARY" shell: name: ShellCheck runs-on: ubuntu-24.04 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false # Every shell script by its shebang (the init script's is "/bin/sh # /etc/rc.common"), so a new hotplug or libexec script is covered the # day it appears. Files without a shebang (keep.d lists) are not shell. - name: ShellCheck run: | shellcheck --version files="$(grep -rlIE '^#!(/usr)?/bin/(sh|bash|env (sh|bash))( |$)' \ install.sh uninstall.sh package/luci-app-dawnline/root scripts | sort)" echo "$files" for f in package/luci-app-dawnline/root/etc/init.d/dawnline \ package/luci-app-dawnline/root/etc/hotplug.d/iface/95-dawnline \ package/luci-app-dawnline/root/usr/libexec/dawnline/resolver \ package/luci-app-dawnline/root/usr/libexec/dawnline/postupdate \ package/luci-app-dawnline/root/usr/libexec/dawnline/fetch-backend; do echo "$files" | grep -qx "$f" || { echo "::error file=$f::not found by the shebang scan"; exit 1; } done # shellcheck disable=SC2086 shellcheck -S warning $files backend: name: "Backend (Go: vet, tests, a real ubusd and uhttpd)" runs-on: ubuntu-24.04 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false # The goldens in backend/*/testdata are the ucode backend's own answers, taken before it was removed # (0.18.0): they are fixed now, and hold the Go backend to what that one did. # gofmt, go vet and the unit tests in the Go toolchain image, then the object, the calls, the stream # and a page's whole path against the ubusd, rpcd and uhttpd of OpenWrt 24.10 and 25.12. - name: Format, vet, unit tests, and the tests in the OpenWrt containers run: scripts/backend-container.sh package: name: Package files runs-on: ubuntu-24.04 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Executables keep their mode run: | for f in usr/bin/dawnline usr/libexec/dawnline/updater usr/libexec/dawnline/fetch-backend usr/libexec/dawnline/resolver usr/libexec/dawnline/postupdate \ etc/init.d/dawnline etc/uci-defaults/90_dawnline etc/hotplug.d/iface/95-dawnline; do [ -x "package/luci-app-dawnline/root/$f" ] || { echo "::error file=package/luci-app-dawnline/root/$f::not executable (git update-index --chmod=+x $f)"; exit 1; } done for f in scripts/backend-container.sh scripts/build-backend.sh scripts/build-packages.sh scripts/build-release.sh scripts/deploy.sh; do [ -x "$f" ] || { echo "::error file=$f::not executable (git update-index --chmod=+x $f)"; exit 1; } done - name: Versions agree run: | v="$(sed -n 's/^PKG_VERSION:=//p' package/luci-app-dawnline/Makefile)" [ "$(cat package/luci-app-dawnline/root/usr/share/dawnline/version)" = "$v" ] || { echo "::error::usr/share/dawnline/version differs from the Makefile ($v)"; exit 1; } grep -q "\"version\": \"$v\"" web/package.json || { echo "::error::web/package.json version differs from the Makefile ($v)"; exit 1; } python3 - "$v" <<'PY' import json, sys v = sys.argv[1] lock = json.load(open('web/package-lock.json')) got = (lock.get('version'), lock.get('packages', {}).get('', {}).get('version')) if got != (v, v): print(f"::error::web/package-lock.json says {got}, the Makefile {v}: run 'npm install' in web/") sys.exit(1) PY echo "Version $v"