Skip to content

Commit

Permalink
chore: upgrade flutter to 3.22.1 (#515)
Browse files Browse the repository at this point in the history
* chore: upgrade flutter to 3.22.1, dart to 3.3.4

* chore: run code generator

* chore: upgrade android code to be compatible with latest flutter version

* chore: upgrade ios project

* fix: restore generated swagger files

* fix: `cat-voice` flutter builder ci (#521)

* fix: add earthly ignore

* fix: use flutter ci from cat ci

* fix: flutter build target

* fix: update cat-gateway code gen

* fix: earthly ignore

* fix: update build

* fix: flutter build target

* fix: flutter builder

* fix: remove browser installer

* chore: upgrade flutter web projects

* fix: revert wrong nginx app path

---------

Co-authored-by: Dominik Toton <[email protected]>
Co-authored-by: Lucio Baglione <[email protected]>
Co-authored-by: Steven Johnson <[email protected]>
Co-authored-by: bkioshn <[email protected]>
  • Loading branch information
5 people authored Jun 4, 2024
1 parent 0a11853 commit af18017
Show file tree
Hide file tree
Showing 45 changed files with 355 additions and 456 deletions.
8 changes: 8 additions & 0 deletions .earthlyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Files and directories created by pub
.dart_tool/
.packages
build/
pubspec.lock
pubspec_overrides.yaml
.flutter-plugins
.flutter-plugins-dependencies
95 changes: 32 additions & 63 deletions catalyst_voices/Earthfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,13 @@
VERSION 0.8

IMPORT ../catalyst-gateway AS catalyst-gateway
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:fix/flutter-builder-ci AS flutter-ci

# If running this target with a local ssh agent active, set the environment
# variable EARTHLY_SSH_AUTH_SOCK='' to make the `+deps` target work. Earthly
# defaults to ssh authentication when it founds an ssh agent active but the
# flutter repo needs to be cloned via https to properly use the `channel`
# subcommand.
deps:
FROM debian:bookworm-slim
ARG TARGETARCH
ARG FLUTTER_VERSION=3.19.5
RUN apt-get update
RUN apt-get install -y git curl unzip bzip2 bash jq gpg lcov
COPY --dir test_driver/scripts .
RUN chmod +x scripts/install-chrome-linux64.sh && ./scripts/install-chrome-linux64.sh
RUN chmod +x scripts/install-edge-linux64.sh && ./scripts/install-edge-linux64.sh
RUN chmod +x scripts/install-firefox-linux64.sh && ./scripts/install-firefox-linux64.sh

WORKDIR /frontend

RUN git clone --depth 1 --branch $FLUTTER_VERSION https://github.com/flutter/flutter.git /usr/local/flutter
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:$HOME/.pub-cache/bin:${PATH}"
RUN flutter --version
RUN flutter doctor -v
RUN flutter config --enable-web
RUN dart pub global activate melos
RUN dart pub global activate junitreport
RUN dart pub global activate coverage

src:
FROM +deps
# builder - Copy all the necessary files and running bootstrap
builder:
DO flutter-ci+SETUP
COPY ../+repo-catalyst-voices-all/repo .
RUN melos bootstrap
DO flutter-ci+BOOTSTRAP

# code-generator - Generates flutter code.
# Based on Catalyst Gateway OpenAPI specifications generates models, clients
Expand All @@ -41,60 +16,54 @@ src:
# proper folder of `catalyst_voices_services` local code.
code-generator:
ARG save_locally=false

FROM +src
WORKDIR /frontend/catalyst_voices/packages/catalyst_voices_services

LET gen_code_path = lib/generated/catalyst_gateway
LET local_gen_code_path = packages/catalyst_voices_services/lib/generated/catalyst_gateway/

FROM +builder
WORKDIR catalyst_voices/packages/catalyst_voices_services
COPY catalyst-gateway+build/doc/cat-gateway-api.json openapi/cat-gateway-api.json
RUN flutter pub get
RUN dart run build_runner build --delete-conflicting-outputs
DO flutter-ci+OPENAPI_CODE_GEN \
--SAVE_LOCALLY=$save_locally \
--GEN_CODE_PATH=$gen_code_path \
--LOCAL_GEN_CODE_PATH=$local_gen_code_path

IF [ $save_locally = true ]
SAVE ARTIFACT lib/generated/catalyst_gateway/* AS LOCAL ./packages/catalyst_voices_services/lib/generated/catalyst_gateway/
ELSE
SAVE ARTIFACT lib/generated/catalyst_gateway
END

# check-flutter-code-generator - Checks that the code generation is consistent
# with the generated code currently in the repo.
# TODO: enable it
flutter-code-generator:
check-flutter-code-generator:
FROM +code-generator
# Copy generated files in the local file tree to a temporary folder
COPY packages/catalyst_voices_services/lib/generated/catalyst_gateway /tmp/repo_generated
# Check diff between local code and earthly artifacts
RUN diff /tmp/repo_generated lib/generated/catalyst_gateway

# check-static-analysis - Runs static analysis on the code
check-static-analysis:
FROM +src
RUN melos analyze --fatal-infos --fatal-warnings
FROM +builder
DO flutter-ci+ANALYZE

# check-code-formatting - Runs code formatting checks
check-code-formatting:
FROM +src
RUN melos run format-check

# Build web version of Catalyst Voices
build:
FROM +src

WORKDIR /frontend/catalyst_voices
RUN flutter clean
RUN flutter pub get
RUN flutter build web --web-renderer canvaskit --release --target lib/configs/main_web.dart
FROM +builder
DO flutter-ci+FORMAT

WORKDIR /frontend/catalyst_voices/build
SAVE ARTIFACT web /web AS LOCAL web
# build-web - Build web version of Catalyst Voices
build-web:
FROM +builder
ARG WORKDIR=/frontend/catalyst_voices
DO flutter-ci+BUILD_WEB --TARGET=lib/configs/main_web.dart --WORKDIR=$WORKDIR
SAVE ARTIFACT web

# test-unit - Run unit tests
test-unit:
FROM +src
RUN melos run test-report
WAIT
SAVE ARTIFACT test_reports AS LOCAL test_reports
END
FROM +builder
DO flutter-ci+UNIT_TESTS

package:
FROM nginx:alpine3.18
ARG tag='latest'
COPY +build/web /app
COPY +build-web/web /app
COPY ./nginx.conf /etc/nginx/nginx.conf
EXPOSE 80

Expand Down
4 changes: 2 additions & 2 deletions catalyst_voices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ This repository contains the Catalyst Voices app and packages.

## Requirements

* flutter: 3.19.+
* Dart: 3.3.0+
* flutter: 3.22.1+
* Dart: 3.3.4+
* Ruby: 2.5+
* Xcode: 15.0+
* Android Studio: Android Studio Electric Eel | 2022.1.1 +
Expand Down
16 changes: 6 additions & 10 deletions catalyst_voices/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -27,10 +28,6 @@ if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion flutter.compileSdkVersion

Expand Down Expand Up @@ -115,7 +112,6 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.3'
Expand Down

This file was deleted.

13 changes: 0 additions & 13 deletions catalyst_voices/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
buildscript {
ext.kotlin_version = '1.9.22'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
30 changes: 22 additions & 8 deletions catalyst_voices/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.9.22" apply false
}

include ":app"
6 changes: 3 additions & 3 deletions catalyst_voices/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
integration_test: 13825b8a9334a850581300559b8839134b124670
integration_test: ce0a3ffa1de96d1a89ca0ac26fca7ea18a749ef4
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586

PODFILE CHECKSUM: ff9ae414ffbc80ad6f9d2058e299051a15f6eca7

COCOAPODS: 1.15.0
COCOAPODS: 1.15.2
2 changes: 1 addition & 1 deletion catalyst_voices/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version: 0.1.0+1
publish_to: none

environment:
sdk: ">=3.3.0 <4.0.0"
flutter: 3.19.5
sdk: ">=3.3.4 <4.0.0"
flutter: 3.22.1

dependencies:
catalyst_voices_assets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,8 @@

<title>example</title>
<link rel="manifest" href="manifest.json">

<script>
// The value below is injected by flutter build, do not touch.
const serviceWorkerVersion = null;
</script>
<!-- This script adds the flutter initialization JS code -->
<script src="flutter.js" defer></script>
</head>
<body>
<script>
window.addEventListener('load', function(ev) {
// Download main.dart.js
_flutter.loader.loadEntrypoint({
serviceWorker: {
serviceWorkerVersion: serviceWorkerVersion,
},
onEntrypointLoaded: function(engineInitializer) {
engineInitializer.initializeEngine().then(function(appRunner) {
appRunner.runApp();
});
}
});
});
</script>
<script src="flutter_bootstrap.js" async></script>
</body>
</html>
4 changes: 2 additions & 2 deletions catalyst_voices/packages/catalyst_voices_assets/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version: 0.1.0+1
publish_to: none

environment:
sdk: ">=3.3.0 <4.0.0"
flutter: 3.19.5
sdk: ">=3.3.4 <4.0.0"
flutter: 3.22.1

dependencies:
flutter:
Expand Down
4 changes: 2 additions & 2 deletions catalyst_voices/packages/catalyst_voices_blocs/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version: 0.1.0+1
publish_to: none

environment:
sdk: ">=3.3.0 <4.0.0"
flutter: 3.19.5
sdk: ">=3.3.4 <4.0.0"
flutter: 3.22.1

dependencies:
bloc: ^8.1.2
Expand Down
4 changes: 2 additions & 2 deletions catalyst_voices/packages/catalyst_voices_brands/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version: 0.1.0+1
publish_to: none

environment:
sdk: ">=3.3.0 <4.0.0"
flutter: 3.19.5
sdk: ">=3.3.4 <4.0.0"
flutter: 3.22.1

dependencies:
catalyst_voices_assets:
Expand Down
Loading

0 comments on commit af18017

Please sign in to comment.