How does bundle clean fit into CircleCI cache? - circleci

The CircleCI docs include some information on why bundle clean should be run when cache is involved, but I'm having a hard time understanding how. I'm confused about the code block in the Bundler (Ruby) section here:
https://circleci.com/docs/2.0/caching/#bundler-ruby
The code block in question is:
- run: bundle install & bundle clean
- restore_cache:
keys:
# when lock file changes, use increasingly general patterns to restore cache
- v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
- v1-gem-cache-{{ arch }}-{{ .Branch }}-
- v1-gem-cache-{{ arch }}-
- save_cache:
paths:
- ~/.bundle
key: v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
I'm reading this process as:
Run bundle install before the cache is put in place (a full gem installation time before restoring cache, which negates the time-saving benefits of a cache) and then run bundle clean
Restore the cache over the installed gems
Don't do anything (between restore_cache and save_cache steps)
Save the new cache
Am I understanding that process correctly?
This looks to me like restore_cache and save_cache steps are not going to be effective, because the full bundle install time would have already been spent.
If I'm understanding things, would this be a more effective process?
- restore_cache:
keys:
# when lock file changes, use increasingly general patterns to restore cache
- v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
- v1-gem-cache-{{ arch }}-{{ .Branch }}-
- v1-gem-cache-{{ arch }}-
- run: bundle install & bundle clean
- save_cache:
paths:
- ~/.bundle
key: v1-gem-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
If I'm not understanding this correctly, can anyone help clarify how the suggested code block works?
Update:
It also looks like
- run: bundle install & bundle clean
needs to be modified to
- run: bundle install && bundle clean

I'm pretty sure you are correct and that this is a typo in the CircleCI Docs. I've opened a PR to fix: https://github.com/circleci/circleci-docs/pull/2663

Related

How to deploy CICD for TestFlight on Github Actions

I am quite new on deploying CICD. Currently this is my .yml file:
name: Release IOS
on:
push:
branches:
- github-action
jobs:
build:
name: Build IPA and upload to TestFlight
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Select Xcode Version
uses: maxim-lobanov/setup-xcode#v1
with:
xcode-version: latest-stable
- name: Setup SSH
uses: webfactory/ssh-agent#v0.5.4
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Setup ruby
uses: ruby/setup-ruby#v1
with:
ruby-version: 2.7.2
bundler-cache: true
- name: Setup Node.js
uses: actions/setup-node#v1
with:
node-version: 14.17.0
- name: Install Cordova, Ionic, and cordova-res
run: npm install -g cordova#10.0.0 #ionic/cli cordova-res
- name: Install app dependencies
run: npm install
- name: npx gulp
run: npx gulp
- name: cordova resources
run: ionic cordova resources
- name: Remove Ios platform
run: ionic cordova platform remove ios
- name: Add Ios platform
run: ionic cordova platform add ios
- name: Fix translations problems in IOS
run: ionic cordova plugin add cordova-plugin-ionic-webview
- name: Install #ionic-native/ionic-webview
run: npm install #ionic-native/ionic-webview
- name: Prebuild iOS production
run: npm run prod:ios
- name: Uninstall outdated gems
run: gem cleanup
- name: Publish as internal testing
uses: yukiarrr/ios-build-action#v1.5.0
with:
project-path: ./platforms/ios/MyProject.xcodeproj
p12-base64: ${{ secrets.IOS_P12_BASE64 }}
certificate-password: ${{ secrets.IOS_P12_PASSWORD }}
mobileprovision-base64: ${{ secrets.IOS_PROVISION_FILE }}
code-signing-identity: iOS Distribution
team-id: ${{ secrets.TEAM_ID }}
workspace-path: ./platforms/ios/MyProject.xcworkspace # optional
And this is what I end up with:
[17:53:21]: $ set -o pipefail && xcodebuild -workspace ./platforms/ios/MyProject.xcworkspace -scheme MyProject -configuration Release -destination 'generic/platform=iOS' -archivePath /Users/runner/Library/Developer/Xcode/Archives/2022-05-16/output\ 2022-05-16\ 17.53.21.xcarchive clean archive | tee /Users/runner/Library/Logs/gym/MyProject-MyProject.log | xcpretty
[17:53:29]: ▸ Clean Succeeded
[17:53:39]: ▸ ❌ error: No certificate for team '***' matching 'iOS Distribution' found: Select a different signing certificate for CODE_SIGN_IDENTITY, a team that matches your selected certificate, or switch to automatic provisioning. (in target 'MyProject' from project 'MyProject')
[17:53:39]: ▸ ** ARCHIVE FAILED **
▸ Clean Succeeded
❌ error: No certificate for team '***' matching 'iOS Distribution' found: Select a different signing certificate for CODE_SIGN_IDENTITY, a team that matches your selected certificate, or switch to automatic provisioning. (in target 'MyProject' from project 'MyProject')
** ARCHIVE FAILED **
[17:53:39]: Exit status: 65
[17:53:39]:
[17:53:39]: Maybe the error shown is caused by using the wrong version of Xcode
[17:53:39]: Found multiple versions of Xcode in '/Applications/'
[17:53:39]: Make sure you selected the right version for your project
[17:53:39]: This build process was executed using '/Applications/Xcode_13.2.1.app'
[17:53:39]: If you want to update your Xcode path, either
[17:53:39]:
[17:53:39]: - Specify the Xcode version in your Fastfile
[17:53:39]: ▸ xcversion(version: "8.1") # Selects Xcode 8.1.0
[17:53:39]:
[17:53:39]: - Specify an absolute path to your Xcode installation in your Fastfile
[17:53:39]: ▸ xcode_select "/Applications/Xcode8.app"
[17:53:39]:
[17:53:39]: - Manually update the path using
[17:53:39]: ▸ sudo xcode-select -s /Applications/Xcode.app
[17:53:39]:
+---------------+--------------------------------+
| Build environment |
+---------------+--------------------------------+
| xcode_path | /Applications/Xcode_13.2.1.app |
| gym_version | 2.205.2 |
| export_method | app-store |
| sdk | iPhoneOS15.2.sdk |
+---------------+--------------------------------+
I am pretty sure that my certificate, code sign identity and provisioning profile are all correct, but this error still shows when Publish as internal testing fails. What's the correct way to debug it?
(I add fastlane tag because this plugin is built based on it)
iOS has 2 types of certificates, you must use distribution to deploy.
I have followed this article and done it successfully,
https://www.cobeisfresh.com/blog/how-to-implement-a-ci-cd-workflow-for-ios-using-github-actions
You can read more about article

Ansible - Docker's repository key is missing after using apt module

I'm not sure this issue is related to Ansible or Docker, but here it goes:
I can list Docker's repository key with apt-key:
/etc/apt/trusted.gpg.d/docker-key.gpg
-------------------------------------
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <docker#docker.com>
sub rsa4096 2017-02-22 [S]
I can connect to the Docker repo with it, download everything and so on.
However after I run the following Ansible code, this key just vanishes and I have to set it up again or else I'm unable to connect to the repository.
- name: Update apt cache
apt:
update_cache: yes
cache_valid_time: 3600
- name: Update packages
apt:
upgrade: safe
I'm sure the key disappears after the code snippet above. I would like to know why or if I'm overlooking anything.

Expo build fails in CI but builds locally (babel-preset-expo has been ignored because it contains invalid configuration)

Classic case of it works on my machine. I am building two react-native apps. App A and App B. Both of the applications were bootstrapped using expo.
When I run the command to build either app locally expo build:ios they both build. Yet when I attempt to build the applications in gitlab-ci only application B fails to build with the following message:
[23:07:28] warn Package babel-preset-expo has been ignored because it contains invalid configuration. Reason: Cannot find module 'babel-preset-expo/package.json'
[23:07:28] Require stack:
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/#react-native-community/cli/build/tools/config/resolveNodeModuleDir.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/#react-native-community/cli/build/tools/releaseChecker/index.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/#react-native-community/cli/build/commands/server/runServer.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/#react-native-community/cli/build/commands/server/server.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/#react-native-community/cli/build/commands/index.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/#react-native-community/cli/build/index.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/local-cli/cli.js
[23:07:28]
[23:07:29] Starting Metro Bundler on port 19001.
[23:07:29] debug Watch mode is not supported in this environment
[23:07:29] debug Checking for a newer version of React Native
[23:07:29] debug Current version: 0.61.4
[23:07:29] debug No release cache found
[23:07:29] debug No release cache found
[23:07:29] debug Checking for newer releases on GitHub
[23:07:29] debug No release cache found
[23:07:30] Publishing to channel 'default'...
[23:07:30] debug Saving "6d6386b01438c6ef0acd213d304b5839" to cache
[23:07:30] debug No release cache found
[23:07:30] debug No release cache found
[23:07:30] debug Latest release: 0.60.0
[23:07:32] Building iOS bundle
[23:07:43] node_modules/expo/AppEntry.js: Cannot find module 'babel-preset-expo' from '/builds/XXX/application-b'
[23:07:43] › Closing Expo server
[23:07:43] node_modules/expo/AppEntry.js: Cannot find module 'babel-preset-expo' from '/builds/XXX/application-b'
[23:07:43] Failed building JavaScript bundle.
[23:07:43] ::ffff:127.0.0.1 - - [06/Apr/2020:23:07:43 +0000] "GET /node_modules/expo/AppEntry.bundle?dev=false&minify=true&hot=false&platform=ios HTTP/1.1" 500 - "-" "axios/0.19.0"
[23:07:43] › Stopping Metro bundler
[23:07:43] Packager URL http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?dev=false&minify=true&hot=false&platform=ios returned unexpected code 500. Please open your project in the Expo app and see if there are any errors. Also scroll up and make sure there were no errors or warnings when opening your project.
I have tried having the CI explicitly install the module babel-preset-expo, but that does not fix the issue. My babel.config.js is identical for both apps and looks like this:
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
I have the following lines in my both of my package.json:
"devDependencies": {
"#babel/core": "^7.0.0",
"babel-preset-expo": "^8.0.0"
},
The file in both applications being referenced in the error AppEntry.js is identical as well.
Here is my gitlab-ci.yml:
image: node/alpine
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- ~/.npm
stages:
- deploy
- tag
before_script:
- echo $CI_BUILD_REF
- echo $CI_PROJECT_DIR
- apk add --no-cache bash build-base gcc git python3 curl
- PATCH=`git log --pretty=oneline | wc -l | sed -e 's/^[[:space:]]*//'`
- VERSION=`cat VERSION`
- VERSION=${VERSION%?}
- TAG="${VERSION}${PATCH}"
- echo "Build version = ${TAG}"
expo-build:
stage: deploy
artifacts:
paths:
- ipas/
script:
- sed -i "s/0.0.0/${TAG}/g" app.json
- npm ci --production --cache .npm --prefer-offline
- npx expo login -u $EXPO_USERNAME -p $EXPO_PASSWORD
- EXPO_DEBUG=true npx expo build:ios --non-interactive # This works because it has been already built once through the cli, credentials cannot be pass into env
- mkdir -p ipas
- curl "$(npx expo url:ipa --non-interactive)" -o ipas/bravo-teller-$TAG.ipa
only:
- master
Any feedback or suggestions as to what this could be would be greatly appreciated. Thanks
Actually, the babel-preset-expo is not a devDependencies you should add it to dependencies furthermore likely you should use lazy load by using the following code on your babel configuration:
[
'babel-preset-expo',
{
lazyImports: true,
},
]

I can't build android-27 , tool-27.0.2 with travis.CI

Can any one help me?
Stuck from my side.
https://travis-ci.org/XinyueZ/mvvm-template/jobs/313586340
I can 't build (./gradlew test) it.
my yml is:
language: android
android:
components:
- tools
- platform-tools
- build-tools-27.0.2
- android-27
- add-on
- extra
licenses:
- 'android-sdk-license-.+'
jdk:
- oraclejdk8
script:
- ./gradlew :repository:testMockDebugUnitTest :repository:testProdDebugUnitTest :repository:testProdReleaseUnitTest
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
directories:
- $HOME/.m2
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
buildToolsVersion = '27.0.2'
I have tried 27.0.1 as well, same failed.
I had one or three times successed, just 2 hours later, something went wrong.
same yml, no change.
See here
It seems Google uploaded a new version of the android-27 package and the checksum is now different and the download fails. For the moment, you need to install it yourself using the sdkmanager CLI instead. Here's what you would need to add to your .travis.yml file:
before_install:
- yes | sdkmanager "platforms;android-27"

The SDK directory does not exist Travis CI

I have this .travis.yml file, but I am constantly getting this error when building:
* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '/home/travis/build/Me/MyProject/C:\Users\Me\AppData\Local\Android\Sdk' does not exist.
My .travis.yml
language: android
before_install:
- chmod +x gradlew
script:
- ./gradlew clean assembleDebug
install:
- true
- chmod +x ./gradlew; ls -l gradlew; ./gradlew wrapper -v
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
# - platform-tools
# - tools
# The BuildTools version used by your project
- build-tools-23.0.3
# The SDK version used to compile your project
- android-23
# Additional components
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-23
# Specify at least one system image,
# if you need to run emulator(s) during your tests
- sys-img-armeabi-v7a-android-23
- sys-img-x86-android-17
I cannot find anything on google about it, so I don't know how to fix it
Do not commit your local.properties file into your repository.

Resources