From 6000206a7aa6b9a56d8a175762e0c6e15adcafa5 Mon Sep 17 00:00:00 2001 From: Vladislav Tarasevich Date: Tue, 14 Oct 2025 17:06:51 +0300 Subject: [PATCH 1/8] Update workflow to run on ubuntu --- .github/workflows/ci.yml | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6454e914..03b975fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,36 +8,37 @@ on: workflow_dispatch: jobs: - test: - name: Swift ${{ matrix.swift }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} + run-exercises-tests: + name: Swift ${{ matrix.swift }} on Ubuntu + runs-on: ubuntu-24.04 strategy: matrix: - os: [macos-15] - swift: ["6.1"] + swift: ["6.0", "6.1", "6.2"] + container: + image: swift:${{ matrix.swift }} env: RUNALL: "true" steps: - - uses: swift-actions/setup-swift@v2 - with: - swift-version: ${{ matrix.swift }} - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - name: Run tests run: swift test - generator-tests: - runs-on: macos-15 - env: - RUNALL: "true" + run-generator-unit-tests: + runs-on: ubuntu-24.04 + container: + image: swift:6.2 steps: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - name: Run tests run: swift test --package-path ./generator - generator-template-tests: - runs-on: macos-15 + + run-generator-usage-tests: + runs-on: ubuntu-24.04 + container: + image: swift:6.2 steps: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 From d18758f6e90ea9345fc5bb620b7ac0dfa823d86c Mon Sep 17 00:00:00 2001 From: Vladislav Tarasevich Date: Tue, 14 Oct 2025 17:20:54 +0300 Subject: [PATCH 2/8] return to 22.04, jq now installed? --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03b975fe..e40a4060 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ on: jobs: run-exercises-tests: name: Swift ${{ matrix.swift }} on Ubuntu - runs-on: ubuntu-24.04 + runs-on: ubuntu-22.04 strategy: matrix: swift: ["6.0", "6.1", "6.2"] @@ -25,7 +25,7 @@ jobs: run: swift test run-generator-unit-tests: - runs-on: ubuntu-24.04 + runs-on: ubuntu-22.04 container: image: swift:6.2 steps: @@ -36,7 +36,7 @@ jobs: run: swift test --package-path ./generator run-generator-usage-tests: - runs-on: ubuntu-24.04 + runs-on: ubuntu-22.04 container: image: swift:6.2 steps: From c472ef2b454aa028bc2ae1aa90ecf023abd4ece0 Mon Sep 17 00:00:00 2001 From: Vladislav Tarasevich Date: Tue, 14 Oct 2025 18:09:17 +0300 Subject: [PATCH 3/8] setup jq --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e40a4060..3993cce5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,5 +43,8 @@ jobs: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - name: 'Setup jq' + uses: dcarbone/install-jq-action@b7ef57d46ece78760b4019dbc4080a1ba2a40b45 + - name: Run tests run: ./bin/test_generator.sh From 709a020a5c69dc67bbc9be9418cabdf9c13b56a0 Mon Sep 17 00:00:00 2001 From: Vladislav Tarasevich Date: Tue, 14 Oct 2025 18:46:59 +0300 Subject: [PATCH 4/8] Don't use jq, fix workflow, add macOS test for generator CLI --- .github/workflows/ci.yml | 35 ++++++++++++++++++++++-------- bin/test_generator.sh | 47 ++++++++++++++++++++++++++++------------ 2 files changed, 59 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3993cce5..80ebd4b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ on: jobs: run-exercises-tests: name: Swift ${{ matrix.swift }} on Ubuntu - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: matrix: swift: ["6.0", "6.1", "6.2"] @@ -25,7 +25,7 @@ jobs: run: swift test run-generator-unit-tests: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 container: image: swift:6.2 steps: @@ -36,15 +36,32 @@ jobs: run: swift test --package-path ./generator run-generator-usage-tests: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 container: image: swift:6.2 steps: - name: Checkout code - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - - name: 'Setup jq' - uses: dcarbone/install-jq-action@b7ef57d46ece78760b4019dbc4080a1ba2a40b45 - - - name: Run tests + uses: actions/checkout@v4 + - name: Run generator tests run: ./bin/test_generator.sh + + run-generator-usage-tests-macos: + name: Swift on macOS ${{ matrix.macOS }} with Xcode ${{ matrix.xcode }} + runs-on: macos-${{ matrix.macOS }} + strategy: + matrix: + include: + - macOS: '14' + xcode: '16.2' + - macOS: '15' + xcode: '16.4' + - macOS: '26' + xcode: '26.0' + env: + RUNALL: "true" + DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - name: Run generator tests + run: ./bin/test_generator.sh \ No newline at end of file diff --git a/bin/test_generator.sh b/bin/test_generator.sh index 36b31071..edd2aedc 100755 --- a/bin/test_generator.sh +++ b/bin/test_generator.sh @@ -1,23 +1,42 @@ #!/usr/bin/env bash -set -eo pipefail +set -euo pipefail -temp=$(mktemp -d) +declare TEMP_DIR +TEMP_DIR=$(mktemp -d) + +readonly TEMP_DIR +readonly GENERATOR_DIR="./generator" +readonly PRACTICE_DIR="./exercises/practice" +readonly TEMPLATE_PATH=".meta/template.swift" swift build --package-path ./generator -for exercise in ./exercises/practice/*; do - if [[ -r "${exercise}/.meta/template.swift" ]]; then - cp -r "$exercise" "$temp" - test_file="${exercise}/$(jq -r '.files.test[0]' ${exercise}/.meta/config.json)" - temp_test_file="${temp}/$(basename "$exercise")/$(jq -r '.files.test[0]' ${exercise}/.meta/config.json)" - swift run --package-path ./generator Generator $(basename "$exercise") "$temp/$(basename "$exercise")" - echo "Comparing $test_file with $temp_test_file" - diff "$temp_test_file" "$test_file" - if [ $? -ne 0 ]; then - exit_code=1 - fi +exit_code=0 +for exercise_path in "${PRACTICE_DIR}"/*; do + [[ -e "${exercise_path}/${TEMPLATE_PATH}" ]] || continue + + cp -r "${exercise_path}"/. "${TEMP_DIR}" + + # Minify json and extract test file name + test_file=$(tr -d '\n\r ' < "${exercise_path}"/.meta/config.json | grep -o '"test":\["[^"]*' | sed 's/.*\["//') + original_test="${exercise_path}/${test_file}" + temp_test="${TEMP_DIR}/${test_file}" + + exercise_name="${exercise_path##*/}" + + if ! swift run --package-path "${GENERATOR_DIR}" Generator "${exercise_name}" "${TEMP_DIR}"; then + printf 'Generation failed for %s\n' "${exercise_name}" + exit_code=1 + continue + fi + + if ! diff -u -- "${original_test}" "${temp_test}"; then + printf 'Mismatch detected in %s\n' "${exercise_name}" + exit_code=1 + else + printf '%s OK\n' "${exercise_name}" fi done -exit ${exit_code} +exit "${exit_code}" \ No newline at end of file From 48da557fa7f76aa46754640af811915787c77d55 Mon Sep 17 00:00:00 2001 From: Vladislav Tarasevich Date: Tue, 14 Oct 2025 18:55:47 +0300 Subject: [PATCH 5/8] Add proper names and remove mac os legacy xcodes. --- .github/workflows/ci.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 80ebd4b6..288bcf4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: jobs: run-exercises-tests: - name: Swift ${{ matrix.swift }} on Ubuntu + name: Run exercise tests for swift ${{ matrix.swift }} on Ubuntu runs-on: ubuntu-24.04 strategy: matrix: @@ -25,6 +25,7 @@ jobs: run: swift test run-generator-unit-tests: + name: Run generator unit tests runs-on: ubuntu-24.04 container: image: swift:6.2 @@ -36,6 +37,7 @@ jobs: run: swift test --package-path ./generator run-generator-usage-tests: + name: Test generator usage on Ubuntu runs-on: ubuntu-24.04 container: image: swift:6.2 @@ -46,15 +48,10 @@ jobs: run: ./bin/test_generator.sh run-generator-usage-tests-macos: - name: Swift on macOS ${{ matrix.macOS }} with Xcode ${{ matrix.xcode }} + name: Test generator usage on macOS ${{ matrix.macOS }} with Xcode ${{ matrix.xcode }} runs-on: macos-${{ matrix.macOS }} strategy: matrix: - include: - - macOS: '14' - xcode: '16.2' - - macOS: '15' - xcode: '16.4' - macOS: '26' xcode: '26.0' env: From 614f731b530cdb772957e05bdb5af89ed8b6c143 Mon Sep 17 00:00:00 2001 From: Vladislav Tarasevich Date: Tue, 14 Oct 2025 19:12:24 +0300 Subject: [PATCH 6/8] Adjust workflow --- .github/workflows/ci.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 288bcf4a..add0815b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: jobs: - run-exercises-tests: + run-exercises-tests-ubuntu: name: Run exercise tests for swift ${{ matrix.swift }} on Ubuntu runs-on: ubuntu-24.04 strategy: @@ -24,6 +24,23 @@ jobs: - name: Run tests run: swift test + run-exercises-tests-macos: + name: Run exercise tests on macOS ${{ matrix.macOS }} with Xcode ${{ matrix.xcode }} + runs-on: macos-${{ matrix.macOS }} + strategy: + matrix: + include: + - macOS: '26' + xcode: '26.0' + env: + RUNALL: "true" + DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - name: Run tests + run: swift test + run-generator-unit-tests: name: Run generator unit tests runs-on: ubuntu-24.04 @@ -52,6 +69,7 @@ jobs: runs-on: macos-${{ matrix.macOS }} strategy: matrix: + include: - macOS: '26' xcode: '26.0' env: From 7bac26ef57f3672ca15047a1d80e8f5d441fbb19 Mon Sep 17 00:00:00 2001 From: Vladislav Tarasevich Date: Tue, 14 Oct 2025 19:43:27 +0300 Subject: [PATCH 7/8] Split the ci into two workflows --- .github/workflows/ci_exercises.yml | 42 +++++++++++++++++++ .../workflows/{ci.yml => ci_generator.yml} | 38 ++--------------- 2 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/ci_exercises.yml rename .github/workflows/{ci.yml => ci_generator.yml} (56%) diff --git a/.github/workflows/ci_exercises.yml b/.github/workflows/ci_exercises.yml new file mode 100644 index 00000000..e0575bc3 --- /dev/null +++ b/.github/workflows/ci_exercises.yml @@ -0,0 +1,42 @@ +name: CI + +on: + pull_request: + push: + branches: + - main + workflow_dispatch: + +jobs: + run-exercises-tests-ubuntu: + name: Run exercise tests for swift ${{ matrix.swift }} on Ubuntu + runs-on: ubuntu-24.04 + strategy: + matrix: + swift: ["6.0", "6.1", "6.2"] + container: + image: swift:${{ matrix.swift }} + env: + RUNALL: "true" + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - name: Run tests + run: swift test + + run-exercises-tests-macos: + name: Run exercise tests on macOS ${{ matrix.macOS }} with Xcode ${{ matrix.xcode }} + runs-on: macos-${{ matrix.macOS }} + strategy: + matrix: + include: + - macOS: '26' + xcode: '26.0' + env: + RUNALL: "true" + DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app + steps: + - name: Checkout code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - name: Run tests + run: swift test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci_generator.yml similarity index 56% rename from .github/workflows/ci.yml rename to .github/workflows/ci_generator.yml index add0815b..de587055 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci_generator.yml @@ -2,45 +2,16 @@ name: CI on: pull_request: + paths: + - '.github/workflows/ci_generator.yml' + - 'generator/**' + - 'bin/test_generator.sh' push: branches: - main workflow_dispatch: jobs: - run-exercises-tests-ubuntu: - name: Run exercise tests for swift ${{ matrix.swift }} on Ubuntu - runs-on: ubuntu-24.04 - strategy: - matrix: - swift: ["6.0", "6.1", "6.2"] - container: - image: swift:${{ matrix.swift }} - env: - RUNALL: "true" - steps: - - name: Checkout code - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - name: Run tests - run: swift test - - run-exercises-tests-macos: - name: Run exercise tests on macOS ${{ matrix.macOS }} with Xcode ${{ matrix.xcode }} - runs-on: macos-${{ matrix.macOS }} - strategy: - matrix: - include: - - macOS: '26' - xcode: '26.0' - env: - RUNALL: "true" - DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app - steps: - - name: Checkout code - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - name: Run tests - run: swift test - run-generator-unit-tests: name: Run generator unit tests runs-on: ubuntu-24.04 @@ -49,7 +20,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - - name: Run tests run: swift test --package-path ./generator From ea24b132ee5f833ad19fd5f383179a518c443d2c Mon Sep 17 00:00:00 2001 From: Vladislav Tarasevich Date: Tue, 14 Oct 2025 19:46:27 +0300 Subject: [PATCH 8/8] Fix names --- .github/workflows/ci_exercises.yml | 2 +- .github/workflows/ci_generator.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_exercises.yml b/.github/workflows/ci_exercises.yml index e0575bc3..1f074d08 100644 --- a/.github/workflows/ci_exercises.yml +++ b/.github/workflows/ci_exercises.yml @@ -1,4 +1,4 @@ -name: CI +name: CI Exercises on: pull_request: diff --git a/.github/workflows/ci_generator.yml b/.github/workflows/ci_generator.yml index de587055..2998f33f 100644 --- a/.github/workflows/ci_generator.yml +++ b/.github/workflows/ci_generator.yml @@ -1,4 +1,4 @@ -name: CI +name: CI Generator on: pull_request: