mirror of
https://github.com/phranck/TUIkit.git
synced 2026-05-21 09:50:35 +00:00
1f08efade5
- Remove docs/ directory (now in phranck/tuikit.dev) - Remove scheduled workflows (update-plans-data, update-weekly-activity, update-social-cache) - Remove build-landing and deploy-landing CI jobs - Remove pages/id-token permissions (no longer needed) - Keep: build (lint/test), update-badge, deploy-docs (DocC -> docs.tuikit.dev)
136 lines
4.3 KiB
YAML
136 lines
4.3 KiB
YAML
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: 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
|