name: CI on: push: branches: [main] tags: ["*"] pull_request: branches: [main] workflow_dispatch: permissions: contents: read concurrency: group: ci-${{ github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: # ── Lint, Build & Test on macOS and Linux ────────────────────── build: name: ${{ matrix.name }} runs-on: ${{ matrix.runner }} container: ${{ matrix.container }} strategy: fail-fast: false matrix: include: - name: "macOS" runner: macos-15 container: "" install-swiftlint: brew install swiftlint - name: "Linux" runner: ubuntu-latest container: swift:6.0 install-swiftlint: | apt-get update && apt-get install -y curl unzip SWIFTLINT_VERSION="0.58.2" curl -fsSL "https://github.com/realm/SwiftLint/releases/download/${SWIFTLINT_VERSION}/swiftlint_linux.zip" -o swiftlint.zip unzip -o swiftlint.zip -d /usr/local/bin chmod +x /usr/local/bin/swiftlint rm swiftlint.zip steps: - name: Checkout uses: actions/checkout@v4 - name: Install SwiftLint run: ${{ matrix.install-swiftlint }} - name: Lint run: swiftlint - name: Build env: DISABLE_SWIFTLINT: "1" run: swift build - name: Test env: DISABLE_SWIFTLINT: "1" run: swift test # ── Update test count badge in README (main only) ───────────── update-badge: name: Update test badge needs: build runs-on: macos-15 if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' permissions: contents: write steps: - name: Checkout uses: actions/checkout@v4 with: ref: main - name: Count tests and suites id: counts run: | TESTS=$(grep -r '@Test\b' Tests/ --include='*.swift' | wc -l | tr -d ' ') SUITES=$(grep -r '@Suite\b' Tests/ --include='*.swift' | wc -l | tr -d ' ') echo "tests=$TESTS" >> "$GITHUB_OUTPUT" echo "suites=$SUITES" >> "$GITHUB_OUTPUT" echo "Found $TESTS tests in $SUITES suites" - name: Update README badge and counts env: TESTS: ${{ steps.counts.outputs.tests }} SUITES: ${{ steps.counts.outputs.suites }} run: | # Badge: Tests-NNN_passing sed -i '' "s/Tests-[0-9]*_passing/Tests-${TESTS}_passing/" README.md # Project structure: NNN tests across NN test suites sed -i '' "s/[0-9]* tests across [0-9]* test suites/${TESTS} tests across ${SUITES} test suites/" README.md # Developer notes: All NNN tests run in parallel sed -i '' "s/All [0-9]* tests run/All ${TESTS} tests run/" README.md - name: Commit if changed run: | git diff --quiet README.md && echo "No changes" && exit 0 git config user.name "Frank Gregor" git config user.email "phranck@mac.com" git add README.md # [skip ci] prevents the push from triggering another workflow run git commit -m "Chore: Update test count badge to ${{ steps.counts.outputs.tests }} tests [skip ci]" git push # ── DocC Documentation (→ docs.tuikit.dev) ─────────────────── deploy-docs: name: Build & Deploy DocC needs: build runs-on: macos-15 if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' steps: - name: Checkout uses: actions/checkout@v4 - name: Build DocC documentation env: DISABLE_SWIFTLINT: "1" run: | swift package --allow-writing-to-directory docc-output \ generate-documentation \ --target TUIkit \ --output-path docc-output \ --transform-for-static-hosting - name: Add routing support for GitHub Pages run: | cp Sources/TUIkit/TUIkit.docc/theme-overrides.css docc-output/theme-overrides.css python3 - <<'PY' from pathlib import Path link = '' for path in Path("docc-output").rglob("*.html"): content = path.read_text(encoding="utf-8") if link in content or "" not in content: continue path.write_text(content.replace("", f" {link}\n"), encoding="utf-8") PY # 404.html = copy of SPA index so all deep-link paths route through DocC cp docc-output/index.html docc-output/404.html # Root redirect: docs.tuikit.dev/ -> docs.tuikit.dev/documentation/tuikit/ cat > docc-output/index.html << 'REDIRECT' Redirecting to TUIkit Documentation

Redirecting to TUIkit Documentation...

REDIRECT - name: Deploy to tuikit-docs uses: peaceiris/actions-gh-pages@v4 with: deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }} external_repository: phranck/tuikit-docs publish_branch: gh-pages publish_dir: docc-output cname: docs.tuikit.dev