Skip to content

Commit

Permalink
First CI test
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriele Santomaggio <g.santomaggio@gmail.com>
  • Loading branch information
Gsantomaggio committed May 10, 2024
1 parent c0938c6 commit f0dcd1a
Show file tree
Hide file tree
Showing 14 changed files with 444 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/publish-documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish documentation

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'maven'
- name: Publish Documentation
run: |
git config user.name "rabbitmq-ci"
git config user.email "rabbitmq-ci@users.noreply.github.com"
ci/publish-documentation-to-github-pages.sh
48 changes: 48 additions & 0 deletions .github/workflows/test-supported-net-versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Test against supported .NET

on:
- workflow_call


jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.x
7.x
- uses: actions/cache@v4
with:
path: |
~/.nuget/packages
~/.local/share/NuGet/v4-cache
key: ${{ runner.os }}-v2-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-v2-nuget-
- uses: actions/checkout@v4
- name: Checkout tls-gen
uses: actions/checkout@v4
with:
repository: rabbitmq/tls-gen
path: './tls-gen'
- name: Start broker
run: ci/start-broker.sh
- name: Start toxiproxy
run: ci/start-toxiproxy.sh
- name: Display DotNet version
run: dotnet --version
- name: Restore
run: dotnet restore ./Build.csproj --verbosity=normal
- name: Build
run: dotnet build ./Build.csproj --no-restore --verbosity=normal
- name: Verify
run: dotnet format ./rabbitmq-amqp-dotnet-client.sln --no-restore --verbosity=diagnostic --verify-no-changes
- name: Test
run: dotnet test ./Build.csproj --no-build --logger "console;verbosity=detailed" /p:AltCover=true
- name: Stop toxiproxy
run: docker stop toxiproxy && docker rm toxiproxy
- name: Stop broker
run: docker stop rabbitmq && docker rm rabbitmq
127 changes: 127 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
## Misc files
*.bak
docs/api-guide.pdf
docs/pyle.log
docs/pyle.pid
.DS_Store
.idea
InternalTrace*
[Ll]ocal.dist
[Ll]ocal.props
*.lock.json
nunit-agent*
*.pyc
test-output.log
TestResults.xml
TestResult.xml
Tests/coverage.xml
test.sh
*.VisualState.xml
.vscode

## Misc directories
.fake/
gensrc/
.ionide/
NuGet/
tmp/
.vscode/

#################
## Visual Studio
#################

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.sln.docstates

# Build results
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
*.lock.json

BenchmarkDotNet.Artifacts/*

APIApproval.Approve.received.txt

# Visual Studio 2015 cache/options directory
.vs/

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
*.ncrunch*
.*crunch*.local.xml

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# NuGet Packages Directory
packages/
/packages

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.[Pp]ublish.xml
*.pfx
*.publishsettings

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# Unit tests
projects/Unit*/TestResult.xml

# Development scripts
*.pcap

# Vim
.sw?
.*.sw?

#tests
Tests/coverage.*
##
docs/temp/

12 changes: 12 additions & 0 deletions Build.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.Build.Traversal/3.2.0">

<PropertyGroup>
<IsPackable>false</IsPackable>
<MinVerSkip>true</MinVerSkip>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="RabbitMQ.AMQP.Client/RabbitMQ.AMQP.Client.csproj" />
</ItemGroup>

</Project>
39 changes: 39 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!-- vim: set ft=xml: -->
<Project>

<PropertyGroup>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)rabbit.snk</AssemblyOriginatorKeyFile>
<Authors>Broadcom</Authors>
<Company>Broadcom Inc. and/or its subsidiaries.</Company>
<Copyright>Copyright © 2017-$([System.DateTime]::Now.Year) Broadcom. All Rights Reserved. The term Broadcom refers to Broadcom Inc. and/or its subsidiaries.</Copyright>
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
<DefaultLanguage>en-US</DefaultLanguage>
<DisableCheckingDuplicateNuGetItems>false</DisableCheckingDuplicateNuGetItems>
<Features>strict</Features>
<IncludeSymbols>true</IncludeSymbols>
<IsPackable>false</IsPackable>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<PackageId>$(AssemblyName)</PackageId>
<PackageProjectUrl>https://github.com/rabbitmq/rabbitmq-amqp-dotnet-client</PackageProjectUrl>
<PackageReleaseNotes>https://github.com/rabbitmq/rabbitmq-amqp-dotnet-client/releases/latest</PackageReleaseNotes>
<PackageTags>rabbitmq, amqp</PackageTags>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/rabbitmq/rabbitmq-amqp-dotnet-client</RepositoryUrl>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release' And '$(CI)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
<Deterministic>true</Deterministic>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release' and '$(SourceRoot)' == ''">
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- vim: set ft=xml: -->
<Project>
<ItemGroup>
<EmbeddedFiles Include="$(GeneratedAssemblyInfoFile)"/>
</ItemGroup>
</Project>
30 changes: 30 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<!-- RabbitMQ.Amqp.Client -->
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="MinVer" Version="4.3.0" />
<!-- Tests -->
<PackageVersion Include="AltCover" Version="8.6.45" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.5" />
<PackageVersion Include="Xunit.SkippableFact" Version="1.4.13" />
<PackageVersion Include="coverlet.collector" Version="3.2.0" />
<!-- docs/**/*.csproj -->
</ItemGroup>
<ItemGroup Label=".NET 6 Specific" Condition="'$(TargetFramework)' == 'net6.0'">
<!-- RabbitMQ.Stream.Client -->
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
</ItemGroup>
<ItemGroup Label=".NET 7 Specific" Condition="'$(TargetFramework)' == 'net7.0'">
<!-- RabbitMQ.Stream.Client -->
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
</ItemGroup>
<ItemGroup Label=".NET 8 Specific" Condition="'$(TargetFramework)' == 'net8.0'">
<!-- RabbitMQ.Amqp.Client -->
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions RabbitMQ.AMQP.Client/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace RabbitMQ.AMQP.Client;

public class Class1
{
}
9 changes: 9 additions & 0 deletions RabbitMQ.AMQP.Client/RabbitMQ.AMQP.Client.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
25 changes: 25 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[CmdletBinding(PositionalBinding=$false)]
param(
[switch]$RunTests
)

Write-Host "Run Parameters:" -ForegroundColor Cyan
Write-Host "`tPSScriptRoot: $PSScriptRoot"
Write-Host "`tRunTests: $RunTests"
Write-Host "`tdotnet --version: $(dotnet --version)"

Write-Host "Building all projects (Build.csproj traversal)..." -ForegroundColor "Magenta"
dotnet build "$PSScriptRoot\Build.csproj"
Write-Host "Done building." -ForegroundColor "Green"

if ($RunTests) {
Write-Host "Running tests: Build.csproj traversal (all frameworks)" -ForegroundColor "Magenta"
dotnet test "$PSScriptRoot\Build.csproj" --no-build --logger "console;verbosity=detailed"
if ($LastExitCode -ne 0) {
Write-Host "Error with tests, aborting build." -Foreground "Red"
Exit 1
}
Write-Host "Tests passed!" -ForegroundColor "Green"
}

Write-Host "Done."
49 changes: 49 additions & 0 deletions ci/publish-documentation-to-github-pages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

. $(pwd)/release-versions.txt

MESSAGE=$(git log -1 --pretty=%B)
./mvnw buildnumber:create pre-site --no-transfer-progress

./mvnw javadoc:javadoc -Dmaven.javadoc.skip=false --no-transfer-progress

if [ -e target/site/apidocs/element-list ]
then cp target/site/apidocs/element-list target/site/apidocs/package-list
fi

RELEASE_VERSION=$(cat pom.xml | grep -oPm1 "(?<=<version>)[^<]+")

# GHA does shallow clones, so need the next 2 commands to have the gh-pages branch
git remote set-branches origin 'gh-pages'
git fetch -v

git checkout gh-pages
mkdir -p $RELEASE_VERSION/htmlsingle
cp target/generated-docs/index.html $RELEASE_VERSION/htmlsingle
mkdir -p $RELEASE_VERSION/api
cp -r target/site/apidocs/* $RELEASE_VERSION/api/
git add $RELEASE_VERSION/

if [[ $LATEST == "true" ]]
then
if [[ $RELEASE_VERSION == *[RCM]* ]]
then
DOC_DIR="milestone"
elif [[ $RELEASE_VERSION == *SNAPSHOT* ]]
then
DOC_DIR="snapshot"
else
DOC_DIR="stable"
fi

mkdir -p $DOC_DIR/htmlsingle
cp target/generated-docs/index.html $DOC_DIR/htmlsingle
mkdir -p $DOC_DIR/api
cp -r target/site/apidocs/* $DOC_DIR/api/
git add $DOC_DIR/

fi

git commit -m "$MESSAGE"
git push origin gh-pages
git checkout main
Loading

0 comments on commit f0dcd1a

Please sign in to comment.