|
| 1 | +# This workflow performs a full End 2 End test of the App |
| 2 | +# It runs the test on the last 5 iOS releases. |
| 3 | + |
| 4 | +name: E2E Test with latest FusionAuth |
| 5 | + |
| 6 | +on: |
| 7 | + # Triggers the workflow on pull request events but only for default and protected branches |
| 8 | + pull_request: |
| 9 | + branches: [ "main" ] |
| 10 | + # Allows you to run this workflow manually from the Actions tab |
| 11 | + workflow_dispatch: |
| 12 | + # Triggers the workflow on push request events but only for tag versions |
| 13 | + workflow_call: |
| 14 | + |
| 15 | +env: |
| 16 | + fusionauth-docker-image-version: "1.55.1" |
| 17 | + |
| 18 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 19 | +jobs: |
| 20 | + # This workflow contains a single job called "e2e-test" |
| 21 | + e2e-test: |
| 22 | + name: End 2 End Test |
| 23 | + |
| 24 | + permissions: |
| 25 | + # required for all workflows |
| 26 | + security-events: write |
| 27 | + # only required for workflows in private repositories |
| 28 | + actions: read |
| 29 | + contents: read |
| 30 | + |
| 31 | + # The type of runner that the job will run on |
| 32 | + # https://xcodereleases.com/ |
| 33 | + # https://developer.apple.com/support/xcode/ |
| 34 | + # https://developer.apple.com/documentation/xcode-release-notes |
| 35 | + runs-on: ${{ matrix.os }} |
| 36 | + strategy: |
| 37 | + fail-fast: false |
| 38 | + matrix: |
| 39 | + destination: [ "platform=iOS Simulator,OS=18.1,name=iPhone 15" ] |
| 40 | + xcode: [ "15.4" ] |
| 41 | + simulator-platform: [ "iOS" ] |
| 42 | + simulator-version: [ "18.1" ] |
| 43 | + swift: [ "5.10.1" ] |
| 44 | + os: [ "macos-14" ] |
| 45 | + postgresql-version: [ "16" ] |
| 46 | + |
| 47 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 48 | + steps: |
| 49 | + # Initialize the latest version of Xcode. |
| 50 | + - name: Initialize latest xcode |
| 51 | + uses: maxim-lobanov/[email protected] |
| 52 | + with: |
| 53 | + xcode-version: ${{ matrix.xcode }} |
| 54 | + |
| 55 | + # Remove any other Xcode version. |
| 56 | + - name: Remove old xcode versions |
| 57 | + run: | |
| 58 | + echo "Searching for Xcode versions:" |
| 59 | + find /Applications -name "Xcode_*" -maxdepth 1 -mindepth 1 |
| 60 | + echo "Removing old Xcode versions..." |
| 61 | + find /Applications -name "Xcode_*" -maxdepth 1 -mindepth 1 | grep -v ${{ matrix.xcode }} | xargs rm -rf |
| 62 | + echo "Available Xcode versions after removal:" |
| 63 | + find /Applications -name "Xcode_*" -maxdepth 1 -mindepth 1 |
| 64 | +
|
| 65 | + # Get the Xcode version. |
| 66 | + - name: Get Xcode version |
| 67 | + run: xcodebuild -version |
| 68 | + |
| 69 | + # Install Xcodes. |
| 70 | + - name: Install Xcodes |
| 71 | + if: matrix.os == 'macos-13' |
| 72 | + shell: bash |
| 73 | + run: | |
| 74 | + brew install aria2 |
| 75 | + brew install xcodes |
| 76 | +
|
| 77 | + # Install simulator platform. |
| 78 | + - name: Install Simulator |
| 79 | + if: matrix.os == 'macos-13' |
| 80 | + shell: bash |
| 81 | + run: | |
| 82 | + sudo xcodes runtimes |
| 83 | + sudo xcodes runtimes install '${{ matrix.simulator-platform }} ${{ matrix.simulator-version }}' |
| 84 | + sudo xcodes runtimes |
| 85 | +
|
| 86 | + # Initialize Swift in the matrix specified version. |
| 87 | + - name: Initialize Swift |
| 88 | + uses: swift-actions/[email protected] |
| 89 | + with: |
| 90 | + swift-version: ${{ matrix.swift }} |
| 91 | + |
| 92 | + # Get the Swift version. |
| 93 | + - name: Get Swift version |
| 94 | + run: swift --version |
| 95 | + |
| 96 | + # Checkout the repository. |
| 97 | + - name: Checkout repository |
| 98 | + |
| 99 | + |
| 100 | + # Install FusionAuth with brew. |
| 101 | + - name: Install PostgreSQL |
| 102 | + run: brew install postgresql@${{ matrix.postgresql-version }} -v |
| 103 | + |
| 104 | + # Start PostgreSQL with brew. |
| 105 | + - name: Start PostgreSQL |
| 106 | + run: brew services start postgresql@${{ matrix.postgresql-version }} -v |
| 107 | + |
| 108 | + # Add PostgreSQL to the PATH. |
| 109 | + - name: Add PostgreSQL to the PATH |
| 110 | + run: echo "$(brew --prefix postgresql@${{matrix.postgresql-version }})/bin" >> $GITHUB_PATH |
| 111 | + |
| 112 | + # Add PostgreSQL fusionauth user with default password. |
| 113 | + - name: Add PostgreSQL fusionauth user |
| 114 | + run: psql --command="CREATE USER fusionauth PASSWORD 'fusionauth'" --command="\du" postgres |
| 115 | + |
| 116 | + # Add PostgreSQL fusionauth database. |
| 117 | + - name: Add PostgreSQL fusionauth database |
| 118 | + run: createdb --owner=fusionauth fusionauth |
| 119 | + |
| 120 | + # Tap FusionAuth Homebrew formulae. |
| 121 | + - name: Tap FusionAuth Homebrew formulae |
| 122 | + run: brew tap sonderformat-llc/fusionauth |
| 123 | + |
| 124 | + # Install FusionAuth App with brew. |
| 125 | + - name: Install FusionAuth App |
| 126 | + run: brew install fusionauth-app -v |
| 127 | + |
| 128 | + # Configure FusionAuth App with silent mode. |
| 129 | + - name: Configure FusionAuth App |
| 130 | + run: | |
| 131 | + echo "" >> $(brew --prefix)/etc/fusionauth/fusionauth.properties |
| 132 | + echo "fusionauth-app.kickstart.file=$(echo $GITHUB_WORKSPACE)/Samples/Quickstart/fusionauth/${{ env.fusionauth-docker-image-version }}/kickstart/kickstart.json" >> $(brew --prefix)/etc/fusionauth/fusionauth.properties |
| 133 | + echo "fusionauth-app.silent-mode=true" >> $(brew --prefix)/etc/fusionauth/fusionauth.properties |
| 134 | + cat $(brew --prefix)/etc/fusionauth/fusionauth.properties |
| 135 | +
|
| 136 | + # Start FusionAuth App. |
| 137 | + - name: Start FusionAuth App |
| 138 | + run: brew services start fusionauth-app -v |
| 139 | + |
| 140 | + # Check Brew services status. |
| 141 | + - name: Check Brew services status |
| 142 | + run: brew services list |
| 143 | + |
| 144 | + # Check FusionAuth status 10 times with increasing wait times |
| 145 | + # Continue if FusionAuth status is OK or fail at the end. |
| 146 | + - name: Check FusionAuth status |
| 147 | + run: | |
| 148 | + for i in {1..10}; do |
| 149 | + if curl -s http://localhost:9011/api/status | grep -qi "ok"; then |
| 150 | + echo "FusionAuth is up and running." |
| 151 | + exit 0 |
| 152 | + else |
| 153 | + echo "FusionAuth is not up and running. Waiting for $(expr 10 \* $i) seconds." |
| 154 | + sleep $(expr 10 \* $i) |
| 155 | + fi |
| 156 | + done |
| 157 | + cat $(brew --prefix)/var/log/fusionauth/fusionauth-app.log |
| 158 | + exit 1 |
| 159 | +
|
| 160 | + # Check KickstartRunner execution 10 times with increasing wait times |
| 161 | + # Continue if KickstartRunner execution is OK or fail at the end. |
| 162 | + # TODO - use webhook instead https://fusionauth.io/docs/extend/events-and-webhooks/events/kickstart-success |
| 163 | + - name: Check KickstartRunner execution |
| 164 | + run: | |
| 165 | + for i in {1..10}; do |
| 166 | + if cat $(brew --prefix)/var/log/fusionauth/fusionauth-app.log | grep "KickstartRunner" | grep -q "Summary"; then |
| 167 | + echo "KickstartRunner execution is OK." |
| 168 | + exit 0 |
| 169 | + else |
| 170 | + echo "KickstartRunner execution is not OK. Waiting for $(expr 10 \* $i) seconds." |
| 171 | + sleep $(expr 10 \* $i) |
| 172 | + fi |
| 173 | + done |
| 174 | + cat $(brew --prefix)/var/log/fusionauth/fusionauth-app.log |
| 175 | + exit 1 |
| 176 | +
|
| 177 | + # Read FusionAuth App logs. |
| 178 | + - name: Read FusionAuth App logs |
| 179 | + run: cat $(brew --prefix)/var/log/fusionauth/fusionauth-app.log |
| 180 | + |
| 181 | + # Connect to FusionAuth App. |
| 182 | + - name: Connect to FusionAuth App |
| 183 | + run: curl http://localhost:9011/api/status |
| 184 | + |
| 185 | + # Perform the tests from the fusionauth-quickstart-swift-ios-native Sample. |
| 186 | + - name: Perform end to end tests |
| 187 | + run: set -o pipefail && xcodebuild test -workspace FusionAuthSDK.xcworkspace/ -scheme fusionauth-quickstart-swift-ios-native -destination "${{matrix.destination}}" -skipPackagePluginValidation |
| 188 | + |
| 189 | + - name: Upload recording |
| 190 | + |
| 191 | + if: ${{ failure() }} |
| 192 | + with: |
| 193 | + name: FusionAuth-${{ matrix.fusionauth-docker-image-version }}_${{ matrix.os }}_xcode-${{ matrix.xcode }}_swift-${{ matrix.swift }}_${{ matrix.simulator-platform }}-${{ matrix.simulator-version }}.xcresult |
| 194 | + path: /Users/runner/Library/Developer/Xcode/DerivedData/*/Logs/Test/*.xcresult |
0 commit comments