Merge branch 'develop/3.6.0' into feature/unit-test-suite
This commit is contained in:
commit
2fde7ef048
106
.github/workflows/packages.yml
vendored
106
.github/workflows/packages.yml
vendored
|
|
@ -1,4 +1,5 @@
|
|||
name: Packages
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
|
|
@ -12,18 +13,86 @@ on:
|
|||
- 'rc/*'
|
||||
- 'develop/*'
|
||||
- 'codex/*'
|
||||
pull_request:
|
||||
branches:
|
||||
- 'main'
|
||||
- 'bug/*'
|
||||
- 'perf/*'
|
||||
- 'patch/*'
|
||||
- 'feat/*'
|
||||
- 'enh/*'
|
||||
- 'rc/*'
|
||||
- 'develop/*'
|
||||
- 'codex/*'
|
||||
release:
|
||||
types: [ prereleased, published ]
|
||||
types: [prereleased, published]
|
||||
|
||||
env:
|
||||
base_version: '3.6.0'
|
||||
feedz_feed_source: 'https://f.feedz.io/elsa-workflows/elsa-3/nuget/index.json'
|
||||
nuget_feed_source: 'https://api.nuget.org/v3/index.json'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build packages
|
||||
test:
|
||||
name: Test with coverage
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up .NET SDKs
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: |
|
||||
8.0.x
|
||||
9.0.x
|
||||
|
||||
- name: Cache NuGet packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.nuget/packages
|
||||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/Directory.Packages.props', '**/*.csproj') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-nuget-
|
||||
|
||||
- name: Restore solution
|
||||
run: dotnet restore Elsa.sln
|
||||
|
||||
- name: Build solution
|
||||
run: dotnet build Elsa.sln --no-restore --configuration Release
|
||||
|
||||
- name: Prepare coverage directory
|
||||
run: |
|
||||
rm -rf artifacts/coverage
|
||||
mkdir -p artifacts/coverage
|
||||
|
||||
- name: Run tests with coverage
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mapfile -t projects < <(find test -type f -name '*.csproj' | sort)
|
||||
if [ ${#projects[@]} -eq 0 ]; then
|
||||
echo "No test projects were found in the test directory." >&2
|
||||
exit 1
|
||||
fi
|
||||
for project in "${projects[@]}"; do
|
||||
echo "Running tests with coverage for ${project}"
|
||||
dotnet test "$project" --configuration Release --no-build --logger "GitHubActions;report-warnings=false" /p:CollectCoverage=true
|
||||
done
|
||||
|
||||
- name: Upload coverage reports
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: coverage-reports
|
||||
path: artifacts/coverage
|
||||
|
||||
build:
|
||||
name: Build packages
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
steps:
|
||||
- name: Extract branch name
|
||||
run: |
|
||||
|
|
@ -31,28 +100,31 @@ jobs:
|
|||
BRANCH_NAME=${BRANCH_NAME#refs/heads/} # remove the refs/heads/ prefix
|
||||
# Extract the last part after the last slash of the branch name, if any, e.g., feature/issue-123 -> issue-123 and use it as the version prefix.
|
||||
PACKAGE_PREFIX=$(echo $BRANCH_NAME | rev | cut -d/ -f1 | rev | tr '_' '-')
|
||||
|
||||
|
||||
# If the branch name is main, use the preview version. Otherwise, use the branch name as the version prefix.
|
||||
if [[ "${BRANCH_NAME}" == "main" || "${BRANCH_NAME}" =~ ^develop/ ]]; then
|
||||
PACKAGE_PREFIX="preview"
|
||||
fi
|
||||
|
||||
|
||||
echo "Ref: ${{ github.ref }}"
|
||||
echo "Branch name: ${BRANCH_NAME}"
|
||||
echo "Package prefix: ${PACKAGE_PREFIX}"
|
||||
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
|
||||
echo "PACKAGE_PREFIX=${PACKAGE_PREFIX}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Verify commit exists in branch
|
||||
run: |
|
||||
if [[ "${{ github.ref }}" == refs/tags/* && "${{ github.event_name }}" == "release" && ("${{ github.event.action }}" == "published" || "${{ github.event.action }}" == "prereleased")]]; then
|
||||
if [[ "${{ github.ref }}" == refs/tags/* && "${{ github.event_name }}" == "release" && ("${{ github.event.action }}" == "published" || "${{ github.event.action }}" == "prereleased") ]]; then
|
||||
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
|
||||
git branch --remote --contains | grep origin/develop/3.6.0
|
||||
else
|
||||
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
|
||||
git branch --remote --contains | grep origin/${BRANCH_NAME}
|
||||
fi
|
||||
|
||||
- name: Set VERSION variable
|
||||
run: |
|
||||
if [[ "${{ github.ref }}" == refs/tags/* && "${{ github.event_name }}" == "release" && ("${{ github.event.action }}" == "published" || "${{ github.event.action }}" == "prereleased") ]]; then
|
||||
|
|
@ -62,35 +134,21 @@ jobs:
|
|||
else
|
||||
echo "VERSION=${{env.base_version}}-preview.${{github.run_number}}" >> $GITHUB_ENV
|
||||
fi
|
||||
# - name: Set up JDK 17
|
||||
# uses: actions/setup-java@v2
|
||||
# with:
|
||||
# java-version: '17'
|
||||
# distribution: 'adopt'
|
||||
|
||||
- uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: 9.x
|
||||
# - name: Install SonarScanner for .NET
|
||||
# run: dotnet tool install --global dotnet-sonarscanner
|
||||
# - name: Install Coverlet for code coverage
|
||||
# run: dotnet tool install --global coverlet.console
|
||||
# - name: Begin SonarCloud analysis
|
||||
# env:
|
||||
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
# run: dotnet sonarscanner begin /k:"elsa-workflows_elsa-core" /o:"elsa-workflows" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.exclusions=**/obj/**,**/*.dll,build/**,samples/**,src/apps/** /d:"sonar.verbose=true" /d:sonar.cs.opencover.reportsPaths=**/testresults/**/coverage.opencover.xml
|
||||
|
||||
- name: Compile+Test+Pack
|
||||
run: ./build.sh Compile+Test+Pack --version ${VERSION} --analyseCode true
|
||||
# - name: End SonarCloud analysis
|
||||
# env:
|
||||
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
# run: dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: elsa-nuget-packages
|
||||
path: packages/*nupkg
|
||||
if: ${{ github.event_name == 'release' || github.event_name == 'push'}}
|
||||
|
||||
|
||||
publish_preview_feedz:
|
||||
name: Publish to feedz.io
|
||||
needs: build
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
<PackageVersion Include="Confluent.Kafka" Version="2.10.0"/>
|
||||
<PackageVersion Include="Confluent.SchemaRegistry.Serdes.Avro" Version="2.10.0"/>
|
||||
<PackageVersion Include="coverlet.collector" Version="6.0.4" PrivateAssets="All"/>
|
||||
<PackageVersion Include="coverlet.msbuild" Version="6.0.0" PrivateAssets="All"/>
|
||||
<PackageVersion Include="Cronos" Version="0.11.0"/>
|
||||
<PackageVersion Include="Dapper" Version="2.1.66"/>
|
||||
<PackageVersion Include="Datadog.Trace.Bundle" Version="3.16.0"/>
|
||||
|
|
|
|||
6
Elsa.sln
6
Elsa.sln
|
|
@ -62,8 +62,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docker", "docker", "{986E54
|
|||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "unit", "unit", "{18453B51-25EB-4317-A4B3-B10518252E92}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
test\unit\Directory.Build.props = test\unit\Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "integration", "integration", "{1B8D5897-902E-4632-8698-E89CAF3DDF54}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
test\integration\Directory.Build.props = test\integration\Directory.Build.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "component", "component", "{08B41FFA-CEE3-46A7-B5C0-3EB65D37A16C}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
|
|
|
|||
|
|
@ -9,6 +9,15 @@
|
|||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
||||
<CollectCoverage Condition="'$(CollectCoverage)' == ''">true</CollectCoverage>
|
||||
<CoverletOutputFormat Condition="'$(CoverletOutputFormat)' == ''">cobertura,lcov,opencover</CoverletOutputFormat>
|
||||
<CoverletOutput Condition="'$(CoverletOutput)' == ''">$(MSBuildThisFileDirectory)../artifacts/coverage/$(MSBuildProjectName)/coverage</CoverletOutput>
|
||||
<Threshold Condition="'$(Threshold)' == ''">10</Threshold>
|
||||
<ThresholdType Condition="'$(ThresholdType)' == ''">line</ThresholdType>
|
||||
<ThresholdStat Condition="'$(ThresholdStat)' == ''">total</ThresholdStat>
|
||||
<Exclude>
|
||||
[*Elsa.Testing.Shared*]*
|
||||
</Exclude>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -17,7 +26,7 @@
|
|||
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
|
||||
<PackageReference Include="Moq"/>
|
||||
<PackageReference Include="NSubstitute"/>
|
||||
<PackageReference Include="coverlet.collector" PrivateAssets="all"/>
|
||||
<PackageReference Include="coverlet.msbuild"/>
|
||||
<PackageReference Include="xunit"/>
|
||||
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all"/>
|
||||
</ItemGroup>
|
||||
|
|
@ -26,4 +35,4 @@
|
|||
<Using Include="Xunit"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
<Project>
|
||||
|
||||
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<Threshold>40</Threshold>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Testcontainers.PostgreSql"/>
|
||||
<PackageReference Include="Testcontainers.RabbitMq"/>
|
||||
|
|
|
|||
9
test/integration/Directory.Build.props
Normal file
9
test/integration/Directory.Build.props
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<Project>
|
||||
|
||||
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
|
||||
|
||||
<PropertyGroup>
|
||||
<Threshold>10</Threshold>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
<IsPackable>false</IsPackable>
|
||||
<OutputType>Exe</OutputType>
|
||||
<CollectCoverage>false</CollectCoverage>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
9
test/unit/Directory.Build.props
Normal file
9
test/unit/Directory.Build.props
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<Project>
|
||||
|
||||
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
|
||||
|
||||
<PropertyGroup>
|
||||
<Threshold>0</Threshold>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\src\modules\Elsa.Common\Elsa.Common.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
using Elsa.Extensions;
|
||||
using Xunit;
|
||||
|
||||
namespace Elsa.Common.Core;
|
||||
|
||||
public class EnumerableExtensionsTests
|
||||
{
|
||||
[Fact]
|
||||
public void ToBatches_ReturnsItemsInListOfPages()
|
||||
{
|
||||
var items = new List<int>
|
||||
{
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
};
|
||||
var batchSize = 2;
|
||||
var batches = items.ToBatches(batchSize).ToList();
|
||||
|
||||
Assert.Equal(3, batches.Count);
|
||||
Assert.Equal(2, batches.ElementAt(0).Count());
|
||||
Assert.Equal(2, batches.ElementAt(1).Count());
|
||||
Assert.Equal(1, batches.ElementAt(2).Count());
|
||||
Assert.Equal(3, batches.ElementAt(1).ElementAt(0));
|
||||
Assert.Equal(4, batches.ElementAt(1).ElementAt(1));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue