forked from airgap-it/airgap-vault
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
executable file
·116 lines (109 loc) · 4.16 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
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
image: docker:latest
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE
IMAGE_TAG_CURRENT: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
IMAGE_TAG_ANDROID_CURRENT: $CI_REGISTRY_IMAGE:android-$CI_COMMIT_SHA
IMAGE_TAG_ANDROID_LATEST: $CI_REGISTRY_IMAGE:android-latest
stages:
- build
- test
- native_build
- qa
build_ionic:
stage: build
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker build --cache-from $IMAGE_TAG_LATEST -t $IMAGE_TAG .
- docker tag $IMAGE_TAG $IMAGE_TAG_CURRENT
- docker tag $IMAGE_TAG $IMAGE_TAG_LATEST
- docker push $IMAGE_TAG_CURRENT
- docker push $IMAGE_TAG_LATEST
tags:
- docker
unit:
stage: test
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker run --name unit-$CI_COMMIT_SHA $IMAGE_TAG_CURRENT npm run test-ci
- docker run --name lint-$CI_COMMIT_SHA $IMAGE_TAG_CURRENT npm run lint-ci
- docker cp unit-$CI_COMMIT_SHA:/app/coverage/lcov.info lcov.info
- docker cp lint-$CI_COMMIT_SHA:/app/lintReport.json lintReport.json
after_script:
- docker rm unit-$CI_COMMIT_SHA
- docker rm lint-$CI_COMMIT_SHA
tags:
- docker
artifacts:
paths:
- lcov.info
- lintReport.json
build_android:
stage: native_build
when: manual
tags:
- docker
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- sed -i -e "s/versionName \"0.0.0\"/versionName \"$VERSION\"/g" android/app/build.gradle
- docker build -f build/android/Dockerfile -t $IMAGE_TAG_ANDROID_CURRENT --build-arg BUILD_NR="$CI_PIPELINE_ID" --build-arg VERSION="$VERSION" .
- docker run --name $CI_PIPELINE_ID $IMAGE_TAG_ANDROID_CURRENT echo "container ran."
- docker cp $CI_PIPELINE_ID:/app/android-release-unsigned.apk airgap-vault-release-unsigned-$CI_PIPELINE_ID.apk
- docker cp $CI_PIPELINE_ID:/app/android-debug.apk airgap-vault-debug-$CI_PIPELINE_ID.apk
after_script:
- docker rm -f $CI_PIPELINE_ID || true
artifacts:
paths:
- airgap-vault-release-unsigned-$CI_PIPELINE_ID.apk
- airgap-vault-debug-$CI_PIPELINE_ID.apk
build_ios:
stage: native_build
when: manual
before_script:
- echo "$IOS_BUILD_JSON" > build.json
- echo "$IOS_EXPORT_OPTIONS" > exportOptions.plist
script:
- export DEVELOPER_DIR=$XCODE_PATH
- nvm use v10.13.0
- npm install
- npm run disable-pure-getters
- npm run configure-mangle
- npm run apply-diagnostic-modules # manually remove unused cordova-diagnostic-plugin modules
- ionic build --prod
- npx cap sync ios
- xcodebuild -workspace ios/App/App.xcworkspace -scheme "App" -destination generic/platform=iOS -configuration Release archive -archivePath ios/AirGap\ Vault.xcarchive MARKETING_VERSION=$VERSION CURRENT_PROJECT_VERSION=1.0.$CI_PIPELINE_ID -allowProvisioningUpdates
- xcodebuild -exportArchive -archivePath ios/AirGap\ Vault.xcarchive -exportOptionsPlist exportOptions.plist -exportPath ios/ -allowProvisioningUpdates
- xcrun altool --upload-app -f ios/App.ipa -u $IOS_USERNAME -p $IOS_PASSWORD
artifacts:
paths:
- ios/AirGap\ Vault.ipa
tags:
- ios
qa:
stage: qa
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker create --name qa-$CI_PIPELINE_ID $IMAGE_TAG_CURRENT npm run sonar-scanner -- -X
-Dsonar.typescript.lcov.reportPaths=lcov.info
-Dsonar.typescript.tslint.reportPaths=lintReport.json
-Dsonar.test.inclusions=**/*.spec.ts
-Dsonar.tests=src/
-Dsonar.exclusions=**/node_modules/**,**/*.spec.ts,src/assets/libs/**
-Dsonar.sources=src/
-Dsonar.host.url=$SONAR_URL
-Dsonar.login=$SONAR_LOGIN
-Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA
-Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
-Dsonar.gitlab.project_id=$CI_PROJECT_ID
-Dsonar.branch.name=$CI_BUILD_REF_NAME
- docker cp lcov.info qa-$CI_PIPELINE_ID:/app/lcov.info
- docker cp lintReport.json qa-$CI_PIPELINE_ID:/app/lintReport.json
- docker start -a qa-$CI_PIPELINE_ID
after_script:
- docker rm -f qa-$CI_PIPELINE_ID || true
tags:
- docker