-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (130 loc) · 4.61 KB
/
build-and-test.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
#
# This source file is part of the Continous Delivery open source project
#
# SPDX-FileCopyrightText: 2022 Paul Schmiedmayer <paul.schmiedmayer@tum.de>
#
# SPDX-License-Identifier: MIT
#
name: Build and Test
on:
pull_request:
branches:
- main
workflow_dispatch:
workflow_call:
jobs:
buildandtestiosapp:
name: Build and Test iOS App
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Check Environment
run: |
xcodebuild -version
swift --version
- name: Install the Apple certificate and provisioning profile
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate and provisioning profile from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $PP_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Build and test
run: bundler install && bundle exec fastlane test
macosswiftpackages:
name: macOS ${{ matrix.package }} ${{ matrix.configuration }}
runs-on: macos-12
defaults:
run:
working-directory: ./${{ matrix.package }}
strategy:
fail-fast: false
matrix:
package: [WebService, Shared]
configuration: [debug, release]
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: .build
key: ${{ runner.os }}-${{ hashFiles('Package.resolved') }}
- name: Check Environment
run: |
xcodebuild -version
swift --version
- name: Release Build & Test
if: matrix.configuration == 'release'
run: swift test -c release -Xswiftc -enable-testing -Xswiftc -DRELEASE_TESTING
- name: Debug Build & Test
if: matrix.configuration == 'debug'
run: swift test -c debug
linuxswiftpackages:
name: Linux ${{ matrix.package }} ${{ matrix.linux }} ${{ matrix.configuration }}
container:
image: swift:${{ matrix.linux }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./${{ matrix.package }}
strategy:
fail-fast: false
matrix:
package: [WebService, Shared]
linux: [focal, amazonlinux2]
configuration: [debug, release]
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: .build
key: ${{ runner.os }}-${{matrix.linux}}-${{ hashFiles('Package.resolved') }}
- name: Check Environment
run: |
swift --version
- name: Install apt-get Dependencies
if: matrix.linux != 'amazonlinux2' && matrix.package == 'WebService'
run: apt-get update && apt-get install -y --no-install-recommends libsqlite3-dev
- name: Install yum Dependencies
if: matrix.linux == 'amazonlinux2' && matrix.package == 'WebService'
run: yum update -y && yum install -y sqlite-devel
- name: Release Build & Test
if: matrix.configuration == 'release'
run: swift test -c release -Xswiftc -enable-testing -Xswiftc -DRELEASE_TESTING
- name: Debug Build & Test
if: matrix.configuration == 'debug'
run: swift test -c debug
dockercompose:
name: Docker Compose Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Start containers
run: docker-compose -f docker-compose-development.yml up -d --build
- name: Test web service
run: |
sleep 5
sh WebService/test.sh
- name: Stop containers
if: always()
run: docker-compose down --remove-orphans