diff --git a/.github/workflows/pr for android.yml b/.github/workflows/archive/pr for android.yml similarity index 100% rename from .github/workflows/pr for android.yml rename to .github/workflows/archive/pr for android.yml diff --git a/.github/workflows/pullrequest_unittests.yml b/.github/workflows/pullrequest_unittests.yml new file mode 100644 index 000000000..15cfe527a --- /dev/null +++ b/.github/workflows/pullrequest_unittests.yml @@ -0,0 +1,68 @@ + name: Build & Test Pull Requests Unit Tests + + on: + pull_request: + branches: + - main + + env: + DOTNET_NOLOGO: true # Disable the .NET logo + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # Disable the .NET first time experience + DOTNET_CLI_TELEMETRY_OPTOUT: true # Disable sending .NET CLI telemetry + + jobs: + unit-tests : + runs-on: ubuntu-latest + name: Unit Tests + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install KVM and Android SDK (x86) + run: | + # Set up environment variables + export ANDROID_SDK_ROOT=$HOME/android-sdk + export ANDROID_HOME=$ANDROID_SDK_ROOT + export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator:$PATH + + # Create necessary directories + mkdir -p $ANDROID_SDK_ROOT/cmdline-tools + + # Download and install command-line tools + wget -q https://dl.google.com/android/repository/commandlinetools-linux-10406996_latest.zip + unzip -q commandlinetools-linux-*.zip -d $ANDROID_SDK_ROOT/cmdline-tools + mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest + chmod +x $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager + + # Accept licenses and install required components + yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses + # Install Android API level 34 and necessary system images + $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager "platform-tools" "emulator" "platforms;android-34" "system-images;android-34;google_apis;x86_64" + + # Export paths for future steps + echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" >> $GITHUB_ENV + echo "ANDROID_HOME=$ANDROID_SDK_ROOT" >> $GITHUB_ENV + echo "PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/emulator:$PATH" >> $GITHUB_ENV + + - name: Install Android Build Tools + run: | + echo "Installing Android Build Tools..." + sdkmanager "build-tools;34.0.0" # Updated to use Android 34 build tools + sdkmanager --update + + - name: Set up .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + + - name: Install MAUI Workloads + run: dotnet workload install maui-android + + - name: Restore Dependencies + run: dotnet restore TransactionMobile.Maui.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json + + - name: Build Code + run: dotnet build TransactionMobile.Maui/TransactionMobile.Maui.csproj -c Release -f net8.0-android --no-restore + + - name: Run Unit Tests + run: dotnet test TransactionMobile.Maui.BusinessLogic.Tests/TransactionMobile.Maui.BusinessLogic.Tests.csproj -c Release -f net8.0-android --no-restore \ No newline at end of file diff --git a/TransactionMobile.Maui.BusinessLogic.Tests/TransactionMobile.Maui.BusinessLogic.Tests.csproj b/TransactionMobile.Maui.BusinessLogic.Tests/TransactionMobile.Maui.BusinessLogic.Tests.csproj index 790e78de5..03384dbcd 100644 --- a/TransactionMobile.Maui.BusinessLogic.Tests/TransactionMobile.Maui.BusinessLogic.Tests.csproj +++ b/TransactionMobile.Maui.BusinessLogic.Tests/TransactionMobile.Maui.BusinessLogic.Tests.csproj @@ -1,14 +1,8 @@  - net8.0-android - - - $(TargetFrameworks);net8.0-windows10.0.19041.0 - - - - $(TargetFrameworks);net8.0-ios;net8.0-maccatalyst - + + net8.0 true None diff --git a/TransactionMobile.Maui.BusinessLogic/TransactionMobile.Maui.BusinessLogic.csproj b/TransactionMobile.Maui.BusinessLogic/TransactionMobile.Maui.BusinessLogic.csproj index a4ac4c2eb..1f97c2558 100644 --- a/TransactionMobile.Maui.BusinessLogic/TransactionMobile.Maui.BusinessLogic.csproj +++ b/TransactionMobile.Maui.BusinessLogic/TransactionMobile.Maui.BusinessLogic.csproj @@ -1,9 +1,9 @@  - - net8.0-android + net8.0-android;net8.0-ios;net8.0;net8.0-maccatalyst + $(TargetFrameworks);net8.0-windows10.0.19041.0 + true true