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