diff --git a/.nx/workflows/agents.yaml b/.nx/workflows/agents.yaml index d5786201..c8c678a5 100644 --- a/.nx/workflows/agents.yaml +++ b/.nx/workflows/agents.yaml @@ -15,7 +15,26 @@ launch-templates: uses: 'nrwl/nx-cloud-workflows/v3.5/workflow-steps/cache/main.yaml' env: KEY: 'pom.xml|build.gradle|build.gradle.kts|settings.gradle|settings.gradle.kts' - PATHS: '~/.m2/repository' + PATHS: | + ~/.m2/repository + ~/.sdkman + BASE_BRANCH: 'develop' + + - name: Restore Flutter Cache + uses: 'nrwl/nx-cloud-workflows/v3.5/workflow-steps/cache/main.yaml' + env: + KEY: '"flutter-sdk"|~/flutter/version|pubspec.yaml' + PATHS: | + ~/flutter + ~/.pub-cache + BASE_BRANCH: 'develop' + + - name: Restore Android Cache + uses: 'nrwl/nx-cloud-workflows/v3.5/workflow-steps/cache/main.yaml' + env: + KEY: '"android-sdk"' + PATHS: | + ~/android/sdk BASE_BRANCH: 'develop' - name: Install Node Modules @@ -34,32 +53,31 @@ launch-templates: flutterPkgName="flutter_linux_${flutterVersion}-${flutterChannel}.tar.xz" flutterPkgUrl="https://storage.googleapis.com/flutter_infra_release/releases/${flutterChannel}/linux/${flutterPkgName}" - if [ ! -d $HOME/flutter ] - then + if [ ! -d $HOME/flutter ] then echo "⬇️ Downloading and Installing Flutter from $flutterPkgName..." curl -s -L ${flutterPkgUrl} | tar -xJf - -C $HOME - echo "PATH=$HOME/flutter/bin:$PATH" >> $NX_CLOUD_ENV - echo 'export PATH="$HOME/flutter/bin:$PATH"' >> $HOME/.profile - source $HOME/.profile else echo "⏭️ Flutter v$flutterPkgName already installed. Skipping it" fi + echo "PATH=$HOME/flutter/bin:$PATH" >> $NX_CLOUD_ENV + echo 'export PATH="$HOME/flutter/bin:$PATH"' >> $HOME/.profile + source $HOME/.profile + echo "⌛️ Checking Flutter Installation and Version..." flutter --version echo "✅ Done !" - name: Install SDKMan! and Java script: | - if [ ! -d $HOME/.sdkman ] - then + if [ ! -d $HOME/.sdkman ] then echo "⬇️ Downloading and Installing SDKMan!..." curl -s "https://get.sdkman.io" | bash - source $HOME/.sdkman/bin/sdkman-init.sh else echo "⏭️ SDKMan! already installed. Skipping it" fi + source $HOME/.sdkman/bin/sdkman-init.sh sdk version jdkVersion="${JDK_VERSION:-17.0.10}" @@ -67,19 +85,19 @@ launch-templates: javaVersion="${jdkVersion}-${jdkDistro}" JAVA_HOME="$HOME/.sdkman/candidates/java/$javaVersion" - if [ ! -d $JAVA_HOME ] - then + if [ ! -d $JAVA_HOME ] then echo "⌛️ Installing Java v$javaVersion.." sdk install java $javaVersion sdk use java $javaVersion - echo "JAVA_HOME=$JAVA_HOME" >> $NX_CLOUD_ENV - echo "PATH=$JAVA_HOME/bin:$PATH" >> $NX_CLOUD_ENV - echo 'export JAVA_HOME="$JAVA_HOME"' >> $HOME/.profile - source $HOME/.profile else echo "⏭️ Java v$javaVersion already installed. Skipping it" fi + echo "JAVA_HOME=$JAVA_HOME" >> $NX_CLOUD_ENV + echo "PATH=$JAVA_HOME/bin:$PATH" >> $NX_CLOUD_ENV + echo 'export JAVA_HOME="$JAVA_HOME"' >> $HOME/.profile + source $HOME/.profile + echo "⌛️ Checking Java Installation and Version..." java -version echo "✅ Done !" @@ -98,26 +116,37 @@ launch-templates: unzip -qq sdk-tools.zip -d $ANDROID_HOME/cmdline-tools mv $ANDROID_HOME/cmdline-tools/cmdline-tools $ANDROID_HOME/cmdline-tools/latest rm -f sdk-tools.zip - echo 'export ANDROID_HOME="$ANDROID_HOME"' >> $HOME/.profile - echo "ANDROID_HOME=$ANDROID_HOME" >> $NX_CLOUD_ENV - echo "PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH" >> $NX_CLOUD_ENV - echo 'export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"' >> $HOME/.profile - source $HOME/.profile - - #yes | sdkmanager --licenses else - echo "⏭️ Android SDK already installed. Skipping it" + echo "⏭️ Android SDK already installed. Skipping it" fi + echo 'export ANDROID_HOME="$ANDROID_HOME"' >> $HOME/.profile + echo "ANDROID_HOME=$ANDROID_HOME" >> $NX_CLOUD_ENV + echo "PATH=$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH" >> $NX_CLOUD_ENV + echo 'export PATH="$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"' >> $HOME/.profile + source $HOME/.profile + echo "ℹ️ Android SDK Manager version: `sdkmanager --version`" echo "📚 Android SDK Manager - Accepting licenses..." # https://discuss.circleci.com/t/build-fails-on-acceptance-of-license-agreements/27828/5 yes | sdkmanager --licenses || if [ $? -ne '141' ]; then exit $?; fi; > /dev/null #Captures SIGPIPE 141 error but still allow repeating "y" to accept all licenses - # Install specific version and platform tools (if not already installed) - if [[ "$SDK_VERSION" != "latest" ]]; then - sdkmanager --update # Update tools if necessary - sdkmanager "platforms;android-$SDK_VERSION" "build-tools;$SDK_VERSION.0.0" "platform-tools" + if [ ! -d "$ANDROID_HOME/platforms/android-$SDK_VERSION" ] then + sdkmanager "platforms;android-$SDK_VERSION" + else + echo "⏭️ 'platforms;android-$SDK_VERSION' already installed. Skipping it" + fi + + if [ ! -d "$ANDROID_HOME/build-tools/$SDK_VERSION" ] then + sdkmanager "build-tools;$SDK_VERSION.0.0" + else + echo "⏭️ 'build-tools;$SDK_VERSION.0.0' already installed. Skipping it" + fi + + if [ ! -d "$ANDROID_HOME/platform-tools" ] then + sdkmanager "platform-tools" + else + echo "⏭️ 'platform-tools' already installed. Skipping it" fi echo "✅ Done !"