-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
52 lines (46 loc) · 1.36 KB
/
.gitlab-ci.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
default:
tags:
- instance-type:mac2.metal
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: always
- if: $CI_COMMIT_REF_NAME == "main"
when: always
- when: never
# Check merge request message
title-lint:
stage: .pre
script:
- echo Start PR Validation
- env
- '[[ "$CI_COMMIT_MESSAGE" =~ ^(feat|fix|chore|docs|tests|ci) ]] || (echo "no commit type is specified in merge request title" && exit 1)'
# Check code lint issue
code-lint:
stage: .pre
script:
- swiftlint
# Check code format issue
code-format:
stage: .pre
script:
- swiftformat .
# Execute code build
build:
stage: build
script:
- swift build
# Execute code test
test:
stage: test
script:
- rm -rf .build/test/
- xcodebuild test -scheme aws-solution-clickstream-swift -destination 'platform=iOS Simulator,name=iPhone 14 Pro,OS=latest' -resultBundlePath .build/test/TestResults.xcresult
- xcrun xccov view --report --json .build/test/TestResults.xcresult > .build/test/report.json
- COVERAGE_EXPRESS=$(grep -Eo '"lineCoverage":\s*([0-9]+\.[0-9]+)(?:,"targets":)' .build/test/report.json)
- COVERAGE=$(echo "$COVERAGE_EXPRESS" | grep -o '[0-9]*\.[0-9]*' | awk '{ printf "%.2f", $1 * 100 }')
- echo "coverage:$COVERAGE"
coverage: '/coverage:([0-9]+\.[0-9]+)/'
artifacts:
paths:
- .build/test/