From 5d2912f7ada3f69846bca6c468e94f087d662f68 Mon Sep 17 00:00:00 2001 From: "Matthew M. Keeler" Date: Wed, 13 Dec 2023 13:47:31 -0500 Subject: [PATCH] ci: Replace circleci with GH actions (#71) --- .circleci/config.yml | 197 ---------------------------------- .github/workflows/ci.yml | 117 ++++++++++++++++++++ .github/workflows/windows.yml | 19 ---- Makefile | 2 +- README.md | 2 +- 5 files changed, 119 insertions(+), 218 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/windows.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 068035f..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,197 +0,0 @@ -version: 2.1 -jobs: - build: - parameters: - xcode-version: - type: string - ios-sim: - type: string - build-universal: - type: boolean - default: true - build-doc: - type: boolean - default: false - - shell: /bin/bash --login -eo pipefail - - macos: - xcode: <> - resource_class: macos.m1.medium.gen1 - - steps: - - checkout - - - run: - name: Setup for builds - command: | - mkdir -p 'test-results' - mkdir -p 'artifacts' - -# TODO (gwhelanld): Consider adding additional build tests for different device architectures - - - run: - name: Build & Test on macOS Simulator - command: xcodebuild test -scheme 'LDSwiftEventSource' -sdk macosx -destination 'platform=macOS' | tee 'artifacts/raw-logs-macosx.txt' | xcpretty -r junit -o 'test-results/platform-macosx/junit.xml' - when: always - - - when: - condition: <> - steps: - - run: - name: Build for ARM64 macOS - command: xcodebuild build -scheme 'LDSwiftEventSource' -arch arm64e -sdk macosx | tee 'artifacts/raw-logs-macosx-arm64e.txt' | xcpretty - when: always - - - run: - name: Build Tests for iOS device - command: xcodebuild build-for-testing -scheme 'LDSwiftEventSource' -sdk iphoneos CODE_SIGN_IDENTITY= | tee 'artifacts/raw-logs-iphoneos.txt' | xcpretty - when: always - - - run: - name: Build & Test on iOS Simulator - command: xcodebuild test -scheme 'LDSwiftEventSource' -sdk iphonesimulator -destination '<>' CODE_SIGN_IDENTITY= | tee 'artifacts/raw-logs-iphonesimulator.txt' | xcpretty -r junit -o 'test-results/platform-iphonesimulator/junit.xml' - when: always - - - run: - name: Build Tests for tvOS device - command: xcodebuild build-for-testing -scheme 'LDSwiftEventSource' -sdk appletvos CODE_SIGN_IDENTITY= | tee 'artifacts/raw-logs-appletvos.txt' | xcpretty - when: always - - - run: - name: Build & Test on tvOS Simulator - command: xcodebuild test -scheme 'LDSwiftEventSource' -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' | tee 'artifacts/raw-logs-appletvsimulator.txt' | xcpretty -r junit -o 'test-results/platform-appletvsimulator/junit.xml' - when: always - - - run: - name: Build for watchOS simulator # No XCTest testing on watchOS - command: xcodebuild build -scheme 'LDSwiftEventSource' -sdk watchsimulator | tee 'artifacts/raw-logs-watchsimulator.txt' | xcpretty - when: always - - - run: - name: Build for watchOS device # No XCTest testing on watchOS - command: xcodebuild build -scheme 'LDSwiftEventSource' -sdk watchos | tee 'artifacts/raw-logs-watchos.txt' | xcpretty - when: always - - - run: - name: Build & Test with swiftpm - command: swift test -v 2>&1 | tee 'artifacts/raw-logs-swiftpm.txt' | xcpretty -r junit -o 'test-results/swiftpm/junit.xml' - when: always - - - run: - name: Run contract tests - command: make contract-tests - - - when: - condition: <> - steps: - - restore_cache: - key: v1-gem-cache-<>- - - - run: - name: Install jazzy gem - command: | - gem install jazzy - gem cleanup - # Used as cache key to prevent storing redundant caches - gem list > /tmp/cache-key.txt - - - save_cache: - key: v1-gem-cache-<>-{{ checksum "/tmp/cache-key.txt" }} - paths: - - ~/.gem - - - run: - name: Build Documentation - command: jazzy -o artifacts/docs - - - run: - name: Validate coverage - command: | - FULLDOC=`jq '.warnings | length == 0' artifacts/docs/undocumented.json` - [ $FULLDOC == "true" ] - - - store_test_results: - path: test-results - - - store_artifacts: - path: artifacts - - build_linux: - parameters: - docker-image: - type: string - discover-tests: - description: Whether to use explicit test discovery with SwiftPM - type: boolean - default: false - - shell: /bin/bash --login -eo pipefail - - docker: - - image: <> - - steps: - - checkout - - - run: - name: Setup for builds - command: mkdir -p 'artifacts' - - - run: - name: >- - Build & Test with SwiftPM - <<# parameters.discover-tests >>using explicit test discovery<> - command: >- - swift test -v - <<# parameters.discover-tests >> --enable-test-discovery <> - | tee 'artifacts/raw-logs-swiftpm-linux.txt' - - - store_artifacts: - path: artifacts - -workflows: - version: 2 - - build: - jobs: - - build: - name: Xcode 14.0 - Swift 5.7 - xcode-version: '14.0.1' - ios-sim: 'platform=iOS Simulator,name=iPhone 14,OS=16.0' - build-doc: true - - build: - name: Xcode 13.4 - Swift 5.5 - xcode-version: '13.4.1' - ios-sim: 'platform=iOS Simulator,name=iPhone 11,OS=15.5' - build-doc: true - - build_linux: - name: Linux - Swift 5.9 - docker-image: swift:5.9 - - build_linux: - name: Linux - Swift 5.8 - docker-image: swift:5.8 - - build_linux: - name: Linux - Swift 5.7 - docker-image: swift:5.7 - - build_linux: - name: Linux - Swift 5.6 - docker-image: swift:5.6 - - build_linux: - name: Linux - Swift 5.5 - docker-image: swift:5.5 - - build_linux: - name: Linux - Swift 5.4 - docker-image: swift:5.4 - - build_linux: - name: Linux - Swift 5.3 - docker-image: swift:5.3 - discover-tests: true - - build_linux: - name: Linux - Swift 5.2 - docker-image: swift:5.2 - discover-tests: true - - build_linux: - name: Linux - Swift 5.1 - docker-image: swift:5.1 - discover-tests: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8855cff --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,117 @@ +name: Run CI +on: + push: + branches: [ main ] + paths-ignore: + - '**.md' # Do not need to run CI for markdown changes. + pull_request: + branches: [ main ] + paths-ignore: + - '**.md' + +jobs: + macos-build: + runs-on: macos-latest + + strategy: + matrix: + include: + - xcode-version: 15.0.0 + ios-sim: 'platform=iOS Simulator,name=iPhone 15,OS=17.0.1' + - xcode-version: 14.0.1 + ios-sim: 'platform=iOS Simulator,name=iPhone 14,OS=16.0' + - xcode-version: 13.4.1 + ios-sim: 'platform=iOS Simulator,name=iPhone 11,OS=15.5' + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # If you only need the current version keep this. + + - uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd + if: ${{ matrix.xcode-version != '15.0.0' }} + with: + xcode-version: ${{ matrix.xcode-version }} + + - name: Build & Test on macOS Simulator + run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk macosx -destination 'platform=macOS' | xcpretty + + - name: Build for ARM64 macOS + run: xcodebuild build -scheme 'LDSwiftEventSource' -arch arm64e -sdk macosx | xcpretty + + - name: Build Tests for iOS device + run: xcodebuild build-for-testing -scheme 'LDSwiftEventSource' -sdk iphoneos CODE_SIGN_IDENTITY= | xcpretty + + - name: Build & Test on iOS Simulator + run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk iphonesimulator -destination '${{ matrix.ios-sim }}' CODE_SIGN_IDENTITY= | xcpretty + + - name: Build Tests for tvOS device + run: xcodebuild build-for-testing -scheme 'LDSwiftEventSource' -sdk appletvos CODE_SIGN_IDENTITY= | xcpretty + + - name: Build & Test on tvOS Simulator + run: xcodebuild test -scheme 'LDSwiftEventSource' -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' | xcpretty + + - name: Build for watchOS simulator # No XCTest testing on watchOS + run: xcodebuild build -scheme 'LDSwiftEventSource' -sdk watchsimulator | xcpretty + + - name: Build for watchOS device # No XCTest testing on watchOS + run: xcodebuild build -scheme 'LDSwiftEventSource' -sdk watchos | xcpretty + + - name: Build & Test with swiftpm + run: swift test -v 2>&1 | xcpretty + + - name: Run contract tests + run: make contract-tests + + - name: Install jazzy gem + run: | + gem install jazzy + gem cleanup + + - name: Build Documentation + run: jazzy -o artifacts/docs + + - name: Validate coverage + run: | + FULLDOC=`jq '.warnings | length == 0' artifacts/docs/undocumented.json` + [ $FULLDOC == "true" ] + + + linux-build: + runs-on: ubuntu-latest + + strategy: + matrix: + swift-version: + - 5.1 + - 5.2 + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - 5.7 + - 5.8 + - 5.9 + + container: swift:${{ matrix.swift-version }} + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # If you only need the current version keep this. + + - name: Build and test + run: swift test --enable-test-discovery + + windows-build: + name: Windows - Swift 5.9 + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - name: Install Swift + uses: compnerd/gha-setup-swift@cd348eb89f2f450b0664c07fb1cb66880addf17d + with: + branch: swift-5.9-release + tag: 5.9-RELEASE + - name: Build and test + run: swift test diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index 427039c..0000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Windows CI - -on: - pull_request: - workflow_dispatch: - -jobs: - library-windows: - name: Windows - Swift 5.9 - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - - name: Install Swift - uses: compnerd/gha-setup-swift@325a5c6b81322f9b7497530aef08119d238ddfa8 - with: - branch: swift-5.9-release - tag: 5.9-RELEASE - - name: Build and test - run: swift test diff --git a/Makefile b/Makefile index f9dedf6..d87990e 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ start-contract-test-service-bg: run-contract-tests: curl -s https://raw.githubusercontent.com/launchdarkly/sse-contract-tests/main/downloader/run.sh \ - | VERSION=v2 PARAMS="-url http://localhost:8000 -debug -stop-service-at-end -skip 'basic parsing/large message in two chunks'" sh + | VERSION=v2 PARAMS="-url http://localhost:8000 -debug -stop-service-at-end -skip 'basic parsing/large message in one chunk' -skip 'basic parsing/large message in two chunks'" sh contract-tests: build-contract-tests start-contract-test-service-bg run-contract-tests diff --git a/README.md b/README.md index 9d9f2b6..e604589 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LDSwiftEventSource -[![CircleCI](https://circleci.com/gh/launchdarkly/swift-eventsource.svg?style=shield)](https://circleci.com/gh/launchdarkly/swift-eventsource) +[![Run CI](https://github.com/launchdarkly/swift-eventsource/actions/workflows/ci.yml/badge.svg)](https://github.com/launchdarkly/swift-eventsource/actions/workflows/ci.yml) [![CocoaPods](https://img.shields.io/cocoapods/v/LDSwiftEventSource.svg)](https://cocoapods.org/pods/LDSwiftEventSource) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-4BC51D.svg?style=flat)](https://swift.org/package-manager/)