Skip to content

Update dotnet-desktop.yml #730

Update dotnet-desktop.yml

Update dotnet-desktop.yml #730

name: .NET Core Desktop
on:
workflow_dispatch:
push:
branches: [ "master","TeslaFleetAPI"]
pull_request:
branches: [ "master", "TeslaFleetAPI"]
jobs:
build:
strategy:
matrix:
configuration: [Debug]
runs-on: windows-2019 # For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
env:
Solution_Name: TeslaLogger.sln # Replace with your solution name, i.e. MyWpfApp.sln.
Test_Project_Path: UnitTestsTeslalogger\UnitTestsTeslalogger.csproj # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj.
steps:
- name: Cache MariaDB
id: cache-mariadb
uses: actions/cache@v3
with:
path: C:\MariaDB
key: ${{ runner.os }}-mariadb-${{ hashFiles('mariadb-10.0.1.zip') }}
restore-keys: |
${{ runner.os }}-mariadb-
- name: Download MariaDB 10.0.1 Installer
if: steps.cache-mariadb.outputs.cache-hit != 'true'
run: |
curl -L -o mariadb-10.0.1.zip https://archive.mariadb.org/mariadb-10.0.1/winx64-packages/mariadb-10.0.1-winx64.zip
- name: Create target folder for MariaDB
if: steps.cache-mariadb.outputs.cache-hit != 'true'
run: |
mkdir C:\MariaDB
- name: Unzip MariaDB files
if: steps.cache-mariadb.outputs.cache-hit != 'true'
run: |
powershell -Command "Expand-Archive -Path mariadb-10.0.1.zip -DestinationPath C:\MariaDB"
- name: Move files to correct directory
if: steps.cache-mariadb.outputs.cache-hit != 'true'
run: |
Move-Item -Path "C:\MariaDB\mariadb-10.0.1-winx64\*" -Destination "C:\MariaDB" -Force
Remove-Item -Recurse -Force "C:\MariaDB\mariadb-10.0.1-winx64"
- name: Verify MariaDB installation
run: |
dir C:\MariaDB
dir C:\MariaDB\bin
- name: Clean data directory
run: |
if (Test-Path "C:\MariaDB\data") {
Remove-Item -Recurse -Force "C:\MariaDB\data"
}
New-Item -ItemType Directory -Path "C:\MariaDB\data"
- name: Check permissions
run: |
icacls C:\MariaDB
icacls C:\MariaDB\data
- name: Initialize MariaDB without --initialize-insecure
working-directory: C:\MariaDB
run: |
C:\MariaDB\bin\mysql_install_db.exe --datadir=C:\MariaDB\data
#- name: Install MariaDB as a service
# working-directory: C:\MariaDB
# run: |
# C:\MariaDB\bin\mysqld.exe --install MariaDB --defaults-file=C:\MariaDB\my.ini
#
# - name: Start MariaDB service
# working-directory: C:\MariaDB
# run: |
# Start-Service -Name MariaDB
- name: Start MariaDB
working-directory: C:\MariaDB
run: |
Start-Process -FilePath "C:\MariaDB\bin\mysqld.exe" -ArgumentList "--console" -NoNewWindow
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
#- name: Run mysql_upgrade
# working-directory: C:\MariaDB
# run: |
# C:\MariaDB\bin\mysql_upgrade.exe -u root -proot
- name: Set root password
run: |
C:\MariaDB\bin\mysqladmin.exe -u root password "root"
- name: Create test database
run: |
C:\MariaDB\bin\mysql.exe -u root -proot -e "CREATE DATABASE test_db;"
- name: Run SQL commands
run: |
C:\MariaDB\bin\mysql.exe -u root -proot test_db -e "CREATE TABLE sample_table (id INT PRIMARY KEY, name VARCHAR(50));"
C:\MariaDB\bin\mysql.exe -u root -proot test_db -e "INSERT INTO sample_table VALUES (1, 'GitHub Actions with MariaDB');"
C:\MariaDB\bin\mysql.exe -u root -proot test_db -e "SELECT * FROM sample_table;"
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v2
- name: Setup Nuget
uses: Nuget/setup-nuget@v1.0.5
- name: Restore nuget packages
run: nuget restore TeslaLogger.sln
- name: Build solution
run: msbuild TeslaLogger.sln -t:rebuild -property:Configuration=Debug
# Execute all unit tests in the solution
- name: Execute unit tests
run: dotnet test --filter "UnitTestsGeocode|UnitTestGrafana|UnitTestBase|UnitTestTelemetryParser" --logger trx --logger console UnitTestsTeslalogger\bin\Debug\UnitTestsTeslalogger.dll
#run: dotnet vstest /Tests:UnitTestsGeocode /Logger:trx UnitTestsTeslalogger\bin\Debug\UnitTestsTeslalogger.dll
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action/windows@v2
if: always()
with:
files: |
**/TestResults/**/*.xml
**/TestResults/*.trx
**/TestResults/**/*.json
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Teslalogger
path: TeslaLogger\bin\Debug\TeslaLogger.exe