Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to GitHub actions #297

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
56ba663
Create ci.yml
TSchmiedlechner May 24, 2024
ccec042
Update ci.yml
TSchmiedlechner May 24, 2024
e477135
Update ci.yml
TSchmiedlechner May 26, 2024
cf97f80
Update ci.yml
TSchmiedlechner May 26, 2024
6ccafa2
Update ci.yml
TSchmiedlechner May 26, 2024
94b44fc
Update ci.yml
TSchmiedlechner May 26, 2024
122bb39
Update ci.yml
TSchmiedlechner May 26, 2024
9c20d90
Update ci.yml
TSchmiedlechner May 26, 2024
7d5fef6
Added publishing to CI build
TSchmiedlechner Jul 13, 2024
88e269e
Merge branch 'main' into user/tsc/github-actions
TSchmiedlechner Jul 13, 2024
ef8467b
Fix step outputs
TSchmiedlechner Jul 13, 2024
9ec7500
Test release binaries
TSchmiedlechner Jul 13, 2024
45c08ed
.NET 6 is used in tests
TSchmiedlechner Jul 13, 2024
488c979
.NET 6 is required for tests
TSchmiedlechner Jul 13, 2024
44d908a
Merge branch 'user/tsc/github-actions' of https://github.com/fiskaltr…
TSchmiedlechner Jul 13, 2024
d6e549f
Publish test results
TSchmiedlechner Jul 13, 2024
6dca548
Put fail-fast into correct place
TSchmiedlechner Jul 13, 2024
2e3d600
Publishing test results requires linux
TSchmiedlechner Jul 13, 2024
3718826
Upload trx files in build step
TSchmiedlechner Jul 13, 2024
39a3a80
Always upload test results
TSchmiedlechner Jul 13, 2024
f9d564a
Use a shorter path in test
TSchmiedlechner Jul 13, 2024
ae3184a
Added connection string secrets for tests
TSchmiedlechner Jul 13, 2024
0a85793
Append files to sign correctly
TSchmiedlechner Jul 13, 2024
0720f30
Fixed files
TSchmiedlechner Jul 13, 2024
c54eec8
Requires newline... I hope
TSchmiedlechner Jul 13, 2024
a28a29a
Fixed variable name
TSchmiedlechner Jul 13, 2024
54aa5c8
Replaced SQLite nuspec with csproj
TSchmiedlechner Jul 13, 2024
428f522
Publish SQLite files to support manually packing them
TSchmiedlechner Jul 13, 2024
3edc4b5
Fixed copy/paste issue
TSchmiedlechner Jul 13, 2024
c3d7c4e
Include other directories
TSchmiedlechner Jul 13, 2024
58ac05b
Use msbuild and install Android dependencies
TSchmiedlechner Jul 14, 2024
8aca1a1
Install Java 21
TSchmiedlechner Jul 14, 2024
4b0c29b
Maybe the preinstalled Java is enough :|
TSchmiedlechner Jul 14, 2024
af5f18a
It isn't
TSchmiedlechner Jul 14, 2024
2acba13
Setup msbuild
TSchmiedlechner Jul 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
225 changes: 225 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
name: Middleware CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build-and-test:
name: "Build and test"
runs-on: windows-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
solution: [ "queue", "scu-at", "scu-de", "scu-it", "scu-es" ]

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
filter: tree:0

- name: Setup .NET 8
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.x'

- name: Setup .NET 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0'

- name: Install .NET Framework 4.6.1
run: choco install netfx-4.6.1-devpack -y

- name: Install NuGet
run: choco install nuget.commandline -y

- name: Install MinVer
run: dotnet tool install --global minver-cli --version 5.0.0

- name: Restore dependencies
run: dotnet restore (Get-ChildItem -Path ${{ matrix.solution }} -Filter *.sln).FullName

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2

# We have to use msbuild as long as we're building Xamarin projects
- name: Build
run: msbuild (Get-ChildItem -Path ${{ matrix.solution }} -Filter *.sln).FullName /p:Configuration=Release /p:Platform="Any CPU" /p:BuildProjectReferences=true
# run: dotnet build (Get-ChildItem -Path ${{ matrix.solution }} -Filter *.sln).FullName --configuration Release --no-restore

- name: Publish SQLite binaries for manual NuGet packing
if: matrix.solution == 'queue'
working-directory: '${{ matrix.solution }}/src/fiskaltrust.Middleware.Queue.SQLite'
run: |
dotnet publish --configuration Release --no-restore -f net461
dotnet publish --configuration Release --no-restore -f netstandard2.0
dotnet publish --configuration Release --no-restore -f netstandard2.1

- name: Find Unit Test Projects
id: unit_test_projects
run: |
"PROJECTS=$((Get-ChildItem -Path ./${{ matrix.solution }} -Recurse -Filter '*.UnitTest.csproj' | % { $_.FullName }) -join ';')" | Out-File -FilePath $env:GITHUB_OUTPUT -Append

- name: Find Integration Test Projects
id: integration_test_projects
run: |
"PROJECTS=$((Get-ChildItem -Path ./${{ matrix.solution }} -Recurse -Filter '*.IntegrationTest.csproj' | % { $_.FullName }) -join ';')" | Out-File -FilePath $env:GITHUB_OUTPUT -Append

- name: Find Acceptance Test Projects
id: acceptance_test_projects
run: |
"PROJECTS=$((Get-ChildItem -Path ./${{ matrix.solution }} -Recurse -Filter '*.AcceptanceTest.csproj' | % { $_.FullName }) -join ';')" | Out-File -FilePath $env:GITHUB_OUTPUT -Append

- name: Run Unit Tests
if: steps.unit_test_projects.outputs.PROJECTS != ''
run: |
$projects = "${{ steps.unit_test_projects.outputs.PROJECTS }}".Split(";")
$failed = $false
foreach ($project in $projects) {
dotnet test $project --no-build --verbosity normal --configuration Release -l:trx
if ($LASTEXITCODE -ne 0) {
$failed = $true
}
}
if ($failed) {
Write-Error "One or more tests failed."
exit 1
}

- name: Run Integration Tests
env:
CONNECTIONSTRING_AZURE_STORAGE_TESTS: ${{ secrets.CONNECTIONSTRING_AZURE_STORAGE_TESTS }}
CONNECTIONSTRING_POSTGRESQL_TESTS: ${{ secrets.CONNECTIONSTRING_POSTGRESQL_TESTS }}
CONNECTIONSTRING_MYSQL_TESTS: ${{ secrets.CONNECTIONSTRING_MYSQL_TESTS }}
if: steps.integration_test_projects.outputs.PROJECTS != ''
run: |
$projects = "${{ steps.integration_test_projects.outputs.PROJECTS }}".Split(";")
$failed = $false
foreach ($project in $projects) {
dotnet test $project --no-build --verbosity normal --configuration Release -l:trx
if ($LASTEXITCODE -ne 0) {
$failed = $true
}
}
if ($failed) {
Write-Error "One or more tests failed."
exit 1
}

# - name: Run Acceptance Tests
# env:
# CONNECTIONSTRING_AZURE_STORAGE_TESTS: ${{ secrets.CONNECTIONSTRING_AZURE_STORAGE_TESTS }}
# CONNECTIONSTRING_POSTGRESQL_TESTS: ${{ secrets.CONNECTIONSTRING_POSTGRESQL_TESTS }}
# CONNECTIONSTRING_MYSQL_TESTS: ${{ secrets.CONNECTIONSTRING_MYSQL_TESTS }}
# if: steps.acceptance_test_projects.outputs.PROJECTS != ''
# run: |
# $projects = "${{ steps.acceptance_test_projects.outputs.PROJECTS }}".Split(";")
# $failed = $false
# foreach ($project in $projects) {
# dotnet test $project --no-build --verbosity normal --configuration Release -l:trx
# if ($LASTEXITCODE -ne 0) {
# $failed = $true
# }
# }
# if ($failed) {
# Write-Error "One or more tests failed."
# exit 1
# }

- name: Filter files for codesigning
id: filter_files_for_codesigning
run: |
$files = Get-ChildItem -Path .\\${{ matrix.solution }} -Filter "fiskaltrust.*.dll" -Recurse | Select-Object -ExpandProperty FullName

# Multiline outputs required a unique delimiter
$EOF = -join (1..15 | ForEach {[char]((48..57)+(65..90)+(97..122) | Get-Random)})
"FILTERED_FILES<<$EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
foreach ($file in $files) {
$file | Out-File -FilePath $env:GITHUB_OUTPUT -Append
}
"$EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append

- name: Sign binaries
uses: dlemstra/code-sign-action@v1
with:
certificate: '${{ secrets.SIGNING_CERTIFICATE }}'
password: '${{ secrets.SIGNING_CERT_PASSWORD }}'
files: |-
${{ steps.filter_files_for_codesigning.outputs.FILTERED_FILES }}

- name: Publish v1 Nuget packages
run: dotnet pack (Get-ChildItem -Path ${{ matrix.solution }} -Filter *.sln).FullName --no-restore --configuration Release --output ./publish/packages-v1

- name: Publish v2 zip packages
run: |
$version = minver --verbosity error

New-Item -ItemType Directory -Force -Path ./publish/packages-v2

# We're filtering the files to publish here based on the IsPackable attribute that's also used for v1 packages
$projectFiles = Get-ChildItem -Path ${{ matrix.solution }} -Recurse -Filter *.csproj
foreach ($file in $projectFiles) {
[xml]$xmlContent = Get-Content -Path $file.FullName
foreach ($propertyGroup in $xmlContent.Project.PropertyGroup) {
if ($propertyGroup.IsPackable -eq "true") {
$packageName = $file.BaseName
dotnet publish $file.FullName --configuration Release -f net6 --output ./publish/raw/packages-v2/$packageName --no-build /p:DebugType=None /p:DebugSymbols=false
Compress-Archive -Path ./publish/raw/packages-v2/$packageName/* -DestinationPath ./publish/packages-v2/$packageName.$version.zip

$hash = Get-FileHash ./publish/packages-v2/$packageName.$version.zip -Algorithm SHA256
$hashbytes = $hash.Hash -split '([A-F0-9]{2})' | foreach-object { if ($_) {[System.Convert]::ToByte($_,16)}}
$hashstring = [System.Convert]::ToBase64String($hashbytes)
$hashstring | Set-Content ./publish/packages-v2/$packageName.$version.zip.hash

break
}
}
}

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.solution }}-build-artifacts
path: ./publish

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.solution }}-test-artifacts
path: '${{ matrix.solution }}/**/*.trx'

publish-test-results:
name: "Publish Tests Results"
needs: build-and-test
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
if: always()

steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "artifacts/**/*.trx"
10 changes: 9 additions & 1 deletion queue/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Deterministic>true</Deterministic>
<LangVersion>11.0</LangVersion>
</PropertyGroup>
</PropertyGroup>


<ItemGroup>
<PackageReference Include="MinVer" Version="5.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions queue/src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net461;net6</TargetFrameworks>
<WarningsNotAsErrors>NU1901;NU1902;NU1903;NU1904;NU5104</WarningsNotAsErrors>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<PackageDescription>Abstract types that are internally used by the fiskaltrust.Middleware and the fiskaltrust.Launcher.</PackageDescription>
<TargetFrameworks>netstandard2.0;net461;net6</TargetFrameworks>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>The fiskaltrust Middleware Queue with an Azure Table Storage based storage
provider.</Description>
<Description>The fiskaltrust Middleware Queue with an Azure Table Storage based storage provider.</Description>
<TargetFrameworks>net6;net461</TargetFrameworks>
<TargetsForTfmSpecificBuildOutput>
$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>The fiskaltrust Middleware Queue with an Entity Framework storage provider for SQL Server databases.</Description>
<TargetFrameworks>net461;net6</TargetFrameworks>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<Description>The fiskaltrust Middleware Queue with an in-memory storage provider.e. Data is not persisted - for testing purposes only.</Description>
<TargetFrameworks>netstandard2.0;net461;net6</TargetFrameworks>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<Description>The fiskaltrust Middleware Queue with an MySQL storage provider.</Description>
<TargetFrameworks>netstandard2.0;net461;net6</TargetFrameworks>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<Description>The fiskaltrust Middleware Queue with an PostgreSQL storage provider.</Description>
<TargetFrameworks>net6</TargetFrameworks>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
Expand Down
87 changes: 0 additions & 87 deletions queue/src/fiskaltrust.Middleware.Queue.SQLite/.nuspec

This file was deleted.

Loading
Loading