Skip to content

Commit

Permalink
Move checkout action to main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket committed Aug 16, 2023
1 parent 8c1b570 commit f5179b4
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 109 deletions.
27 changes: 27 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Set up environment
description: Set up the environment for building and testing the library on a given platform

inputs:
xcode:
description: The version of Xcode to use
required: true

runs:
using: composite

steps:
- name: Set Ruby version
run: ruby -e 'puts RUBY_VERSION' | tee .ruby-version
shell: bash

- name: Set up Ruby
uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939
with:
bundler-cache: true
cache-version: 1

- name: Setup Xcode
uses: mxcl/xcodebuild@6e60022a0cbe8c89278be2dd1773a2f68e7c5c87
with:
xcode: ${{ inputs.xcode }}
action: none
60 changes: 0 additions & 60 deletions .github/actions/test.yml

This file was deleted.

53 changes: 53 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Run tests
description: Run library tests for a given platform

inputs:
xcode:
description: The version of Xcode to use
required: true
scheme:
description: The Xcode scheme to use
required: true
platform:
description: The platform to build for
required: true

runs:
using: composite

steps:
- name: Install xcpretty
run: gem install xcpretty
shell: bash

- name: Save Xcode version
run: xcodebuild -version | tee .xcode-version
shell: bash

- id: restore-carthage-cache
name: Restore Carthage cache
uses: actions/cache/restore@v3
with:
path: Carthage
key: carthage-${{ inputs.platform }}-${{ hashFiles('Cartfile.resolved') }}-${{ hashFiles('.xcode-version') }}-v1

- name: Install dependencies
if: steps.restore-carthage-cache.outputs.cache-hit != 'true'
run: carthage bootstrap --platform ${{ inputs.platform }} --use-xcframeworks --no-use-binaries --cache-builds
shell: bash

- name: Save Carthage cache
id: save-carthage-cache
uses: actions/cache/save@v3
if: steps.restore-carthage-cache.outputs.cache-hit != 'true'
with:
path: Carthage
key: carthage-${{ inputs.platform }}-${{ hashFiles('Cartfile.resolved') }}-${{ hashFiles('.xcode-version') }}-v1

- name: Run tests
uses: mxcl/xcodebuild@v2
with:
xcode: ${{ inputs.xcode }}
scheme: ${{ inputs.scheme }}
platform: ${{ inputs.platform }}
code-coverage: true
117 changes: 108 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,112 @@
name: Test
on:
[push]
name: CI
on: push

jobs:
ios:
name: Build and test on iOS
test:
name: Test on ${{ matrix.platform.os }} using Xcode ${{ matrix.xcode }}
runs-on: macos-latest

env:
xcodeproj: Auth0.xcodeproj

strategy:
matrix:
platform:
- { os: iOS, scheme: Auth0.iOS }
- { os: macOS, scheme: Auth0.macOS }
- { os: tvOS, scheme: Auth0.tvOS }
xcode:
- '14.2'

steps:
- uses: ./.github/actions/test
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9

- name: Set up environment
uses: ./.github/actions/setup
with:
xcode: '14.2'
platform: iOS
scheme: Auth0.iOS
xcode: ${{ matrix.xcode }}

- name: Run tests
uses: ./.github/actions/test
with:
xcode: ${{ matrix.xcode }}
scheme: ${{ matrix.platform.scheme }}
platform: ${{ matrix.platform.os }}

- name: Convert coverage report
if: ${{ matrix.platform.os == 'iOS' }}
run: bundle exec slather coverage -x --scheme ${{ matrix.platform.scheme }} ${{ env.xcodeproj }}

- name: Upload coverage report
if: ${{ matrix.platform.os == 'iOS' }}
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d

- name: Cancel wokflow on failure
uses: andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1
if: ${{ failure() }}

test-package:
name: Test Swift package using Xcode ${{ matrix.xcode }}
runs-on: macos-latest

strategy:
matrix:
xcode:
- '14.2'

steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9

- name: Set up environment
uses: ./.github/actions/setup
with:
xcode: ${{ matrix.xcode }}

- name: Run tests
run: swift test

- name: Cancel wokflow on failure
uses: andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1
if: ${{ failure() }}

pod-lint:
name: Lint podspec using Xcode ${{ matrix.xcode }}
runs-on: macos-latest

strategy:
matrix:
xcode:
- '14.2'

steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9

- name: Set up environment
uses: ./.github/actions/setup
with:
xcode: ${{ matrix.xcode }}

- name: Run pod lib lint
run: bundle exec pod lib lint --allow-warnings --fail-fast

- name: Cancel wokflow on failure
uses: andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1
if: ${{ failure() }}

swiftlint:
name: Lint code with Swiftlint
runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9

- name: Run Swiftlint
run: swiftlint lint --reporter github-actions-logging

- name: Cancel wokflow on failure
uses: andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1
if: ${{ failure() }}
14 changes: 7 additions & 7 deletions Auth0.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n\nif which swiftlint > /dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
shellScript = "if [ -z ${CI} ]; then\n if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\n fi\n\n if which swiftlint > /dev/null; then\n swiftlint\n else\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\n fi\nfi\n";
};
5B717B251E2E26B9004A05A7 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -1516,7 +1516,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [[ \"${CONFIGURATION}\" = \"Debug\" ]] && [ -z ${CIRCLECI} ] && which swiftlint >/dev/null; then\nswiftlint\nfi\n";
shellScript = "if [ -z ${CI} ]; then\n if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\n fi\n\n if which swiftlint > /dev/null; then\n swiftlint\n else\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\n fi\nfi\n";
};
5B717B261E2E26C4004A05A7 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -1531,7 +1531,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [[ \"${CONFIGURATION}\" = \"Debug\" ]] && [ -z ${CIRCLECI} ] && which swiftlint >/dev/null; then\nswiftlint\nfi\n";
shellScript = "if [ -z ${CI} ]; then\n if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\n fi\n\n if which swiftlint > /dev/null; then\n swiftlint\n else\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\n fi\nfi\n";
};
5B717B271E2E26CE004A05A7 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -1546,7 +1546,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [[ \"${CONFIGURATION}\" = \"Debug\" ]] && [ -z ${CIRCLECI} ] && which swiftlint >/dev/null; then\nswiftlint\nfi\n";
shellScript = "if [ -z ${CI} ]; then\n if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\n fi\n\n if which swiftlint > /dev/null; then\n swiftlint\n else\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\n fi\nfi\n";
};
5B7EE46F20FC9FAE00367724 /* Auth0 */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -1561,7 +1561,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "AUTH0_PLIST=\"${SRCROOT}/Auth0.plist\"\nif [ -f $AUTH0_PLIST ];\nthen\ncp \"$AUTH0_PLIST\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app\"\nfi\n";
shellScript = "AUTH0_PLIST=\"${SRCROOT}/Auth0.plist\"\n\nif [ -f $AUTH0_PLIST ]; then\n cp \"$AUTH0_PLIST\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app\"\nfi\n";
};
5B7EE48C20FCA0D900367724 /* Auth0 */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -1576,7 +1576,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "AUTH0_PLIST=\"${SRCROOT}/Auth0.plist\"\nif [ -f $AUTH0_PLIST ];\nthen\ncp \"$AUTH0_PLIST\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/Contents/Resources\"\nfi\n";
shellScript = "AUTH0_PLIST=\"${SRCROOT}/Auth0.plist\"\n\nif [ -f $AUTH0_PLIST ]; then\n cp \"$AUTH0_PLIST\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/Contents/Resources\"\nfi\n";
};
5F53F5CB1CFCDC2500476A46 /* Auth0 */ = {
isa = PBXShellScriptBuildPhase;
Expand All @@ -1591,7 +1591,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "AUTH0_PLIST=\"${SRCROOT}/Auth0.plist\"\nif [ -f $AUTH0_PLIST ];\nthen\ncp \"$AUTH0_PLIST\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app\"\nfi\n";
shellScript = "AUTH0_PLIST=\"${SRCROOT}/Auth0.plist\"\n\nif [ -f $AUTH0_PLIST ]; then\n cp \"$AUTH0_PLIST\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
5 changes: 0 additions & 5 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ platform :ios do
setup_circle_ci if defined? setup_circle_ci
end

desc "Cocoapods library lint"
lane :pod_lint do
pod_lib_lint(verbose: false, allow_warnings: true, platforms: 'ios,osx,tvos')
end

desc "Tags the release and pushes the Podspec to CocoaPods"
lane :release do
perform_release target: 'Auth0.iOS'
Expand Down
24 changes: 0 additions & 24 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do

## iOS

### ios lint

```sh
[bundle exec] fastlane ios lint
```

Run code linter

### ios test

```sh
[bundle exec] fastlane ios test
```

Runs all the tests

### ios pod_lint

```sh
Expand All @@ -39,14 +23,6 @@ Runs all the tests

Cocoapods library lint

### ios ci

```sh
[bundle exec] fastlane ios ci
```

Runs all the tests in a CI environment

### ios release

```sh
Expand Down
4 changes: 0 additions & 4 deletions fastlane/Scanfile

This file was deleted.

0 comments on commit f5179b4

Please sign in to comment.