From 490644e027b217fd2dfbee8f6f8d490985b61e6e Mon Sep 17 00:00:00 2001 From: kinarobin Date: Sat, 9 Oct 2021 16:30:38 +0800 Subject: [PATCH] apply github actions --- .github/workflows/CI.yml | 190 +++++++++++++++++++++++++++++++++++++ .travis.yml | 86 ----------------- Tests/Tests/SDUtilsTests.m | 2 +- 3 files changed, 191 insertions(+), 87 deletions(-) create mode 100644 .github/workflows/CI.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 00000000..ebe49170 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,190 @@ +name: "SDWebImage CI" + +on: + push: + branches: + - master + pull_request: + branches: + - '*' + +jobs: + Pods: + name: Cocoapods Lint + runs-on: macos-11 + env: + DEVELOPER_DIR: /Applications/Xcode_13.0.app + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Cocoapods + run: gem install cocoapods --no-document --quiet + + - name: Install Xcpretty + run: gem install xcpretty --no-document --quiet + + - name: Pod Update. + run: pod repo update --silent + + - name: Pod Install. + run: pod install + + - name: Run SDWebImage podspec lint + run: | + set -o pipefail + pod lib lint SDWebImage.podspec --allow-warnings --skip-tests + Demo: + name: Run Demo + runs-on: macos-11 + env: + DEVELOPER_DIR: /Applications/Xcode_13.0.app + WORKSPACE_NAME: SDWebImage.xcworkspace + OSXSCHEME: SDWebImage OSX Demo + iOSSCHEME: SDWebImage iOS Demo + TVSCHEME: SDWebImage TV Demo + WATCHSCHEME: SDWebImage Watch Demo + strategy: + matrix: + iosDestination: ["name=iPhone 13 Pro"] + tvOSDestination: ["name=Apple TV 4K"] + watchOSDestination: ["platform=watchOS Simulator,name=Apple Watch Series 7 - 45mm"] + macOSDestination: ["platform=macOS"] + macCatalystDestination: ["platform=macOS,arch=x86_64,variant=Mac Catalyst"] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Cocoapods + run: gem install cocoapods --no-document --quiet + + - name: Install Xcpretty + run: gem install xcpretty --no-document --quiet + + - name: Pod Update + run: pod repo update --silent + + - name: Pod Install + run: pod install + + - name: Run demo for OSX + run: | + set -o pipefail + xcodebuild build -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.OSXSCHEME }}" -destination "${{ matrix.macOSDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c + + - name: Run demo for iOS + run: | + set -o pipefail + xcodebuild build -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.iOSSCHEME }}" -destination "${{ matrix.iosDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c + + - name: Run demo for TV + run: | + set -o pipefail + xcodebuild build -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.TVSCHEME }}" -destination "${{ matrix.tvOSDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c + + - name: Run demo for Watch + run: | + set -o pipefail + xcodebuild build -workspace "${{ env.WORKSPACE_NAME }}" -scheme "${{ env.WATCHSCHEME }}" -destination "${{ matrix.watchOSDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c + + Test: + name: Unit Test + runs-on: macos-11 + env: + DEVELOPER_DIR: /Applications/Xcode_13.0.app + WORKSPACE_NAME: SDWebImage.xcworkspace + strategy: + matrix: + iosDestination: ["platform=iOS Simulator,name=iPhone 13 Pro"] + macOSDestination: ["platform=macOS,arch=x86_64"] + tvOSDestination: ["platform=tvOS Simulator,name=Apple TV 4K"] + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Cocoapods + run: gem install cocoapods --no-document --quiet + + - name: Install Xcpretty + run: gem install xcpretty --no-document --quiet + + - name: Pod Update + run: pod repo update --silent + + - name: Pod Install + run: pod install + + - name: Clean DerivedData + run: | + rm -rf ~/Library/Developer/Xcode/DerivedData/ + mkdir DerivedData + + - name: Test - ${{ matrix.iosDestination }} + run: | + set -o pipefail + xcodebuild test -workspace "${{ env.WORKSPACE_NAME }}" -scheme "Tests iOS" -destination "${{ matrix.iosDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c + mv ~/Library/Developer/Xcode/DerivedData/ ./DerivedData/iOS + + - name: Test - ${{ matrix.macOSDestination }} + run: | + set -o pipefail + xcodebuild test -workspace "${{ env.WORKSPACE_NAME }}" -scheme "Tests Mac" -destination "${{ matrix.macOSDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c + mv ~/Library/Developer/Xcode/DerivedData/ ./DerivedData/macOS + + - name: Test - ${{ matrix.tvOSDestination }} + run: | + set -o pipefail + xcodebuild test -workspace "${{ env.WORKSPACE_NAME }}" -scheme "Tests TV" -destination "${{ matrix.tvOSDestination }}" -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c + mv ~/Library/Developer/Xcode/DerivedData/ ./DerivedData/tvOS + + - name: Code Coverage + run: | + set -o pipefail + export PATH="/usr/local/opt/curl/bin:$PATH" + curl --version + bash <(curl -s https://codecov.io/bash) -D './DerivedData/macOS' -J '^SDWebImage$' -c -X gcov -F macos + bash <(curl -s https://codecov.io/bash) -D './DerivedData/iOS' -J '^SDWebImage$' -c -X gcov -F ios + bash <(curl -s https://codecov.io/bash) -D './DerivedData/tvOS' -J '^SDWebImage$' -c -X gcov -F tvos + + Build: + name: Build Library + runs-on: macos-11 + env: + DEVELOPER_DIR: /Applications/Xcode_13.0.app + PROJECT_NAME: SDWebImage.xcodeproj + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Cocoapods + run: gem install cocoapods --no-document --quiet + + - name: Install Xcpretty + run: gem install xcpretty --no-document --quiet + + - name: Pod Update + run: pod repo update --silent + + - name: Pod Install + run: pod install + + - name: Build the SwiftPM + run: | + set -o pipefail + swift build + rm -rf ~/.build + + - name: Build as static library + run: | + set -o pipefail + xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "SDWebImage static" -sdk iphonesimulator PLATFORM_NAME=iphonesimulator -configuration Release | xcpretty -c + rm -rf ~/Library/Developer/Xcode/DerivedData/ + - name: Build as dynamic frameworks + run: | + set -o pipefail + xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "SDWebImage" -sdk macosx -configuration Release | xcpretty -c + xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "SDWebImage" -sdk iphonesimulator PLATFORM_NAME=iphonesimulator -configuration Release | xcpretty -c + xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "SDWebImage" -sdk appletvsimulator -configuration Release | xcpretty -c + xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "SDWebImage" -sdk watchsimulator -configuration Release | xcpretty -c + xcodebuild build -project "${{ env.PROJECT_NAME }}" -scheme "SDWebImage" -destination "platform=macOS,arch=x86_64,variant=Mac Catalyst" -configuration Release | xcpretty -c + rm -rf ~/Library/Developer/Xcode/DerivedData/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8edf4473..00000000 --- a/.travis.yml +++ /dev/null @@ -1,86 +0,0 @@ - -language: objective-c -osx_image: xcode13.0 - -env: - global: - - LC_CTYPE=en_US.UTF-8 - - LANG=en_US.UTF-8 - -notifications: - email: false - -addons: - homebrew: - packages: - - curl # Fix the codecov upload issue - -cache: cocoapods -podfile: Podfile - -before_install: - - env - - locale - - gem install cocoapods --no-document --quiet - - gem install xcpretty --no-document --quiet - - pod --version - - pod repo update --silent - - xcpretty --version - - xcodebuild -version - - xcodebuild -showsdks - -script: - - set -o pipefail - - - echo Check if the library described by the podspec can be built - - pod lib lint --allow-warnings --skip-tests # Will run test below - - - echo Build the SwiftPM - - swift build - - rm -rf ~/.build - - - echo Build as static library - - xcodebuild build -project SDWebImage.xcodeproj -scheme 'SDWebImage static' -sdk iphonesimulator PLATFORM_NAME=iphonesimulator -configuration Debug | xcpretty -c - - - echo Clean DerivedData - - rm -rf ~/Library/Developer/Xcode/DerivedData/ - - - echo Build as dynamic frameworks - - xcodebuild build -project SDWebImage.xcodeproj -scheme 'SDWebImage' -sdk macosx -configuration Debug | xcpretty -c - - xcodebuild build -project SDWebImage.xcodeproj -scheme 'SDWebImage' -sdk iphonesimulator PLATFORM_NAME=iphonesimulator -configuration Debug | xcpretty -c - - xcodebuild build -project SDWebImage.xcodeproj -scheme 'SDWebImage' -sdk appletvsimulator -configuration Debug | xcpretty -c - - xcodebuild build -project SDWebImage.xcodeproj -scheme 'SDWebImage' -sdk watchsimulator -configuration Debug | xcpretty -c - - xcodebuild build -project SDWebImage.xcodeproj -scheme 'SDWebImage' -destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst' -configuration Debug | xcpretty -c - - xcodebuild build -project SDWebImage.xcodeproj -scheme 'SDWebImageMapKit' -sdk macosx -configuration Debug | xcpretty -c - - xcodebuild build -project SDWebImage.xcodeproj -scheme 'SDWebImageMapKit' -sdk iphonesimulator PLATFORM_NAME=iphonesimulator -configuration Debug | xcpretty -c - - xcodebuild build -project SDWebImage.xcodeproj -scheme 'SDWebImageMapKit' -sdk appletvsimulator -configuration Debug | xcpretty -c - - xcodebuild build -project SDWebImage.xcodeproj -scheme 'SDWebImageMapKit' -destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst' -configuration Debug | xcpretty -c - - - echo Build the Demo apps - - pod install - - xcodebuild build -workspace SDWebImage.xcworkspace -scheme 'SDWebImage OSX Demo' -destination 'platform=macOS,arch=x86_64' -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c - - xcodebuild build -workspace SDWebImage.xcworkspace -scheme 'SDWebImage iOS Demo' -destination 'platform=iOS Simulator,name=iPhone 11 Pro' -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c - - xcodebuild build -workspace SDWebImage.xcworkspace -scheme 'SDWebImage TV Demo' -destination 'platform=tvOS Simulator,name=Apple TV 4K' -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c - - xcodebuild build -workspace SDWebImage.xcworkspace -scheme 'SDWebImage Watch Demo' -destination 'platform=iOS Simulator,name=iPhone 11 Pro' -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c - - xcodebuild build -workspace SDWebImage.xcworkspace -scheme 'SDWebImage iOS Demo' -destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst' -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c - - - mkdir DerivedData - - mv ~/Library/Developer/Xcode/DerivedData/ ./DerivedData/common - - - echo Run the tests - - xcodebuild test -workspace SDWebImage.xcworkspace -scheme 'Tests iOS' -destination 'platform=iOS Simulator,name=iPhone 11 Pro' -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c - - mv ~/Library/Developer/Xcode/DerivedData/ ./DerivedData/iOS - - cp -R ./DerivedData/common ~/Library/Developer/Xcode/DerivedData - - xcodebuild test -workspace SDWebImage.xcworkspace -scheme 'Tests Mac' -destination 'platform=macOS,arch=x86_64' -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c - - mv ~/Library/Developer/Xcode/DerivedData/ ./DerivedData/macOS - - cp -R ./DerivedData/common ~/Library/Developer/Xcode/DerivedData - - xcodebuild test -workspace SDWebImage.xcworkspace -scheme 'Tests TV' -destination 'platform=tvOS Simulator,name=Apple TV' -configuration Debug CODE_SIGNING_ALLOWED=NO | xcpretty -c - - mv ~/Library/Developer/Xcode/DerivedData/ ./DerivedData/tvOS - - cp -R ./DerivedData/common ~/Library/Developer/Xcode/DerivedData - -after_success: - - export PATH="/usr/local/opt/curl/bin:$PATH" - - curl --version - - bash <(curl -s https://codecov.io/bash) -D './DerivedData/macOS' -J '^SDWebImage$' -c -X gcov -F macos - - bash <(curl -s https://codecov.io/bash) -D './DerivedData/iOS' -J '^SDWebImage$' -c -X gcov -F ios - - bash <(curl -s https://codecov.io/bash) -D './DerivedData/tvOS' -J '^SDWebImage$' -c -X gcov -F tvos diff --git a/Tests/Tests/SDUtilsTests.m b/Tests/Tests/SDUtilsTests.m index 5b59c74c..e67f72ca 100644 --- a/Tests/Tests/SDUtilsTests.m +++ b/Tests/Tests/SDUtilsTests.m @@ -72,7 +72,7 @@ - (void)displayLinkDidRefresh:(SDDisplayLink *)displayLink { NSTimeInterval duration = displayLink.duration; // Running value - expect(duration).beGreaterThan(0.01); + expect(duration).beGreaterThan(0.001); /// 60Hz ~ 120Hz expect(duration).beLessThan(0.02); }