Only run build + test for draft PRs #1782
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
name: DLCS Build, Test & Publish | |
on: | |
push: | |
branches: [ "main", "develop" ] | |
tags: [ "v*" ] | |
pull_request: | |
branches: [ "main", "develop" ] | |
paths-ignore: | |
- "docs/**" | |
- "scripts/**" | |
jobs: | |
# if this is for a draft PR, build + run tests only | |
test-dotnet-only: | |
if: github.event.pull_request.draft == true | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: src/protagonist | |
env: | |
BUILD_CONFIG: "Release" | |
SOLUTION: "protagonist.sln" | |
steps: | |
- id: checkout | |
uses: actions/checkout@v4 | |
- id: setup-dotnet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: "6.0.x" | |
- id: restore-dotnet-dependencies | |
run: dotnet restore $SOLUTION | |
- id: build-dotnet | |
run: dotnet build $SOLUTION --configuration $BUILD_CONFIG --no-restore | |
- id: test-dotnet | |
run: dotnet test $SOLUTION --filter 'Category!=Manual' --configuration $BUILD_CONFIG --no-restore --no-build --verbosity normal | |
# if this is NOT a draft: build, test, sonar-scan and build images | |
test-dotnet: | |
if: github.event.pull_request.draft == false | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: src/protagonist | |
env: | |
BUILD_CONFIG: "Release" | |
SOLUTION: "protagonist.sln" | |
steps: | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: 'zulu' # Alternative distribution options are available. | |
- id: checkout | |
uses: actions/checkout@v4 | |
- id: setup-dotnet | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: "6.0.x" | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Install SonarCloud scanners and code coverage tools | |
run: | | |
dotnet tool install --global dotnet-sonarscanner | |
dotnet tool install --global JetBrains.dotCover.GlobalTool | |
- id: restore-dotnet-dependencies | |
run: dotnet restore $SOLUTION | |
- id: build-dotnet | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
dotnet-sonarscanner begin /k:"dlcs_protagonist" /o:"dlcs" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html | |
dotnet build $SOLUTION --configuration $BUILD_CONFIG --no-restore | |
dotnet dotcover test --dcReportType=HTML --filter 'Category!=Manual' --configuration $BUILD_CONFIG --no-restore --no-build --verbosity normal | |
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" | |
build-push-orchestrator: | |
runs-on: ubuntu-latest | |
needs: test-dotnet | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/docker-build-and-push | |
name: build and push | |
with: | |
image-name: "orchestrator" | |
dockerfile: "Dockerfile.Orchestrator" | |
context: "./src/protagonist" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
build-push-thumbs: | |
runs-on: ubuntu-latest | |
needs: test-dotnet | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/docker-build-and-push | |
with: | |
image-name: "thumbs" | |
dockerfile: "Dockerfile.Thumbs" | |
context: "./src/protagonist" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
build-push-engine: | |
runs-on: ubuntu-latest | |
needs: test-dotnet | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/docker-build-and-push | |
with: | |
image-name: "engine" | |
dockerfile: "Dockerfile.Engine" | |
context: "./src/protagonist" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
build-push-portal: | |
runs-on: ubuntu-latest | |
needs: test-dotnet | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/docker-build-and-push | |
with: | |
image-name: "portal" | |
dockerfile: "Dockerfile.Portal" | |
context: "./src/protagonist" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
build-push-api: | |
runs-on: ubuntu-latest | |
needs: test-dotnet | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/docker-build-and-push | |
with: | |
image-name: "api" | |
dockerfile: "Dockerfile.API" | |
context: "./src/protagonist" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
build-push-cleanuphandler: | |
runs-on: ubuntu-latest | |
needs: test-dotnet | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/docker-build-and-push | |
with: | |
image-name: "cleanuphandler" | |
dockerfile: "Dockerfile.CleanupHandler" | |
context: "./src/protagonist" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
build-push-migrator: | |
runs-on: ubuntu-latest | |
needs: test-dotnet | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/docker-build-and-push | |
with: | |
image-name: "migrator" | |
dockerfile: "Dockerfile.Migrator" | |
context: "./src/protagonist" | |
github-token: ${{ secrets.GITHUB_TOKEN }} |