I use a circleci.yml file to configure a CircleCI builds for iOS project
The "dependencies" section run by default "Fetch Cocoapods Repo" from a S3 server, which takes almost 3 minutes.
I want to disable this default command for this section with following definition:
dependencies:
pre:
- gem update fastlane
- fastlane --version
override:
cache_directories:
- "~/.cocoapods"
compile:
override:
- fastlane scan
test:
override:
The problem is that the section "dependencies": with "override" keyword run a default command "Fetch Cocoapods Repo".
The question is: To avoid running default commands under a section, Is it enough to add keyword "override"?
Won't work on it's own, but changing the override line to the following would
override:
- echo "Skipping Cocoapods fetch"
Related
Following the docs, I set my environment variable in the console ($CLIENT_ID).
In the console I added the echo command to try and insert the variable into a .env.
The error I keep getting is There was an issue connecting to your repo provider. When I remove the echo line the build passes. I've tried single/double quotes and putting the line above/below the other lines under the build commands phase.
Here's the backend section for the build process.
backend:
phases:
build:
commands:
- echo 'CLIENT_ID=$CLIENT_ID' >> backend/.env
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple
I wrote an comment but to make it easier, I quote from answers from this question
build:
commands:
- npm run build
- VARIABLE_NAME_1=$VARIABLE_NAME_1 # it works like this
- VARIABLE_NAME_2=${VARIABLE_NAME_2} # it also works this way
Please thumb up on the original answers, and flag this question as duplicated.
Seems this is a feature request:
https://github.com/aws-amplify/amplify-cli/issues/4347
I have a circle config which includes the following custom command:
remove-circle-ip:
description: "remove current Circle CI box IP from inbound security group rules for DB"
steps:
- aws-white-list-circleci-ip/remove:
tag-key: circleci
tag-value: whitelistmeplease
port: 5432
which I use in my job as follows:
jobs:
test:
docker:
- image: nikolaik/python-nodejs:python3.8-nodejs12
environment:
AWS_DEFAULT_REGION: us-east-2
steps:
- setup
- install-python-deps
- add-circle-ip
- run:
name: run tests
command: |
poetry run coverage run --source='.' manage.py test
- run:
name: remove circle IP
command: remove-circle-ip
when: always
I'd like the step for remove circle IP to run even if the tests which run before it fail. I can't seem to figure out the syntax for this. Previously, I had just used - remove-circle-ip to run the command rather than putting a run block, i.e.:
jobs:
test:
docker:
...
steps:
- setup
- ...
- add-circle-ip
- ...
- remove-circle-ip
but couldn't figure out how to specify when: always if I did it that way.
But now, when switching to calling my command as part of a run block, it fails with "remove-circle-ip: command not found"
So how can I make this command always run even if steps before fail?
I'm fairly new to CircleCI so there may be a better way to do this, or maybe this shouldn't be done at all, however something similar was done (before I joined) to a project I'm working on. It was achieved by making every step report success, whether it actually succeeded or failed, which allows the command at the end to always run. The commands are all terminal commands, so they just have || true at the end. I'm not sure how you would achieve that with a more complex command or using a builtin command.
In our case the steps that can fail are optional and we don't care if they actually fail or not. However if you want to report the failure I think that you should be able to store the failure from a previous step somewhere, and add a final step that reports it.
I am build different flavor of Flutter app with different Firebase environment (development and production). I need set different bundle ID for development and production in Xcode for iOS apps.
I am use schemes to configure the different flavor (in Build Settings I add environment value for every configuration).
But I have big issue with change $(PRODUCT_BUNDLE_IDENTIFIER). I need add suffix .development to normal app id for development app id.
I have try follow this method(use User Defined Settings) and change info.plist to get variable from User Defined Settings but it not work.
Error is:
The operation couldn’t be completed. Application
“$(EXAMPLE_BUNDLE_ID)" is unknown to FrontBoard.
So it seem when pass in User Defined Setting it is not interpolate correct.
I have also try mix method of add default PRODUCT_BUNDLE_IDENTIFIER and User Defined Settings. For example: com.example.app$(EXAMPLE_BUNDLE_ID) where EXAMPLE_BUNDLE_ID = .development
I also try reference User Defined Setting $(EXAMPLE_BUNDLE_ID) by direct add it to Bundle Identifier in Target General tab under ‘Identity’. But this then change to : -- EXAMPLE_BUNDLE_ID-
I have also try in info.plist use $(PRODUCT_BUNDLE_IDENTIFIER)$(EXAMPLE_BUNDLE_ID) for Bundle Identifier value. But this give similar error:
The operation couldn’t be completed. Application
“com.example.app$(EXAMPLE_BUNDLE_ID)" is unknown to FrontBoard.
Again this look like interpolation issue.
Anyone know solution? I have look but cannot find answer.
This easy for android because just use applicationIdSuffix ".development” in productFlavors. But I cannot find way like this for Xcode.
Do you need to have different package name (Android) and bundle id (iOS) because you need to use Firebase Auth plugin?
In this case for iOS project you shold consider using PlistBuddy and you could set it adding a Run Script in your XCode build phases like that
if [ "${CONFIGURATION}" = "Debug" ]; then
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier com.example.developmento.appName" "$PROJECT_DIR/Runner/Info.plist"
echo "Changed bundle id for developement $PROJECT_DIR/Runner/Info.plist"
else
echo "Nothing to do"
fi
Anyway if you don't use Firebase Auth, you can have the same bundle id in different firebase projects.
If you need then to differenziate firebase projects file between staging and production, you could have a look here:
How to choose between development and production firebase project based on build flavours?
UPDATE
So following OP chat, knowing that he's following this tutorial to setup flutter flavors I've tryed myself to see where we were stuck.
Starting point is the following:
Two Firebase project
Use of Firebase Auth module (so the need to change the bundle id between projects)
And of course two different GoogleService-Info.plist
I start with Xcode bundle id and GoogleService-Info.plist set to production (just an option)
Then I've save both GoogleServices-Info-staging.plist and GoogleServices-Info-production.plist save in my ios/Runner folder
Then I setup this build script before the script for Compile Sources
# Type a script or drag a script file from your workspace to insert its path.
if [ "${CONFIGURATION}" == "Debug" ] || [ "${CONFIGURATION}" == "Debug-Runner-staging" ]; then
echo "Setting up staging firebase environment"
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier com.example.staging.flutterAppAuthFlavours" "${PROJECT_DIR}/Runner/Info.plist"
cp -r "${PROJECT_DIR}/Runner/GoogleService-Info-staging.plist" "${PROJECT_DIR}/Runner/GoogleService-Info.plist"
echo "$(date) staging flavour - Configuration: ${CONFIGURATION}" > "${PROJECT_DIR}/environment.txt"
elif [ "${CONFIGURATION}" == "Debug-Runner-production" ]; then
echo "Setting up production firebase environment"
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier com.example.flutterAppAuthFlavours" "${PROJECT_DIR}/Runner/Info.plist"
cp -r "${PROJECT_DIR}/Runner/GoogleService-Info-production.plist" "${PROJECT_DIR}/Runner/GoogleService-Info.plist"
echo "$(date) production flavour - Configuration: ${CONFIGURATION}" > "${PROJECT_DIR}/environment.txt"
fi
And I called it Setup Firebase Environment (you can call it what you want)
This script store also some logs (with timestamp) in a file called environment.txt inside ios folder in order to easy check what xcode build has done
And now about Schemes and Build Configurations:
I've done two Build Configuration that are the exact copy of my Debug Build Configuration and I called them
Debug-Runner-staging
Debug-Runner-production
The rule of thumb is to name the build configurations as 'Debug-<your flavor>' and you need to have a scheme for every flavors you have, so I have these:
Runner-staging whose Run calls Debug-Runner-staging build configuration
Runner-production whose Run calls Debug-Runner-production build configuration
So now if I call flutter run --flavor Debug-staging I have a build that runs on my staging firebase project.
and if I call flutter run --flavor Debug-production I have a build that runs on my production firebase project.
UPDATE 2
Just for completness you could change bundle id also here:
Anyway it seems that there's a strange behavior that once you build a flavour a second time flutter command build correctly the flavor but run the previos build flavor.
As building with XCode and switching with schemes all works as expected (even the run of the right application) I guess that this could be a flutter command issue. So I suggest you trying file an issue here linking also this SO question/answer.
UPDATE 3
After a bit of intel I've found that flutter tools set the applicaiton launching environment before building the project. So when we change CFBundleIdentifier inside Info.plist the first time, the second time we launch flutter run it takes the previous modified value and try launching this bundle id while during build we are changing it because we are building a different variant.
A possible solution could be to launch a script that change the CFBundleIdentifier inside Info.plist before calling fluetter run.
For example starting with a Info.plist with a production bundle id of com.example.flutterAppAuthFlavours we could do something like that
Here I’ve used sed command just to think different, but you could call always our belowed PlistBuddy to make the change before calling flutter run.
I'm trying to run my iOS testsuite in CircleCI using fastlane scan. Running the tests is working great, but the total time is increased a lot by installing dependencies from cocoapods.
I've tried to cache the Pods directory by doing the following, however, the checksum is changing between the restore_cache step and the save_cache step:
- restore_cache:
key: 1-pods-{{ checksum "Podfile.lock" }}
- run:
name: Install Pods
command: pod install
- save_cache:
key: 1-pods-{{ checksum "Podfile.lock" }}
paths:
- ./Pods
Essentially, the pod install causes the checksum to change even if none of the pods have changed. As such, the key under which it's saved in cache never lines up with what's trying to be restored from cache.
Is there a better way to do this?
Yes, there is a way to make this work. restore_cache accepts key prefixes (https://circleci.com/docs/2.0/configuration-reference/#restore_cache). So to fall back to an earlier cache you can use something like this:
- restore_cache:
keys:
- 1-pods-{{ checksum "Podfile.lock" }}
- 1-pods-
There are some more specific guidelines here: https://circleci.com/docs/2.0/ios-migrating-from-1-2/#installing-cocoapods
These are the complete steps.
- restore_cache:
key: 1-pods-{{ checksum "Podfile.lock" }}
- run:
name: Install CocoaPods
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
- save_cache:
key: 1-pods-{{ checksum "Podfile.lock" }}
paths:
- ./Pods
First step is to restore cache.
Second step, if cache is not found, update the pods repo from circleci mirror and install pods. This step takes around 5 minutes so you better skip it if unnecessary.
Third step, save cache if key is still not occupied
source: https://medium.com/wandercodes/how-to-save-time-in-circleci-when-using-pods-4e00cd419ad8
OK, after running into this exact issue I solved it for myself. I'll leave solution here in case this ends up being the same for others.
What?
When trying to cache and restore cocoapod dependencies on circleci the checksum being used for my cache key is different at restore when compared to save; resulting in never finding a cache key match.
Why?
When circleci was adding my repo as a source it was including the .git extension to my repo. However, when I added the repo to my own machine (i.e., pod repo add <name> <url> I did not include the extension. So, on my local machine when I'd run pod install my Podfile.lock would list my private repo without the .git, which of course factors into the generation of the checksum. Then on circleci, it would go through the same process, but generate a Podfile.lock which did include the .git extension, in turn causing a different checksum, and ultimately a different cache key.
Solution
Remove the private repo from my local machine (i.e., pod repo remove <name>) and add it back again, being sure to include the .git extension as part of the url (i.e., pod repo add <name> https://my-vcs.com/path-to/repo.git).
One note regarding using the fallback method mentioned above. This actually resulted in a Sandbox out of sync error, because the old caches contained pods that were no longer aligned with the current state of the app. So I'd probably avoid using this technique.
I'm looking for a std travis coverity setup for a rails application.
My current .travis.yml file looks like this:
# environment settings
env:
- DB=sqlite
- DB=mysql
- DB=postgresql
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "<SECURE>"
# project language
language: ruby
rvm:
- 2.3.1
# branches to build (whitelist)
branches:
only:
- master
- coverity_scan
- testing
# command to run before install
before_install:
- echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
# arguments for the bundler
bundler_args: --without production development
# addons
addons:
coverity_scan:
project:
name: "<PROJECT_NAME>"
description: "Build submitted via Travis CI"
notification_email: <MY_EMAIL>
build_command_prepend: ""
build_command: "--no-command"
branch_pattern: coverity_scan
# script
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
- bundle exec rspec spec/
- bundle exec cucumber
# run before script
before_script:
- mysql -e 'create database my_app_test'
- psql -c 'create database my_app_test' -U postgres
I'm not sure what to put in the build_command part of addons.coverity_scan. I already tried leaving it empty, --no-command, bundle install, and bundle install --jobs=3 --retry=3, but none of them worked. --no_command, for example, gives me the following message:
Coverity Scan analysis selected for branch coverity_scan.
Coverity Scan analysis authorized per quota.
$ curl -s https://scan.coverity.com/scripts/travisci_build_coverity_scan.sh | COVERITY_SCAN_PROJECT_NAME="$PROJECT_NAME" COVERITY_SCAN_NOTIFICATION_EMAIL="<MY_EMAIL>" COVERITY_SCAN_BUILD_COMMAND="--no-command" COVERITY_SCAN_BUILD_COMMAND_PREPEND="" COVERITY_SCAN_BRANCH_PATTERN=coverity_scan bash
Note: COVERITY_SCAN_PROJECT_NAME and COVERITY_SCAN_TOKEN are available on Project Settings page on scan.coverity.com
Coverity Scan configured to run on branch coverity_scan
Coverity Scan analysis authorized per quota.
Downloading Coverity Scan Analysis Tool...
2016-09-13 23:26:36 URL:https://scan.coverity.com/download/Linux [449455458/449455458] -> "/tmp/cov-analysis-Linux.tgz" [1]
Extracting Coverity Scan Analysis Tool...
/tmp/coverity-scan-analysis ~/build/<PROJECT_NAME>
~/build/<PROJECT_NAME>
Running Coverity Scan Analysis Tool...
Coverity Build Capture (64-bit) version 8.5.0.3 on Linux 3.13.0-92-generic x86_64
Internal version numbers: db70178643 p-kent-push-26368.949
[WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
For more details, please look at:
/home/travis/build/<PROJECT_NAME>/cov-int/build-log.txt
Extracting SCM data for 0 files...
Please see the log file '/home/travis/build/<PROJECT_NAME>/cov-int/scm_log.txt' for warnings and SCM command issues.
[WARNING] Unable to gather all SCM data - see log at /home/travis/build/<PROJECT_NAME>/cov-int/scm_log.txt for details.
Successfully added SCM data for 0 files
Tarring Coverity Scan Analysis results...
Uploading Coverity Scan Analysis results...
And because I'm using travis I'm not able to look into the log files...
When the command is empty it fails with the error, that a command needs to be given and it does nothing.
Can someone help me with some kind of a std setup for a rails app?
Thanks in advance!
Instructions for using Coverity SCAN the new languages supported by 8.5 are found here : https://scan.coverity.com/download?tab=other . We assume that users first read these instructions prior to attempting TravisCI integration. It is also highly recommended that local integration is tested to ensure clean captures before attempting any CI.
Ruby is supported in Coverity 8.5. Debugging this is difficult without the log. It's possible the SCAN kit is missing a config for Ruby, which can be fixed by running cov-configure --ruby.
The more likely problem, however, is that Ruby is what Coverity considers a "non-compiled" language (meaning you don't usually have a build that compiles them before they can be used). So this means you need to inform cov-build about where your Ruby files are. Looking at your travis config, I expect you need to add this to your build_command: --fs-capture-search /path/to/your/ruby/files
It seems that it is not possible to analyse rails (interpreted ones in general) projects (correct me if I'm wrong). I deleted my project from coverity.