37
loading...
This website collects cookies to deliver better user experience
.gitlab-ci.yml
brew install jq
Pipelines
are the top-level component of continuous integration, delivery, and deployment.
Jobs
defines what to do, executed by runners
Stages
defines when to run the jobs
stages:
- prebuild
- build
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- my-project-path/.bundle
- my-project-path/vendor
install_dependencies:
stage: prebuild
script:
- unset cd
- cd my-project-path
- bundle config set --local deployment 'true'
- bundle install
tags:
- macos_11-2-3
- xcode_12-4
- ios_14-4
build_project:
stage: build
script:
- unset cd
- cd my-project-path
- xcodebuild clean build test -project my-project.xcodeproj -scheme "CI" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
- xcrun xccov view --report --json DerivedData/my-project-path/Logs/Test/*.xcresult > xcresult.json
- cat xcresult.json | jq ".lineCoverage" -j | awk '{printf "XCTEST_COVERAGE=%0.2f%%\n",$1*100}'
tags:
- macos_11-2-3
- xcode_12-4
- ios_14-4
prebuild
and build
install_dependencies
Jobbuild_project
Jobmy-project-path/.bundle
is storing the bundle configmy-project-path/.vendor
is storing the installed gems${CI_COMMIT_REF_SLUG}
is the branch or tag name for which project is builtprebuild
stage will be deleted when the build
stage is executed, even the Jobs are executed on the same machinervm
is used, it will redefine the cd
command as below:cd ()
{
__zsh_like_cd cd "$@"
}
cd
command is used in the Job, it will throw ERROR: Build failed with: exit status 1
and exit immediatelyunset cd
is used to reset cd
to be the shell builtin command
cd
command (as in the example).bash_profile
tags
must match the configs in the Runners section in gitlab.com -> project settings -> CI/CD.gitlab-ci.yml
should be placed in the root of the git repoPipeline Status
https://gitlab.com/%{project_path}/-/commits/%{default_branch}
https://gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg
Get the code coverage report in JSON format after the project is built
xcrun xccov view --report --json DerivedData/my-project/Logs/Test/*.xcresult > xcresult.json
Print the code coverage to the job log
cat xcresult.json | jq ".lineCoverage" -j | awk '{printf "XCTEST_COVERAGE=%0.2f%%\n",$1*100}'
lineCoverage
field from the JSON%
must be included for Test coverage parsingXCTEST_COVERAGE=(\d+.\d+%)
Code Coverage
https://gitlab.com/%{project_path}/-/commits/%{default_branch}
https://gitlab.com/%{project_path}/badges/%{default_branch}/pipeline.svg