Skip to content

Commit

Permalink
Setup GH Actions (#43)
Browse files Browse the repository at this point in the history
* Create build.yml
* Update Nerdbank.GitVersioning for GitHub actions support
* Attempt to work around shallow clone issues with LibGit2Sharp

    See: dotnet/Nerdbank.GitVersioning#423
    See: libgit2/libgit2sharp#1775

* Skip RabbitMQ integration tests when no connection string configured
* Remove dummy service bus connection string to skip Service Bus integration tests
* Skip additional service bus tests when no connection string available
* Skip additional RabbitMQ tests when no connection string is available
* Attempt to get rabbitmq service container working
* Attempt to connect to rabbitmq service container for tests
* Skip rabbitmq management tests if neither connectionstring or management uri configured
* Add service bus connection string secret
* Attempted OS matrix builds for linux and windows builds
* Revert "Attempted OS matrix builds for linux and windows builds"
* Add coverlet flags to dotnet test
* Attempt to store test coverage artifact
* Remove flaky rabbitmq connection finalizer tests
  • Loading branch information
danielcirket committed Jul 6, 2020
1 parent 5592819 commit 536ac12
Show file tree
Hide file tree
Showing 31 changed files with 248 additions and 300 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build

on:
push:
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

services:
rabbitmq:
image: rabbitmq:3-management
ports:
- 5672:5672
- 15672:15672

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: .NET Build
run: dotnet build OpenEventSourcing.sln -c Release

- name: .NET Test
run: dotnet test OpenEventSourcing.sln --no-build -c Release /p:CollectCoverage=true /p:CoverletOutput='../../TestCoverage/' /p:MergeWith='../../TestCoverage/coverage.json' /p:CoverletOutputFormat="opencover" /p:Exclude="[OpenEventSourcing.Samples.*]"
env:
OPENEVENTSOURCING_RABBITMQ__CONNECTIONSTRING: amqp://guest:guest@localhost:5672/
OPENEVENTSOURCING_RABBITMQ__MANAGEMENTURI: http://localhost:15672/
OPENEVENTSOURCING_AZURE__SERVICEBUS__CONNECTIONSTRING: ${{ secrets.AZURE_SERVICEBUS_CONNECTIONSTRING }}

- uses: actions/upload-artifact@v2
with:
name: test-coverage
path: TestCoverage/*
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.50" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.1.91" PrivateAssets="All" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected override void ConfigureServices(IServiceCollection services)
.AddJsonSerializers();
}

[Fact]
[ServiceBusTest]
public void WhenCreateRuleAsyncCalledWithNullRuleThenShouldThrowArgumentException()
{
using (var scope = ServiceProvider.CreateScope())
Expand All @@ -59,7 +59,7 @@ public void WhenCreateRuleAsyncCalledWithNullRuleThenShouldThrowArgumentExceptio
.And.ParamName.Should().Be("ruleName");
}
}
[Fact]
[ServiceBusTest]
public void WhenCreateRuleAsyncCalledWithNullSubscriptionThenShouldThrowArgumentException()
{
using (var scope = ServiceProvider.CreateScope())
Expand All @@ -75,7 +75,7 @@ public void WhenCreateRuleAsyncCalledWithNullSubscriptionThenShouldThrowArgument
.And.ParamName.Should().Be("subscriptionName");
}
}
[Fact]
[ServiceBusTest]
public void WhenCreateRuleAsyncCalledWithNullTopicThenShouldThrowArgumentException()
{
using (var scope = ServiceProvider.CreateScope())
Expand Down Expand Up @@ -181,7 +181,7 @@ public void WhenCreateRuleAsyncCalledWithExistingRuleThenShouldThrowRuleAlreadyE
.And.RuleName.Should().Be(_ruleName);
}
}
[Fact]
[ServiceBusTest]
public void WhenRemoveRuleAsyncCalledWithNullRuleThenShouldThrowArgumentException()
{
using (var scope = ServiceProvider.CreateScope())
Expand All @@ -197,7 +197,7 @@ public void WhenRemoveRuleAsyncCalledWithNullRuleThenShouldThrowArgumentExceptio
.And.ParamName.Should().Be("ruleName");
}
}
[Fact]
[ServiceBusTest]
public void WhenRemoveRuleAsyncCalledWithNullSubscriptionThenShouldThrowArgumentException()
{
using (var scope = ServiceProvider.CreateScope())
Expand All @@ -213,7 +213,7 @@ public void WhenRemoveRuleAsyncCalledWithNullSubscriptionThenShouldThrowArgument
.And.ParamName.Should().Be("subscriptionName");
}
}
[Fact]
[ServiceBusTest]
public void WhenRemoveRuleAsyncCalledWithNullTopicThenShouldThrowArgumentException()
{
using (var scope = ServiceProvider.CreateScope())
Expand Down Expand Up @@ -300,7 +300,7 @@ public void WhenRemoveRuleAsyncCalledWithNonExistentRuleThenShouldSucceed()
verify.Should().NotThrow();
}
}
[Fact]
[ServiceBusTest]
public void WhenRetrieveRulesAsyncCalledWithNullSubscriptionThenShouldThrowArgumentException()
{
using (var scope = ServiceProvider.CreateScope())
Expand All @@ -316,7 +316,7 @@ public void WhenRetrieveRulesAsyncCalledWithNullSubscriptionThenShouldThrowArgum
.And.ParamName.Should().Be("subscriptionName");
}
}
[Fact]
[ServiceBusTest]
public void WhenRetrieveRulesAsyncCalledWithNullTopicThenShouldThrowArgumentException()
{
using (var scope = ServiceProvider.CreateScope())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected override void ConfigureServices(IServiceCollection services)
.AddJsonSerializers();
}

[Fact]
[ServiceBusTest]
public void WhenCreateSubscriptionAsyncCalledWithNullTopicNameThenShouldThrowArgumentException()
{
using (var scope = ServiceProvider.CreateScope())
Expand All @@ -53,7 +53,7 @@ public void WhenCreateSubscriptionAsyncCalledWithNullTopicNameThenShouldThrowArg
.And.ParamName.Should().Be("topicName");
}
}
[Fact]
[ServiceBusTest]
public void WhenCreateSubscriptionAsyncCalledWithNullSubscriptionNameThenShouldThrowArgumentException()
{
using (var scope = ServiceProvider.CreateScope())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected override void ConfigureServices(IServiceCollection services)
.AddJsonSerializers();
}

[Fact]
[ServiceBusTest]
public void WhenCreateTopicAsyncCalledWithNullTopicThenShouldThrowArgumentException()
{
using (var scope = ServiceProvider.CreateScope())
Expand Down Expand Up @@ -117,7 +117,7 @@ public void WhenTopicExistsAsyncCalledWithTopicExchangeThenShouldReturnTrue()
verify.Should().NotThrow();
}
}
[Fact]
[ServiceBusTest]
public void WhenRemoveTopicAsyncCalledWithNullTopicThenShouldThrowArgumentException()
{
using (var scope = ServiceProvider.CreateScope())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public CreateMessageTests()
#endif
}

[Fact]
[ServiceBusTest]
public void WhenCreateMessageCalledWithNullEventThenShouldThrowArgumentNullException()
{
using (var scope = ServiceProvider.CreateScope())
Expand All @@ -53,7 +53,7 @@ public void WhenCreateMessageCalledWithNullEventThenShouldThrowArgumentNullExcep
.And.ParamName.Should().Be("event");
}
}
[Fact]
[ServiceBusTest]
public void WhenCreateMessageCalledWithEventThenShouldPopulateMessageIdFromEventId()
{
using (var scope = ServiceProvider.CreateScope())
Expand All @@ -65,7 +65,7 @@ public void WhenCreateMessageCalledWithEventThenShouldPopulateMessageIdFromEvent
result.MessageId.Should().Be(@event.Id.ToString());
}
}
[Fact]
[ServiceBusTest]
public void WhenCreateMessageCalledWithEventThenShouldPopulateTypeFromEventTypeName()
{
using (var scope = ServiceProvider.CreateScope())
Expand All @@ -77,7 +77,7 @@ public void WhenCreateMessageCalledWithEventThenShouldPopulateTypeFromEventTypeN
result.Label.Should().Be(nameof(FakeEvent));
}
}
[Fact]
[ServiceBusTest]
public void WhenCreateMessageCalledWithEventThenShouldPopulateCorrelationIdFromEvent()
{
using (var scope = ServiceProvider.CreateScope())
Expand All @@ -90,7 +90,7 @@ public void WhenCreateMessageCalledWithEventThenShouldPopulateCorrelationIdFromE
result.CorrelationId.Should().Be(@event.CorrelationId.ToString());
}
}
[Fact]
[ServiceBusTest]
public void WhenCreateMessageCalledWithEventThenShouldPopulateBodyFromEvent()
{
using (var scope = ServiceProvider.CreateScope())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Azure": {
"ServiceBus": {
"ConnectionString": "Endpoint=sb://openeventsourcing.servicebus.windows.net/;SharedAccessKeyName=DUMMY;SharedAccessKey=DUMMY"
"ConnectionString": ""
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using OpenEventSourcing.RabbitMQ.Exceptions;
using OpenEventSourcing.RabbitMQ.Extensions;
using OpenEventSourcing.Serialization.Json.Extensions;
using OpenEventSourcing.Testing.Attributes;
using RabbitMQ.Client;
using Xunit;

Expand Down Expand Up @@ -45,7 +44,7 @@ public ExchangeTests(ConfigurationFixture fixture)
#endif
}

[IntegrationTest]
[RabbitMqTest]
public void WhenCreateExchangeAsyncCalledWithNonExistentExchangeThenShouldSucceed()
{
var factory = ServiceProvider.GetRequiredService<IRabbitMqConnectionFactory>();
Expand All @@ -68,7 +67,7 @@ public void WhenCreateExchangeAsyncCalledWithNonExistentExchangeThenShouldSuccee
verify.Should().Throw<ExchangeAlreadyExistsException>()
.And.ExchangeName.Should().Be(exchangeName);
}
[IntegrationTest]
[RabbitMqTest]
public void WhenCreateExchangeAsyncCalledWithExistingExchangeThenShouldThrowExchangeAlreadyExistsException()
{
var factory = ServiceProvider.GetRequiredService<IRabbitMqConnectionFactory>();
Expand All @@ -84,7 +83,7 @@ public void WhenCreateExchangeAsyncCalledWithExistingExchangeThenShouldThrowExch
act.Should().Throw<ExchangeAlreadyExistsException>()
.And.ExchangeName.Should().Be(exchangeName);
}
[IntegrationTest]
[RabbitMqTest]
public void WhenRemoveExchangeAsyncCalledWithNonExistentExchangeThenShouldThrowExhangeNotFoundException()
{
var factory = ServiceProvider.GetRequiredService<IRabbitMqConnectionFactory>();
Expand All @@ -99,7 +98,7 @@ public void WhenRemoveExchangeAsyncCalledWithNonExistentExchangeThenShouldThrowE
act.Should().Throw<ExchangeNotFoundException>()
.And.ExchangeName.Should().Be(exchangeName);
}
[IntegrationTest]
[RabbitMqTest]
public void WhenRemoveExchangeAsyncCalledWithExistingExchangeThenShouldSucceed()
{
var factory = ServiceProvider.GetRequiredService<IRabbitMqConnectionFactory>();
Expand All @@ -123,7 +122,7 @@ public void WhenRemoveExchangeAsyncCalledWithExistingExchangeThenShouldSucceed()
verify.Should().Throw<ExchangeNotFoundException>()
.And.ExchangeName.Should().Be(exchangeName);
}
[IntegrationTest]
[RabbitMqTest]
public void WhenExchangeExistsAsyncCalledWithNonExistentExchangeThenShouldReturnFalse()
{
var factory = ServiceProvider.GetRequiredService<IRabbitMqConnectionFactory>();
Expand All @@ -139,7 +138,7 @@ public void WhenExchangeExistsAsyncCalledWithNonExistentExchangeThenShouldReturn

verify.Should().NotThrow();
}
[IntegrationTest]
[RabbitMqTest]
public void WhenExchangeExistsAsyncCalledWithExistingExchangeThenShouldReturnTrue()
{
var factory = ServiceProvider.GetRequiredService<IRabbitMqConnectionFactory>();
Expand Down

0 comments on commit 536ac12

Please sign in to comment.