# Forgejo Actions — runs on Forgejo runners; GHA-compatible syntax.
name: Swift Build & Test

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  build-test:
    name: swift build + test
    runs-on: macos-14
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Cache SwiftPM build artifacts
        uses: actions/cache@v4
        with:
          path: .build
          key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
          restore-keys: |
            ${{ runner.os }}-spm-

      - name: Swift version
        run: swift --version

      - name: Swift build
        run: swift build

      - name: Swift test
        run: swift test --parallel
