|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + workflow_dispatch: |
| 9 | + schedule: |
| 10 | + - cron: "0 8 * * 1" |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +jobs: |
| 16 | + metadata-validate: |
| 17 | + name: Metadata Validate |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + - name: Validate README metadata |
| 22 | + run: | |
| 23 | + chmod +x scripts/validate-readme-metadata.sh |
| 24 | + ./scripts/validate-readme-metadata.sh |
| 25 | +
|
| 26 | + readme-sync-check: |
| 27 | + name: README Sync Check |
| 28 | + runs-on: ubuntu-latest |
| 29 | + needs: metadata-validate |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + - name: Regenerate README |
| 33 | + run: | |
| 34 | + chmod +x scripts/update-readme.sh |
| 35 | + ./scripts/update-readme.sh |
| 36 | + - name: Ensure README is committed |
| 37 | + run: | |
| 38 | + git diff --exit-code -- README.md |
| 39 | +
|
| 40 | + duplicate-problem-detector: |
| 41 | + name: Duplicate Problem Detector |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + - name: Detect duplicate problem names |
| 46 | + run: | |
| 47 | + chmod +x scripts/check-duplicate-problems.sh |
| 48 | + ./scripts/check-duplicate-problems.sh |
| 49 | +
|
| 50 | + swift-build-test: |
| 51 | + name: Swift Build And Test |
| 52 | + runs-on: macos-latest |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v4 |
| 55 | + - name: Build and test project |
| 56 | + shell: bash |
| 57 | + run: | |
| 58 | + set -euo pipefail |
| 59 | + project="Algorithm Solutions In Swift.xcodeproj" |
| 60 | + list_output="$(xcodebuild -list -project "$project")" |
| 61 | + echo "$list_output" |
| 62 | +
|
| 63 | + if echo "$list_output" | sed -n '/Schemes:/,$p' | grep -Fq "Algorithm Solutions In Swift"; then |
| 64 | + xcodebuild \ |
| 65 | + -project "$project" \ |
| 66 | + -scheme "Algorithm Solutions In Swift" \ |
| 67 | + -destination "platform=macOS" \ |
| 68 | + build test |
| 69 | + else |
| 70 | + xcodebuild -project "$project" -target "Algorithm Solutions In Swift" build |
| 71 | + xcodebuild -project "$project" -target "Algorithm Solutions In Swift Tests" build |
| 72 | + fi |
| 73 | +
|
| 74 | + swift-format-lint-check: |
| 75 | + name: Swift Format And Lint Check |
| 76 | + runs-on: macos-latest |
| 77 | + continue-on-error: true |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v4 |
| 80 | + - name: Run style checks |
| 81 | + run: | |
| 82 | + chmod +x scripts/check-swift-style.sh |
| 83 | + ./scripts/check-swift-style.sh |
| 84 | +
|
| 85 | + link-health: |
| 86 | + name: Link Health |
| 87 | + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' |
| 88 | + runs-on: ubuntu-latest |
| 89 | + continue-on-error: true |
| 90 | + steps: |
| 91 | + - uses: actions/checkout@v4 |
| 92 | + - name: Check README links |
| 93 | + uses: lycheeverse/lychee-action@v2 |
| 94 | + with: |
| 95 | + fail: true |
| 96 | + args: --no-progress --max-concurrency 8 --timeout 20 --accept 200,429,403 README.md |
| 97 | + env: |
| 98 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 99 | + |
| 100 | + codeql: |
| 101 | + name: CodeQL |
| 102 | + runs-on: macos-latest |
| 103 | + permissions: |
| 104 | + actions: read |
| 105 | + contents: read |
| 106 | + security-events: write |
| 107 | + strategy: |
| 108 | + fail-fast: false |
| 109 | + matrix: |
| 110 | + language: |
| 111 | + - swift |
| 112 | + steps: |
| 113 | + - uses: actions/checkout@v4 |
| 114 | + - name: Initialize CodeQL |
| 115 | + uses: github/codeql-action/init@v3 |
| 116 | + with: |
| 117 | + languages: ${{ matrix.language }} |
| 118 | + - name: Build for CodeQL |
| 119 | + shell: bash |
| 120 | + run: | |
| 121 | + set -euo pipefail |
| 122 | + project="Algorithm Solutions In Swift.xcodeproj" |
| 123 | + list_output="$(xcodebuild -list -project "$project")" |
| 124 | +
|
| 125 | + if echo "$list_output" | sed -n '/Schemes:/,$p' | grep -Fq "Algorithm Solutions In Swift"; then |
| 126 | + xcodebuild \ |
| 127 | + -project "$project" \ |
| 128 | + -scheme "Algorithm Solutions In Swift" \ |
| 129 | + -destination "platform=macOS" \ |
| 130 | + build |
| 131 | + else |
| 132 | + xcodebuild -project "$project" -target "Algorithm Solutions In Swift" build |
| 133 | + fi |
| 134 | + - name: Analyze with CodeQL |
| 135 | + uses: github/codeql-action/analyze@v3 |
0 commit comments