Skip to content

Commit

Permalink
Migrate CI to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket committed Dec 6, 2023
1 parent 14cbfd6 commit 1b117b0
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 9 deletions.
16 changes: 10 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1
orbs:
macos: circleci/macos@2
flutter: circleci/flutter@1
flutter: circleci/flutter@2
parameters:
flutter_version:
type: string
Expand All @@ -14,7 +14,7 @@ jobs:
- checkout
- flutter/install_sdk_and_pub:
app-dir: ./sample
flutter_version: << pipeline.parameters.flutter_version >>
version: << pipeline.parameters.flutter_version >>
- run:
name: Prepare Environment Variables
command: cp .env.example .env
Expand All @@ -32,20 +32,24 @@ jobs:
ios_simulator:
type: string
macos:
xcode: '13.0.0'
xcode: '14.3.1'
resource_class: macos.m1.medium.gen1
environment:
BUNDLE_RETRY: 3
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
steps:
- checkout
- macos/preboot-simulator:
version: '15.0'
version: '16.4'
platform: iOS
device: << parameters.ios_simulator >>
- flutter/install_sdk_and_pub:
app-dir: ./sample
flutter_version: << pipeline.parameters.flutter_version >>
version: << pipeline.parameters.flutter_version >>
- run:
name: Update Cocoapods
command: gem update cocoapods
- flutter/install_ios_pod:
app-dir: ./sample
- run:
Expand All @@ -67,6 +71,6 @@ workflows:
jobs:
- analyze_and_test
- test_ios:
ios_simulator: iPhone 13
ios_simulator: iPhone 14
requires:
- analyze_and_test
81 changes: 81 additions & 0 deletions .github/actions/setup-darwin/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Set up iOS/macOS environment
description: Set up the environment for building and testing the library on iOS/macOS

inputs:
platform:
description: Either iOS or macOS
required: true

flutter:
description: The version of Flutter to use
required: true

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

auth0-domain:
description: The Auth0 domain
required: true

auth0-client-id:
description: The Auth0 client ID
required: true

runs:
using: composite

steps:
- name: Lowercase platform value
id: lowercase-platform
run: echo "platform=$(echo ${{ inputs.platform }} | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
shell: bash

- name: Install Flutter
uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa
with:
flutter-version: ${{ inputs.flutter }}
channel: stable
cache: true

- name: Install Flutter dependencies
working-directory: sample
run: flutter pub get
shell: bash

- name: Set Ruby version
working-directory: sample/${{ steps.lowercase-platform.outputs.platform }}
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
working-directory: sample/${{ steps.lowercase-platform.outputs.platform }}

- name: Setup Xcode
run: sudo xcode-select --switch /Applications/Xcode_${{ inputs.xcode }}.app/Contents/Developer
shell: bash

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

- id: restore-pods-cache
name: Restore Pods cache
uses: actions/cache@f5ce41475b483ad7581884324a6eca9f48f8dcc7
with:
path: sample/${{ steps.lowercase-platform.outputs.platform }}/Pods
key: pods-${{ hashFiles('Podfile.lock') }}-${{ hashFiles('.xcode-version') }}-v1

- name: Install pods
working-directory: sample/${{ steps.lowercase-platform.outputs.platform }}
run: pod install
shell: bash

- name: Set .env
working-directory: sample
run: printf '%s\n%s\n%s' 'AUTH0_DOMAIN=${{ inputs.auth0-domain }}' 'AUTH0_CLIENT_ID=${{ inputs.auth0-client-id }}' 'AUTH0_CUSTOM_SCHEME=demo' >> .env
shell: bash
42 changes: 42 additions & 0 deletions .github/actions/smoke-tests-darwin/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Run iOS/macOS smoke tests
description: Execute the smoke test suite on iOS/macOS

inputs:
platform:
description: Either iOS or macOS
required: true

destination:
description: The destination string for xcodebuild
required: true

runs:
using: composite

steps:
- name: Lowercase platform value
id: lowercase-platform
run: echo "platform=$(echo ${{ inputs.platform }} | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
shell: bash

- name: Build ${{ inputs.platform }} app
working-directory: sample/${{ steps.lowercase-platform.outputs.platform }}
run: flutter build ${{ steps.lowercase-platform.outputs.platform }} --debug ${{ inputs.platform == 'iOS' && '--no-codesign' || '' }}
shell: bash

- name: Disable iOS hardware keyboard
if: ${{ inputs.platform == 'iOS' }}
run: defaults write com.apple.iphonesimulator ConnectHardwareKeyboard 0
shell: bash

- name: Run ${{ inputs.platform }} smoke tests
working-directory: sample/${{ steps.lowercase-platform.outputs.platform }}
run: xcodebuild test -scheme Runner -workspace Runner.xcworkspace -destination '${{ inputs.destination }}' -resultBundlePath smoke-tests.xcresult -only-testing:RunnerUITests
shell: bash

- name: Upload xcresult bundles
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
if: ${{ failure() }}
with:
name: '${{ inputs.platform }} xcresult bundles'
path: 'sample/${{ steps.lowercase-platform.outputs.platform }}/smoke-tests.xcresult'
109 changes: 109 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: CI

on:
pull_request:
types:
- opened
- synchronize

permissions: {}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

env:
flutter: '3.x'
ios-simulator: iPhone 15
java: 11

jobs:
authorize:
name: Authorize
environment: ${{ github.event.pull_request.head.repo.fork && 'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- run: true

analyze-dart:
name: Analyze Dart code
needs: authorize
runs-on: ubuntu-latest

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

- name: Install Flutter
uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225
with:
flutter-version: ${{ env.flutter }}
channel: stable
cache: true

- name: Add sample/.env
working-directory: sample
run: cp .env.example .env

- name: Run Dart analyzer
working-directory: sample
run: flutter analyze

test-dart:
name: Test Dart code
needs: authorize
runs-on: ubuntu-latest

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

- name: Install Flutter
uses: subosito/flutter-action@2783a3f08e1baf891508463f8c6653c258246225
with:
flutter-version: ${{ env.flutter }}
channel: stable
cache: true

- name: Add sample/.env
working-directory: sample
run: cp .env.example .env

- name: Run Dart tests
working-directory: sample
run: flutter test

test-ios-smoke:
name: Run native iOS smoke tests using Xcode ${{ matrix.xcode }}
needs: authorize
runs-on: macos-13-large
environment: ${{ github.event.pull_request.head.repo.fork && 'external' || 'internal' }}

env:
platform: iOS
USER_EMAIL: ${{ secrets.USER_EMAIL }}
USER_PASSWORD: ${{ secrets.USER_PASSWORD }}

strategy:
matrix:
xcode:
- '15.0.1'

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

- name: Set up environment
uses: ./.github/actions/setup-darwin
with:
platform: ${{ env.platform }}
flutter: ${{ env.flutter }}
xcode: ${{ matrix.xcode }}
auth0-domain: ${{ vars.AUTH0_DOMAIN }}
auth0-client-id: ${{ vars.AUTH0_CLIENT_ID }}

- name: Run iOS smoke tests
uses: ./.github/actions/smoke-tests-darwin
with:
platform: ${{ env.platform }}
destination: 'platform=iOS Simulator,name=iPhone 15'
6 changes: 4 additions & 2 deletions sample/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1340;
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
5C84DBD72879193000E317DB = {
Expand Down Expand Up @@ -265,6 +265,7 @@
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand Down Expand Up @@ -638,7 +639,8 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Manual;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
Expand Down
2 changes: 1 addition & 1 deletion sample/ios/UITests/SmokeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SmokeTests: XCTestCase {
private let loginButton = "Login"
private let logoutButton = "Logout"
private let continueButton = "Continue"
private let timeout: TimeInterval = 10
private let timeout: TimeInterval = 30

override func setUp() {
continueAfterFailure = false
Expand Down

0 comments on commit 1b117b0

Please sign in to comment.