I am trying to use the following config to build my iOS app, I double checked the documentation but I am having various issues while trying to run some job only on the master branch.
Here is my config.yml:
version: 2.1
aliases:
- &restore_gem_cache
name: Restore gem cache
keys:
- gem-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
- gem-cache-v1-{{ arch }}-{{ .Branch }}
# Fall back to using the latest cache if no exact match is found.
- gem-cache-v1
- &save_gem_cache
name: Save gem cache
key: gem-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
- &bundle_install
name: Install Gems via Bundler
command: bundle install --path vendor/bundle
- &restore_pods_cache
name: Restore pods cache
key: 1-pods-{{ checksum "Podfile.lock" }}
- &save_pods_cache
name: Save pods cache
key: 1-pods-{{ checksum "Podfile.lock" }}
paths: ./Pods
- &pod_install
name: Install Pods
command: |
if [ ! -d "Pods" ]
then
curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
bundle exec pod install
fi
- &restore_git_cache
name: Restore GIT cache
keys:
- source-v1-{{ .Branch }}-{{ .Revision }}
- source-v1-{{ .Branch }}-
# Fall back to using the latest cache if no exact match is found.
- source-v1-
- &save_git_cache
name: Save GIT cache
key: source-v1-{{ .Branch }}-{{ .Revision }}
paths:
- .git
workflows:
version: 2
build-deploy:
jobs:
- build:
filters:
branches:
only:
- master
- develop
- circle-ci-project-setup
- /rc-.*/
- deploy:
requires:
- build
filters:
branches:
only:
- master
jobs:
build:
macos:
xcode: 11.3.0
steps:
- restore_cache: *restore_git_cache
- checkout
- save_cache: *save_git_cache
- restore_cache: *restore_gem_cache
- run: *bundle_install
- save_cache: *save_gem_cache
- restore_cache: *restore_pods_cache
- run: pod install #*pod_install
- save_cache: *save_pods_cache
- run: fastlane tests # Run tests using Fastlane
# Collect XML test results data to show in the UI, and save the same XML
# files under test-results folder in the Artifacts tab
- store_test_results:
path: test_output
- store_artifacts:
path: test_output
destination: scan-output
deploy:
macos:
xcode: 11.3.0
steps:
- run: fastlane upload_release
I am having two main issues:
- The conditional branching logic does not work, I pushed the config on my circle-ci-project-setup branch but the deploy job gets triggered every time.
- The Pods caching logic does not work in my case (even if this is being logged: Pod installation complete! There are 25 dependencies from the Podfile and 47 total pods installed. Skipping cache generation, cache already exists for key: 1-pods-3gdLQRz20oqo91RssvPgaTsQ41cP0jBbF_c1ONeeEhg= Found one created at 2020-05-22 15:59:18 +0000 UTC), I took it from the documentation/best practices, in logs after $ fastlane tests is being run, I am getting errors relative to the pod installation:
error: /Users/distiller/project/Pods/Pods/Target Support Files/Pods-Project_Name/Pods-Project_Name.debug.xcconfig: unable to open file (in target “Project_Name” in project “Project_Name”) (in target ‘Project_Name’ from project ‘Project_Name’)
I also tried validating the conditional jobs running following config by running “circleci config validate” in a shell for the following snippet but it does not get validated (the same validation error is triggered after pushing the commit):
workflows:
version: 2
build-deploy:
jobs:
- build:
filters:
branches:
only:
- master
- develop
- circle-ci-project-setup
- /rc-.*/
- deploy:
requires:
- build
filters:
branches:
only:
- master
jobs:
build:
macos:
xcode: 11.3.0
steps:
- run: echo "build job started..."
deploy:
macos:
xcode: 11.3.0
steps:
- run: echo "deploy job started..."
I get the following error:
Error: ERROR IN CONFIG FILE:
[#/workflows/build-deploy] only 1 subschema matches out of 2
1. [#/workflows/build-deploy/jobs/1] 0 subschemas matched instead of one
| 1. [#/workflows/build-deploy/jobs/1] 2 schema violations found
| | 1. [#/workflows/build-deploy/jobs/1] maximum size: [1], found: [2]
| | | SCHEMA:
| | | maxProperties: 1
| | | INPUT:
| | | deploy: null
| | | requires:
| | | - build
| | | filters:
| | | branches:
| | | only:
| | | - master
| | 2. [#/workflows/build-deploy/jobs/1/requires] expected type: Mapping, found: Sequence
| | | SCHEMA:
| | | type: object
| | | INPUT:
| | | - build
| 2. [#/workflows/build-deploy/jobs/1] expected type: String, found: Mapping
| | SCHEMA:
| | type: string
| | INPUT:
| | deploy: null
| | requires:
| | - build
| | filters:
| | branches:
| | only:
| | - master
Thanks in advance for your support, I am relatively new to CI, the messages are misleading and unclear for me.