forked from testcontainers/testcontainers-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7e1df7
commit 5d827a3
Showing
1 changed file
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
name: Continuous Integration & Delivery | ||
|
||
on: | ||
push: | ||
branches: [ develop, main, bugfix/*, feature/* ] | ||
pull_request: | ||
branches: [ develop, main ] | ||
workflow_dispatch: | ||
inputs: | ||
publish_nuget_package: | ||
description: Publish a new NuGet package? | ||
required: false | ||
type: boolean | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
DOTNET_CLI_TELEMETRY_OPTOUT: true | ||
DOTNET_NOLOGO: true | ||
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | ||
DOTNET_USE_POLLING_FILE_WATCHER: true | ||
NUGET_XMLDOC_MODE: skip | ||
TZ: CET # https://stackoverflow.com/q/53510011 | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ ubuntu-22.04, ubuntu-latest, ] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Debug MSSQL Container Start | ||
run: docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=yourStrong(!)Password" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest | ||
|
||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
|
||
- name: Cache NuGet Packages | ||
uses: actions/cache@v4 | ||
with: | ||
key: ${{ matrix.os }}-nuget-${{ hashFiles('Directory.Packages.props') }} | ||
path: ~/.nuget/packages | ||
|
||
# Our modules occupy too much disk space. The GitHub-hosted runners ran into the | ||
# error: "no space left on device." The pulled images are not cleaned up between | ||
# the test runs. One obvious approach is splitting the tests and running them on | ||
# multiple runners. However, we need to keep in mind that running too many | ||
# simultaneous builds has an impact on others as well. We observed that scheduled | ||
# Dependabot builds blocked others in the Testcontainers organization. | ||
- name: Free Disk Space | ||
uses: jlumbroso/free-disk-space@v1.3.1 | ||
if: runner.os == 'Linux' | ||
with: | ||
tool-cache: true | ||
android: true | ||
dotnet: true | ||
haskell: true | ||
large-packages: true | ||
docker-images: true | ||
swap-storage: false | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
|
||
- 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=${{ startsWith(matrix.os, 'ubuntu') && 'FullyQualifiedName~Testcontainers' || 'DockerPlatform=Windows' }} | ||
|
||
# The Test Reporter GH Action is not compatible with the recent | ||
# actions/upload-artifact@v4 updates: https://github.com/dorny/test-reporter/issues/363. | ||
- name: Upload Test And Coverage Results | ||
uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: ${{ matrix.os }}-v3 | ||
path: test-results | ||
|
||
- name: Upload Test And Coverage Results | ||
uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: ${{ matrix.os }} | ||
path: test-results | ||
|
||
publish: | ||
if: ${{ contains(fromJson('["develop", "main"]'), github.ref_name) }} | ||
|
||
needs: build | ||
|
||
environment: production | ||
|
||
runs-on: ubuntu-22.04 | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: read | ||
|
||
env: | ||
CODE_SIGNING_CERTIFICATE_BASE64: ${{ secrets.CODE_SIGNING_CERTIFICATE_BASE64 }} | ||
CODE_SIGNING_CERTIFICATE_PASSWORD: ${{ secrets.CODE_SIGNING_CERTIFICATE_PASSWORD }} | ||
FEED_SOURCE: https://api.nuget.org/v3/index.json | ||
FEED_API_KEY: ${{ secrets.FEED_API_KEY }} | ||
SONARCLOUD_URL: https://sonarcloud.io | ||
SONARCLOUD_ORGANIZATION: testcontainers | ||
SONARCLOUD_KEY: testcontainers_testcontainers-dotnet | ||
SONARCLOUD_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }} | ||
PUBLISH_NUGET_PACKAGE: ${{ inputs.publish_nuget_package }} | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
fetch-depth: 0 | ||
|
||
- name: Download Test And Coverage Results (ubuntu-22.04) | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ubuntu-22.04 | ||
path: test-results | ||
|
||
- name: Download Test And Coverage Results (windows-2022) | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: windows-2022 | ||
path: test-results | ||
|
||
- name: Fix Absolute Code Coverage Paths | ||
run: Get-ChildItem -Path 'test-results' -Filter *.xml -Recurse | Select-Object -ExpandProperty FullName | % { (Get-Content -LiteralPath $_) -Replace 'fullPath="[A-Za-z0-9:\-\/\\]+(src|tests)', 'fullPath="${{ github.workspace }}/$1' | Set-Content -LiteralPath $_ } | ||
shell: pwsh | ||
|
||
- name: Cache NuGet Packages | ||
uses: actions/cache@v4 | ||
with: | ||
key: ubuntu-22.04-nuget-${{ hashFiles('Directory.Packages.props') }} | ||
path: ~/.nuget/packages | ||
|
||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
|
||
- 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 | ||
|
||
# Cake sets the semVer environment variable | ||
- uses: release-drafter/release-drafter@v6 | ||
with: | ||
version: ${{ env.semVer }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |