Skip to content

Commit

Permalink
feat(#476): Replace Azure DevOps pipeline with GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
HofmeisterAn committed Jun 13, 2022
1 parent f3096c0 commit 55984d7
Show file tree
Hide file tree
Showing 16 changed files with 246 additions and 230 deletions.
43 changes: 0 additions & 43 deletions .azuredevops/build.yml

This file was deleted.

60 changes: 0 additions & 60 deletions .azuredevops/publish.yml

This file was deleted.

19 changes: 9 additions & 10 deletions .cake-scripts/version.cake
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ internal sealed class BuildInformation
{
var buildSystem = context.BuildSystem();

var environment = buildSystem.GitHubActions.Environment;

var isLocalBuild = buildSystem.IsLocalBuild;

var isPullRequest = buildSystem.AzurePipelines.Environment.PullRequest.IsPullRequest;
var isPullRequest = environment.PullRequest.IsPullRequest;

var isFork = buildSystem.AzurePipelines.Environment.PullRequest.IsFork;
var isFork = "fork".Equals(environment.Workflow.EventName, StringComparison.OrdinalIgnoreCase);

var buildId = buildSystem.AzurePipelines.Environment.Build.Id.ToString();
var buildId = environment.Workflow.RunId;

var git = context.GitBranchCurrent(".");

Expand All @@ -47,17 +49,14 @@ internal sealed class BuildInformation
}
else
{
branch = buildSystem.AzurePipelines.Environment.Repository.SourceBranch;
branch = branch.Replace("refs/heads/", string.Empty);
branch = environment.Workflow.RefName;
}

if (isPullRequest)
{
pullRequestId = buildSystem.AzurePipelines.Environment.PullRequest.Number.ToString();
sourceBranch = buildSystem.AzurePipelines.Environment.PullRequest.SourceBranch;
targetBranch = buildSystem.AzurePipelines.Environment.PullRequest.TargetBranch;
sourceBranch = sourceBranch.Replace("refs/heads/", string.Empty);
targetBranch = targetBranch.Replace("refs/heads/", string.Empty);
pullRequestId = new string(environment.Workflow.Ref.Where(char.IsDigit).ToArray());
sourceBranch = environment.Workflow.HeadRef;
targetBranch = environment.Workflow.BaseRef;
}

var version = context.XmlPeek(propertiesFilePath, "/Project/PropertyGroup[2]/Version/text()");
Expand Down
120 changes: 120 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Continuous Integration & Delivery

on:
push:
branches: [ develop, master, bugfix/*, feature/* ]
pull_request:
branches: [ develop, master ]

env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_VERSION: 6.0.x
TZ: CET # https://stackoverflow.com/q/53510011

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
clean: true
lfs: true

- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Restore .NET Tools
run: dotnet tool restore

- name: Restore NuGet Packages
run: dotnet cake --target=Restore-NuGet-Packages

- name: Run Build
run: dotnet cake --target=Build

- name: Run Tests
run: dotnet cake --target=Tests --test-filter=FullyQualifiedName~${{ startsWith(matrix.os, 'ubuntu') && 'DotNet.Testcontainers' || 'DotNet.Testcontainers.Tests.Unit.Containers.Windows' }}

- name: Get Logs
run: Get-ChildItem -Path . -Include *.log -Recurse | % { Get-Content -Path $_.FullName }
shell: pwsh

- name: Rename Test And Coverage Results
run: Get-ChildItem -Path 'test-coverage' -Filter *.xml | Rename-Item -NewName { $_.Name -Replace 'coverage', '${{ matrix.os }}'.ToLower() }
shell: pwsh

- name: Upload Test And Coverage Results
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}
path: |
test-coverage
test-results
publish:
needs: build

environment: ${{ contains(fromJson('["develop", "master"]'), github.ref_name) && 'production' || 'development' }}

runs-on: ubuntu-20.04

env:
FEED_SOURCE: https://api.nuget.org/v3/index.json
FEED_APIKEY: ${{ secrets.FEED_APIKEY }}
SONARCLOUD_URL: https://sonarcloud.io
SONARCLOUD_ORGANIZATION: hofmeisteran-github
SONARCLOUD_KEY: dotnet-testcontainers
SONARCLOUD_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}

steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
clean: true
lfs: true
fetch-depth: 0

- name: Download Test And Coverage Results (ubuntu-20.04)
uses: actions/download-artifact@v3
with:
name: ubuntu-20.04

- name: Download Test And Coverage Results (windows-2019)
uses: actions/download-artifact@v3
with:
name: windows-2019

- name: Fix Absolute Code Coverage Paths
run: |
Get-ChildItem -Path 'test-coverage' -Filter *.xml | % { (Get-Content $_) -Replace '[A-Za-z0-9:\-\/\\]+src', '${{ github.workspace }}/src' | Set-Content $_ }
Get-ChildItem -Path 'test-coverage' -Filter *.xml | % { (Get-Content $_) -Replace '[A-Za-z0-9:\-\/\\]+tests', '${{ github.workspace }}/tests' | Set-Content $_ }
shell: pwsh

- name: Restore .NET Tools
run: dotnet tool restore

- name: Restore NuGet Packages
run: dotnet cake --target=Restore-NuGet-Packages

- name: Run Sonar Analysis
run: dotnet cake --target=Sonar-Begin

- name: Run Build
run: dotnet cake --target=Build

- name: Upload Sonar Results
run: dotnet cake --target=Sonar-End

- name: Publish NuGet Package
run: dotnet cake --target=Publish
14 changes: 6 additions & 8 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@ on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop ]
branches: [ develop, master ]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-20.04
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ csharp ]

permissions:
security-events: write

runs-on: ubuntu-20.04

steps:
- name: Checkout Repository
uses: actions/checkout@v2
Expand Down
47 changes: 0 additions & 47 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,3 @@ To build the project just run the provided Cake script, `dotnet cake --target=Bu
3. Do not forget the unit tests and keep the SonarCloud statistics in mind.
4. If you are finished rebase and create a pull request.
5. Cheers, :beers:.

### Commit Messages

.NET Testcontainers uses a consitent and structured vocabulary for commit messages with the following pattern:

```
[ISSUE] #LABEL 'specification'
{Comment}
```

#### Labels

- \#INIT: Initializes a repository or a new release
- `assemblyName`: assembly name
- `version`: version
- \#IMPLEMENT: Implement a new function
- `assemblyName`: assembly name
- `function`: class
- \#CHANGE: Change an existing function
- `assemblyName`: assembly name
- `function`: class
- \#EXTEND: Extend an existing function
- `assemblyName`: assembly name
- `function`: class
- \#BUGFIX: Bugfix
- `assemblyName`: assembly name
- \#REVIEW: Quality control
- `assemblyName`: assembly name
- `refactor`: function
- `analyze`: quality
- `migrate`: function
- `format`: source

#### Examples

```
[1] #INIT 'assemblyName: DotNet.Testcontainers; version: 1.0.0'
[2] #IMPLEMENT 'assemblyName: DotNet.Testcontainers; function: TestcontainersClient'
{Add Dockerfile support.}
[3] #CHANGE 'assemblyName: DotNet.Testcontainers; function: TestcontainersConfiguration'
{Change default wait strategy to WaitUntilContainerIsRunning.}
[4] #EXTEND 'assemblyName: DotNet.Testcontainers; function: TestcontainersConfiguration'
{Add new configuration property WaitStrategy.}
```
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<Company>Andre Hofmeister</Company>
<Description>A lightweight library to run tests with throwaway instances of Docker containers.</Description>
<Summary>.NET Testcontainers makes it easy to run tests with Docker containers. Create reliable and fast environments within seconds and throw them away if not needed anymore.</Summary>
<PackageIcon>DotNet.Testcontainers.png</PackageIcon>
<PackageIconUrl>https://github.com/HofmeisterAn/dotnet-testcontainers/raw/develop/docs/DotNet.Testcontainers.png</PackageIconUrl>
<PackageIcon>Logo.png</PackageIcon>
<PackageIconUrl>https://github.com/HofmeisterAn/dotnet-testcontainers/raw/develop/docs/Logo.png</PackageIconUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://github.com/HofmeisterAn/dotnet-testcontainers</PackageProjectUrl>
<PackageTags>.NET;Docker;Container;Test</PackageTags>
Expand All @@ -36,7 +36,7 @@
</PropertyGroup>
<ItemGroup>
<None Include="$(SolutionDir)LICENSE" Visible="false" Pack="true" PackagePath="" />
<None Include="$(SolutionDir)docs/DotNet.Testcontainers.png" Visible="false" Pack="true" PackagePath="" />
<None Include="$(SolutionDir)docs/Logo.png" Visible="false" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![NuGet](https://img.shields.io/nuget/v/DotNet.Testcontainers.svg)](https://www.nuget.org/packages/DotNet.Testcontainers)
[![NuGet](https://img.shields.io/nuget/vpre/DotNet.Testcontainers.svg)](https://www.nuget.org/packages/DotNet.Testcontainers)
[![Build Status](https://dev.azure.com/HofmeisterAn/GitHub-Testcontainers/_apis/build/status/Build?branchName=refs/heads/develop)](https://dev.azure.com/HofmeisterAn/GitHub-Testcontainers/_build/latest?definitionId=15&branchName=refs/heads/develop)
[![Continuous Integration](https://github.com/HofmeisterAn/dotnet-testcontainers/actions/workflows/cicd.yml/badge.svg?branch=develop)](https://github.com/HofmeisterAn/dotnet-testcontainers/actions/workflows/cicd.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=dotnet-testcontainers&metric=alert_status)](https://sonarcloud.io/dashboard?id=dotnet-testcontainers)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=dotnet-testcontainers&metric=coverage)](https://sonarcloud.io/dashboard?id=dotnet-testcontainers)

Expand Down
Loading

0 comments on commit 55984d7

Please sign in to comment.