Skip to content

Commit

Permalink
187: Clean up and streamline CI
Browse files Browse the repository at this point in the history
  • Loading branch information
steffenkleinle committed Nov 28, 2024
1 parent 7451776 commit 27b5374
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 147 deletions.
177 changes: 90 additions & 87 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,103 @@ commands:
- run:
command: circleci config validate
name: Validate circle config
install_dart_linux:
install_fastlane:
description: Restores and saves fastlane cache of the passed directory.
parameters:
directory:
type: string
steps:
- restore_cache:
keys:
- v1-gems-{{ arch }}-{{ checksum "<< parameters.directory >>/Gemfile.lock" }}
- v1-gems-{{ arch }}-
name: Restore Fastlane Cache
- run:
command: |
curl -o dart.deb https://storage.googleapis.com/dart-archive/channels/stable/release/3.5.3/linux_packages/dart_3.5.3-1_amd64.deb
sudo dpkg -i dart.deb
name: Install Dart
install_fvm:
command: bundle config set path 'vendor/bundle'
name: Configure Installation Directory
working_directory: << parameters.directory >>
- run:
command: bundle check || bundle install
name: '[FL] Install'
working_directory: << parameters.directory >>
- save_cache:
key: v1-gems-{{ arch }}-{{ checksum "<< parameters.directory >>/Gemfile.lock" }}
name: Save Fastlane Cache
paths:
- << parameters.directory >>/vendor/bundle
install_flutter:
parameters:
precache:
default: none
enum:
- none
- android
- ios
type: enum
steps:
- run:
command: |
dart pub global activate fvm
echo 'export PATH=$HOME/.pub-cache/bin:$PATH' >> $BASH_ENV
export PATH="$PATH":"$HOME/.pub-cache/bin"
command: curl -fsSL https://fvm.app/install.sh | bash
name: Install FVM
- restore_cache:
keys:
- v1-fvm-{{ checksum ".fvmrc" }}-{{ arch }}
- v1-fvm-{{ arch }}-{{ checksum ".fvmrc" }}-{{ checksum "pubspec.yaml" }}-{{ checksum "pubspec.lock" }}-{{ arch }}
- v1-fvm-{{ arch }}-
- run:
command: fvm install
name: Install Flutter
- run:
command: fvm flutter config --no-analytics
name: Configure Flutter
- run:
command: fvm flutter --version
name: Show Flutter version
- run:
command: fvm flutter pub get --enforce-lockfile
name: Install Flutter Packages
- unless:
condition:
equal:
- << parameters.precache >>
- none
steps:
- run:
command: fvm flutter precache --<< parameters.precache >>
name: Precache Flutter Binary Artifacts
working_directory: << parameters.precache >>
- save_cache:
key: v1-fvm-{{ checksum ".fvmrc" }}-{{ arch }}
key: v1-fvm-{{ arch }}-{{ checksum ".fvmrc" }}-{{ checksum "pubspec.yaml" }}-{{ checksum "pubspec.lock" }}
paths:
- .fvm
- ~/fvm/
install_gradle_dependencies:
description: Restores and saves the gradle cache.
steps:
- restore_cache:
keys:
- v1-gradle-{{ checksum "android/build.gradle" }}-{{ checksum "android/app/build.gradle" }}-{{ checksum "android/settings.gradle" }}
- v1-gradle-
- run:
command: fvm flutter --version
name: Show Flutter version
command: bundle exec fastlane dependencies
name: '[FL] Download Dependencies'
- save_cache:
key: v1-gradle-{{ checksum "android/build.gradle" }}-{{ checksum "android/app/build.gradle" }}-{{ checksum "android/settings.gradle" }}
paths:
- ~/.gradle
install_node_modules:
description: Restores and saves the node_modules directories of the tools directory.
steps:
- restore_cache:
keys:
- v1-node-modules-{{ checksum "tools/package.json" }}-{{checksum "tools/package-lock.json" }}
- v1-node-modules-
- run:
command: fvm flutter config --no-analytics
name: Configure Flutter
command: '[ ! -d node_modules ] && npm ci --ignore-scripts --loglevel warn --yes || echo package.json and package-lock.json unchanged. Using cache.'
name: Install node dependencies for npm workspaces
working_directory: tools
- save_cache:
key: v1-node-modules-{{ checksum "tools/package.json" }}-{{checksum "tools/package-lock.json" }}
paths:
- ~/tools/node_modules
persist_environment_variables:
description: Sets the environment variables specified in the file 'environment_variables'. Make sure the file is persisted and has been attached.
steps:
Expand Down Expand Up @@ -103,59 +168,6 @@ commands:
- run:
command: cat ~/attached_workspace/environment_variables >> ${BASH_ENV}
name: Restore environment variables
restore_gradle_cache:
description: Restores and saves the gradle cache.
steps:
- restore_cache:
keys:
- v1-gradle-{{ checksum "android/build.gradle" }}-{{ checksum "android/app/build.gradle" }}-{{ checksum "android/settings.gradle" }}
- v1-gradle-
- run:
command: bundle exec fastlane dependencies
name: '[FL] Download Dependencies'
- save_cache:
key: v1-gradle-{{ checksum "android/build.gradle" }}-{{ checksum "android/app/build.gradle" }}-{{ checksum "android/settings.gradle" }}
paths:
- ~/.gradle
restore_npm_cache:
description: Restores and saves the node_modules directories of the tools directory.
steps:
- restore_cache:
keys:
- v1-node-modules-{{ checksum "tools/package.json" }}-{{checksum "tools/package-lock.json" }}
- v1-node-modules-
- run:
command: '[ ! -d node_modules ] && npm ci --ignore-scripts --loglevel warn --yes || echo package.json and package-lock.json unchanged. Using cache.'
name: Install node dependencies for npm workspaces
working_directory: tools
- save_cache:
key: v1-node-modules-{{ checksum "tools/package.json" }}-{{checksum "tools/package-lock.json" }}
paths:
- ~/tools/node_modules
restore_ruby_cache:
description: Restores and saves fastlane cache of the passed directory.
parameters:
directory:
type: string
steps:
- restore_cache:
keys:
- v1-gems-{{ arch }}-{{ checksum "<< parameters.directory >>/Gemfile.lock" }}
- v1-gems-{{ arch }}-
name: Restore Ruby Cache
- run:
command: bundle config set path 'vendor/bundle'
name: Configure Installation Directory
working_directory: << parameters.directory >>
- run:
command: bundle check || bundle install
name: '[FL] Install'
working_directory: << parameters.directory >>
- save_cache:
key: v1-gems-{{ arch }}-{{ checksum "<< parameters.directory >>/Gemfile.lock" }}
name: Save Ruby Cache
paths:
- << parameters.directory >>/vendor/bundle
jobs:
build_android:
docker:
Expand All @@ -169,17 +181,12 @@ jobs:
- checkout
- prepare_workspace
- restore_environment_variables
- install_dart_linux
- install_fvm
- restore_ruby_cache:
directory: android
- run:
command: |
fvm flutter pub get --enforce-lockfile
fvm flutter precache --android
name: Install Flutter Packages
working_directory: android
- install_flutter:
precache: android
- prepare_project
- install_gradle_dependencies
- install_fastlane:
directory: android
- run:
command: bundle exec fastlane android build version_name:${NEW_VERSION_NAME} version_code:${NEW_VERSION_CODE}
name: '[FL] Build'
Expand Down Expand Up @@ -212,7 +219,7 @@ jobs:
shell: /bin/bash -eo pipefail
steps:
- checkout
- restore_npm_cache
- install_node_modules
- run:
command: echo "export NEW_VERSION_NAME=$(yarn --silent next-version calc | jq .versionName)" >> ${BASH_ENV}
name: Calculate next version name
Expand All @@ -237,11 +244,7 @@ jobs:
steps:
- checkout
- check_circleci_config
- install_dart_linux
- install_fvm
- run:
command: fvm flutter pub get --enforce-lockfile
name: Install Flutter Packages
- install_flutter
- run:
command: fvm dart format -l 120 -o none --set-exit-if-changed .
name: Check Formatting
Expand All @@ -264,8 +267,8 @@ jobs:
- checkout
- prepare_workspace
- restore_environment_variables
- restore_npm_cache
- restore_ruby_cache:
- install_node_modules
- install_fastlane:
directory: android
- run:
command: echo "export ANDROID_RELEASE_ID='$(yarn --silent github-release create android ${NEW_VERSION_NAME} ${NEW_VERSION_CODE} --production-delivery << parameters.production_delivery >> --github-private-key ${GITHUB_PRIVATE_KEY} --owner ${CIRCLE_PROJECT_USERNAME} --repo ${CIRCLE_PROJECT_REPONAME} --release-notes "Release v${NEW_VERSION_NAME}+${NEW_VERSION_CODE}")'" >> ${BASH_ENV}
Expand Down
6 changes: 0 additions & 6 deletions .circleci/src/commands/install_dart_linux.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ parameters:
type: string
steps:
- restore_cache:
name: Restore Ruby Cache
name: Restore Fastlane Cache
keys:
- v1-gems-{{ arch }}-{{ checksum "<< parameters.directory >>/Gemfile.lock" }}
- v1-gems-{{ arch }}-
Expand All @@ -17,7 +17,7 @@ steps:
command: bundle check || bundle install
working_directory: << parameters.directory >>
- save_cache:
name: Save Ruby Cache
name: Save Fastlane Cache
key: v1-gems-{{ arch }}-{{ checksum "<< parameters.directory >>/Gemfile.lock" }}
paths:
- << parameters.directory >>/vendor/bundle
38 changes: 38 additions & 0 deletions .circleci/src/commands/install_flutter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
parameters:
precache:
type: enum
default: none
enum: [none, android, ios]
steps:
- run:
name: Install FVM
command: curl -fsSL https://fvm.app/install.sh | bash
- restore_cache:
keys:
- v1-fvm-{{ arch }}-{{ checksum ".fvmrc" }}-{{ checksum "pubspec.yaml" }}-{{ checksum "pubspec.lock" }}-{{ arch }}
- v1-fvm-{{ arch }}-
- run:
name: Install Flutter
command: fvm install
- run:
name: Configure Flutter
command: fvm flutter config --no-analytics
- run:
name: Show Flutter version
command: fvm flutter --version
- run:
name: Install Flutter Packages
command: fvm flutter pub get --enforce-lockfile
- unless:
condition:
equal: [<< parameters.precache >>, none]
steps:
- run:
name: Precache Flutter Binary Artifacts
command: fvm flutter precache --<< parameters.precache >>
working_directory: << parameters.precache >>
- save_cache:
key: v1-fvm-{{ arch }}-{{ checksum ".fvmrc" }}-{{ checksum "pubspec.yaml" }}-{{ checksum "pubspec.lock" }}
paths:
- .fvm
- ~/fvm/
24 changes: 0 additions & 24 deletions .circleci/src/commands/install_fvm.yml

This file was deleted.

15 changes: 5 additions & 10 deletions .circleci/src/jobs/build_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ steps:
- checkout
- prepare_workspace
- restore_environment_variables
- install_dart_linux
- install_fvm
- restore_ruby_cache:
directory: android
- run:
name: Install Flutter Packages
command: |
fvm flutter pub get --enforce-lockfile
fvm flutter precache --android
working_directory: android
- install_flutter:
precache: android
- prepare_project
- install_gradle_dependencies
- install_fastlane:
directory: android
# - run:
# name: '[FL] Prepare Android Keystore'
# command: bundle exec fastlane keystore
Expand Down
2 changes: 1 addition & 1 deletion .circleci/src/jobs/bump_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resource_class: small
shell: /bin/bash -eo pipefail
steps:
- checkout
- restore_npm_cache
- install_node_modules
- run:
name: Calculate next version name
command: echo "export NEW_VERSION_NAME=$(yarn --silent next-version calc | jq .versionName)" >> ${BASH_ENV}
Expand Down
7 changes: 2 additions & 5 deletions .circleci/src/jobs/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ shell: /bin/bash -eo pipefail
steps:
- checkout
- check_circleci_config
- install_dart_linux
- install_fvm
- run:
name: Install Flutter Packages
command: fvm flutter pub get --enforce-lockfile
- install_flutter
- run:
name: Check Formatting
command: fvm dart format -l 120 -o none --set-exit-if-changed .
# Prepare project after formatting check to avoid errors due to autogenerated files
- prepare_project
- run:
name: Check Analyzer and Linting
Expand Down
4 changes: 2 additions & 2 deletions .circleci/src/jobs/deliver_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ steps:
- checkout
- prepare_workspace
- restore_environment_variables
- restore_npm_cache
- restore_ruby_cache:
- install_node_modules
- install_fastlane:
directory: android
# - run:
# name: '[FL] Play Store Upload'
Expand Down
Loading

0 comments on commit 27b5374

Please sign in to comment.