From 6910fb3efedc8278450e28eee07425c6879780ad Mon Sep 17 00:00:00 2001 From: Adam Young Date: Wed, 27 Mar 2024 09:08:31 +0000 Subject: [PATCH] CONFIG: CI workflow improvements (#161) --- .github/workflows/ci-documentation.yml | 24 ---------------- .github/workflows/ci.yml | 15 ++++++---- .github/workflows/codeql.yml | 5 ++-- .github/workflows/documentation.yml | 13 +++++++-- .github/workflows/integration.yml | 3 +- .github/workflows/lint-markdown.yml | 2 +- .github/workflows/lint.yml | 8 +++--- Makefile | 39 +++++++++++++++----------- 8 files changed, 52 insertions(+), 57 deletions(-) delete mode 100644 .github/workflows/ci-documentation.yml diff --git a/.github/workflows/ci-documentation.yml b/.github/workflows/ci-documentation.yml deleted file mode 100644 index 1485dd02..00000000 --- a/.github/workflows/ci-documentation.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Documentation CI - -on: - pull_request: - branches: - - main - workflow_dispatch: - -concurrency: - group: "ci-documentation-${{ github.head_ref || github.run_id }}" - cancel-in-progress: true - -jobs: - build-documentation: - name: Build Documentation - runs-on: ubuntu-latest - env: - SWIFTCI_DOCC: 1 - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Build - run: swift package generate-documentation --product TMDb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7bf6d1e..096c98f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,7 @@ concurrency: env: DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer + BUILD_JOB_COUNT: 4 jobs: build-test: @@ -28,13 +29,13 @@ jobs: uses: actions/checkout@v4 - name: Build - run: swift build -Xswiftc -warnings-as-errors --build-tests + run: swift build --build-tests --jobs ${{ env.BUILD_JOB_COUNT }} -Xswiftc -warnings-as-errors - name: Test run: swift test --skip-build --parallel --filter TMDbTests - name: Build for Release - run: swift build -c release -Xswiftc -warnings-as-errors + run: swift build -c release --jobs ${{ env.BUILD_JOB_COUNT }} -Xswiftc -warnings-as-errors build-and-test-platforms: name: Build and Test (${{ matrix.name }}) @@ -49,15 +50,17 @@ jobs: destination: platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.2 - name: tvOS destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.2 + - name: visionOS + destination: platform=visionOS Simulator,name=Apple Vision Pro,OS=1.0 steps: - name: Checkout uses: actions/checkout@v4 - name: Build - run: set -o pipefail && env NSUnbufferedIO=YES && xcodebuild build-for-testing -scheme TMDb -only-testing TMDbTests -destination '${{ matrix.destination }}' | xcpretty + run: set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme TMDb -only-testing TMDbTests -destination '${{ matrix.destination }}' -parallelizeTargets 2>&1 | xcbeautify - name: Test - run: set -o pipefail && env NSUnbufferedIO=YES && xcodebuild test-without-building -scheme TMDb -only-testing TMDbTests -destination '${{ matrix.destination }}' | xcpretty + run: set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme TMDb -only-testing TMDbTests -destination '${{ matrix.destination }}' -parallel-testing-enabled YES 2>&1 | xcbeautify build-test-linux: name: Build and Test (Linux) @@ -68,10 +71,10 @@ jobs: uses: actions/checkout@v4 - name: Build - run: swift build -Xswiftc -warnings-as-errors --build-tests + run: swift build --build-tests --jobs ${{ env.BUILD_JOB_COUNT }} -Xswiftc -warnings-as-errors - name: Test run: swift test --skip-build --parallel --filter TMDbTests - name: Build for Release - run: swift build -c release -Xswiftc -warnings-as-errors + run: swift build -c release --jobs ${{ env.BUILD_JOB_COUNT }} -Xswiftc -warnings-as-errors diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 2430ce10..67be7746 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -18,6 +18,7 @@ concurrency: env: DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer + BUILD_JOB_COUNT: 4 jobs: analyze: @@ -39,9 +40,9 @@ jobs: config-file: ./.github/codeql/codeql-config.yml - name: Build - run: swift build --build-tests + run: swift build --build-tests --jobs ${{ env.BUILD_JOB_COUNT }} - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 with: - category: "/language:swift" \ No newline at end of file + category: "/language:swift" diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 8fc84310..b66c738e 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -1,6 +1,9 @@ name: Documentation on: + pull_request: + branches: + - main push: branches: - main @@ -33,22 +36,26 @@ jobs: - name: Build documentation run: | - swift package --allow-writing-to-directory docs \ - generate-documentation --target TMDb \ + swift package \ + --allow-writing-to-directory docs \ + generate-documentation \ + --target TMDb \ --disable-indexing \ --transform-for-static-hosting \ - --hosting-base-path TMDb \ + --hosting-base-path tmdb \ --output-path docs env: SWIFTCI_DOCC: 1 - name: Upload documentation + if: github.ref == 'refs/heads/main' uses: actions/upload-pages-artifact@v3 with: path: 'docs' deploy: name: Deploy + if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest needs: build environment: diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index ad68cc2b..364b453a 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -21,6 +21,7 @@ concurrency: env: DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer + BUILD_JOB_COUNT: 4 jobs: integration-test: @@ -31,7 +32,7 @@ jobs: uses: actions/checkout@v4 - name: Build - run: swift build --build-tests + run: swift build --build-tests --jobs ${{ env.BUILD_JOB_COUNT }} - name: Test run: swift test --skip-build --filter TMDbIntegrationTests diff --git a/.github/workflows/lint-markdown.yml b/.github/workflows/lint-markdown.yml index 4a1b0b65..3de19fd3 100644 --- a/.github/workflows/lint-markdown.yml +++ b/.github/workflows/lint-markdown.yml @@ -9,7 +9,7 @@ on: - main paths: - ".github/workflows/lint-markdown.yml" - - "**/*.swift" + - "**/*.md" workflow_dispatch: concurrency: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4dd5a96f..297a0e6b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,8 +17,8 @@ concurrency: cancel-in-progress: true jobs: - swiftlint: - name: Swiftlint + swiftLint: + name: SwiftLint runs-on: ubuntu-latest container: image: docker://ghcr.io/realm/swiftlint:0.53.0 @@ -29,7 +29,7 @@ jobs: - name: Swiftlint run: swiftlint --strict --reporter github-actions-logging - swiftformat: + swiftFormat: name: SwiftFormat runs-on: ubuntu-latest container: @@ -39,4 +39,4 @@ jobs: uses: actions/checkout@v4 - name: SwiftFormat - run: swiftformat --lint . + run: swiftformat --lint --reporter github-actions-log . diff --git a/Makefile b/Makefile index b0c6bb3d..5af88316 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,9 @@ INTEGRATION_TEST_TARGET = TMDbIntegrationTests IOS_DESTINATION = 'platform=iOS Simulator,name=iPhone 15,OS=17.2' WATCHOS_DESINTATION = 'platform=watchOS Simulator,name=Apple Watch Series 9 (45mm),OS=10.2' -TVOS_DESTINATION = 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.2' +TVOS_DESTINATION = 'platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=17.2' +VISIONOS_DESTINATION = 'platform=visionOS Simulator,name=Apple Vision Pro,OS=1.1' +BUILD_JOB_COUNT = 4 SWIFT_CONTAINER_IMAGE = swift:5.9.2-jammy @@ -30,19 +32,19 @@ lint-markdown: .PHONY: build build: - swift build + swift build --jobs 4 -Xswiftc -warnings-as-errors .PHONY: build-linux build-linux: - docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -Xswiftc -warnings-as-errors" + docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build --jobs $(BUILD_JOB_COUNT) -Xswiftc -warnings-as-errors" .PHONY: build-release build-release: - swift build -c release -Xswiftc -warnings-as-errors + swift build -c release --jobs 4 -Xswiftc -warnings-as-errors .PHONY: build-linux-release build-linux-release: - docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -c release -Xswiftc -warnings-as-errors" + docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -c release --jobs $(BUILD_JOB_COUNT) -Xswiftc -warnings-as-errors" .PHONY: build-docs build-docs: @@ -64,35 +66,40 @@ generate-docs: .PHONY: test test: - swift build -Xswiftc -warnings-as-errors --build-tests - swift test --skip-build --filter $(TEST_TARGET) + swift build --build-tests --jobs $(BUILD_JOB_COUNT) -Xswiftc -warnings-as-errors + swift test --skip-build --parallel --filter $(TEST_TARGET) .PHONY: test-ios test-ios: - xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION) - xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION) + set -o pipefail && NSUnbufferedIO=YES xcodebuild clean build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION) -parallelizeTargets 2>&1 | xcbeautify + set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(IOS_DESTINATION) -parallel-testing-enabled YES 2>&1 | xcbeautify .PHONY: test-watchos test-watchos: - xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION) - xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION) + set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION) -parallelizeTargets 2>&1 | xcbeautify + set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(WATCHOS_DESINTATION) -parallel-testing-enabled YES 2>&1 | xcbeautify .PHONY: test-tvos test-tvos: - xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION) - xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION) + set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION) -parallelizeTargets 2>&1 | xcbeautify + set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(TVOS_DESTINATION) -parallel-testing-enabled YES 2>&1 | xcbeautify + +.PHONY: test-visionos +test-visionos: + set -o pipefail && NSUnbufferedIO=YES xcodebuild build-for-testing -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(VISIONOS_DESTINATION) -parallelizeTargets 2>&1 | xcbeautify + set -o pipefail && NSUnbufferedIO=YES xcodebuild test-without-building -scheme $(TARGET) -only-testing $(TEST_TARGET) -destination $(VISIONOS_DESTINATION) -parallel-testing-enabled YES 2>&1 | xcbeautify .PHONY: test-linux test-linux: - docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build -Xswiftc -warnings-as-errors --build-tests && swift test --skip-build --filter $(TEST_TARGET)" + docker run --rm -v "$${PWD}:/workspace" -w /workspace $(SWIFT_CONTAINER_IMAGE) /bin/bash -cl "swift build --build-tests --jobs $(BUILD_JOB_COUNT) -Xswiftc -warnings-as-errors && swift test --skip-build --filter $(TEST_TARGET)" .PHONY: integration-test integration-test: .check-env-vars - swift build --build-tests + swift build --build-tests --jobs $(BUILD_JOB_COUNT) swift test --skip-build --filter $(INTEGRATION_TEST_TARGET) .PHONY: ci -ci: .check-env-vars lint lint-markdown test test-ios test-watchos test-tvos test-linux integration-test build-release build-docs +ci: .check-env-vars lint lint-markdown test test-ios test-watchos test-tvos test-visionos test-linux integration-test build-release build-docs .check-env-vars: @test $${TMDB_API_KEY?Please set environment variable TMDB_API_KEY}