Skip to content

Commit

Permalink
CONFIG: CI workflow improvements (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamayoung authored Mar 27, 2024
1 parent 41f2630 commit 6910fb3
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 57 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/ci-documentation.yml

This file was deleted.

15 changes: 9 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ concurrency:

env:
DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
BUILD_JOB_COUNT: 4

jobs:
build-test:
Expand All @@ -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 }})
Expand All @@ -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)
Expand All @@ -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
5 changes: 3 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ concurrency:

env:
DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
BUILD_JOB_COUNT: 4

jobs:
analyze:
Expand All @@ -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"
category: "/language:swift"
13 changes: 10 additions & 3 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Documentation

on:
pull_request:
branches:
- main
push:
branches:
- main
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ concurrency:

env:
DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
BUILD_JOB_COUNT: 4

jobs:
integration-test:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- main
paths:
- ".github/workflows/lint-markdown.yml"
- "**/*.swift"
- "**/*.md"
workflow_dispatch:

concurrency:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Swiftlint
run: swiftlint --strict --reporter github-actions-logging

swiftformat:
swiftFormat:
name: SwiftFormat
runs-on: ubuntu-latest
container:
Expand All @@ -39,4 +39,4 @@ jobs:
uses: actions/checkout@v4

- name: SwiftFormat
run: swiftformat --lint .
run: swiftformat --lint --reporter github-actions-log .
39 changes: 23 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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}
Expand Down

0 comments on commit 6910fb3

Please sign in to comment.