Skip to content

Commit

Permalink
Add basic iOS workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket committed Aug 15, 2023
1 parent 47354dc commit 8c1b570
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 34 deletions.
60 changes: 60 additions & 0 deletions .github/actions/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Test
description: Build and test the library for a given Xcode version and platform
inputs:
xcode:
description: 'The version of Xcode to use'
required: true
platform:
description: 'The platform to build for'
required: true
scheme:
description: 'The scheme to build'
required: true
runs:
using: composite
shell: bash -euo pipefail
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set Ruby version
run: ruby -e 'puts RUBY_VERSION' | tee .ruby-version
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
cache-version: 1
- name: Install Carthage
run: brew install carthage
- name: Install Swiftlint
run: brew install swiftlint
- name: Setup Xcode
uses: mxcl/xcodebuild@v2
with:
xcode: ${{ inputs.xcode }}
action: none
- name: Save Xcode version
run: xcodebuild -version | tee .xcode-version
- id: restore-carthage-cache
name: Restore Carthage cache
uses: actions/cache/restore@v3
with:
path: Carthage
key: v1-carthage-${{ hashFiles('.xcode-version') }}-${{ hashFiles('Cartfile.resolved') }}
- name: Install dependencies
if: steps.restore-carthage-cache.outputs.cache-hit != 'true'
run: carthage bootstrap --platform ${{ inputs.platform }} --no-use-binaries --cache-builds
- 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: v1-carthage-${{ hashFiles('.xcode-version') }}-${{ hashFiles('Cartfile.resolved') }}
- name: Run tests
uses: mxcl/xcodebuild@v2
with:
xcode: ${{ inputs.xcode }}
platform: ${{ inputs.platform }}
scheme: ${{ inputs.scheme }}
code-coverage: true
configuration: release
13 changes: 13 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Test
on:
[push]
jobs:
ios:
name: Build and test on iOS
runs-on: macos-latest
steps:
- uses: ./.github/actions/test
with:
xcode: '14.2'
platform: iOS
scheme: Auth0.iOS
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ opt_in_rules: # some rules are only opt-in
disabled_rules:
- void_function_in_ternary
- large_tuple
- blanket_disable_command
included: # paths to include during linting. `--path` is ignored if present.
- Auth0
excluded: # paths to ignore during linting. Takes precedence over `included`.
Expand Down
2 changes: 1 addition & 1 deletion 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 [[ \"${CONFIGURATION}\" = \"Debug\" ]] && [ -z ${CIRCLECI} ] && which swiftlint >/dev/null; then\nswiftlint\nfi\n";
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";
};
5B717B251E2E26B9004A05A7 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
2 changes: 0 additions & 2 deletions Auth0/WebAuth.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// swiftlint:disable file_length

#if WEB_AUTH_PLATFORM
import Foundation
import Combine
Expand Down
32 changes: 1 addition & 31 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,14 @@ default_platform :ios
platform :ios do

before_all do
setup_circle_ci
end

desc "Run code linter"
lane :lint do
swiftlint(
mode: :lint,
config_file: '.swiftlint.yml',
reporter: 'emoji',
raise_if_swiftlint_error: true
)
end

desc "Runs all the tests"
lane :test do |options|
scheme = options[:scheme]
device = options[:device]
scan(
scheme: scheme,
device: device,
clean: true,
skip_build: true,
code_coverage: true
)
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 "Runs all the tests in a CI environment"
lane :ci do
# TODO: Run rest of platforms
lint
test
end

desc "Tags the release and pushes the Podspec to CocoaPods"
lane :release do
perform_release target: 'Auth0.iOS'
Expand Down

0 comments on commit 8c1b570

Please sign in to comment.