Skip to content

Commit

Permalink
Test first job.
Browse files Browse the repository at this point in the history
  • Loading branch information
KBBA committed Jul 28, 2023
1 parent 4ad6981 commit 352766e
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 104 deletions.
112 changes: 56 additions & 56 deletions .github/workflows/build-push-nuget.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
name: NuGet Generation
# name: NuGet Generation

on:
workflow_run:
workflows: [Run Tests]
types: [completed]
# on:
# workflow_run:
# workflows: [Run Tests]
# types: [completed]

jobs:
on-success:
# jobs:
# on-success:

runs-on: ubuntu-latest
strategy:
matrix:
proj: [Monitoring, Monitoring.Web]
# runs-on: ubuntu-latest
# strategy:
# matrix:
# proj: [Monitoring, Monitoring.Web]

defaults:
run:
working-directory: ./src
# defaults:
# run:
# working-directory: ./src

name: Update NuGet package - ${{ matrix.proj }}
env:
PACKAGE_PROJECT_DIR: DR.Common.${{ matrix.proj }}
PACKAGE_PROJECT_NAME: DR.Common.${{ matrix.proj }}
# name: Update NuGet package - ${{ matrix.proj }}
# env:
# PACKAGE_PROJECT_DIR: DR.Common.${{ matrix.proj }}
# PACKAGE_PROJECT_NAME: DR.Common.${{ matrix.proj }}

if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
# steps:

- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_branch }}
# - name: Checkout repository
# uses: actions/checkout@v3
# with:
# ref: ${{ github.event.workflow_run.head_branch }}

- name: Setup .NET Core @ Latest
uses: actions/setup-dotnet@v2
with:
source-url: https://nuget.pkg.github.com/drdk/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
# - name: Setup .NET Core @ Latest
# uses: actions/setup-dotnet@v2
# with:
# source-url: https://nuget.pkg.github.com/drdk/index.json
# env:
# NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v5
# - name: Get branch name
# id: branch-name
# uses: tj-actions/branch-names@v5

- name: Running on a pull request branch, so get branch name to add to Version
if: steps.branch-name.outputs.is_default == 'false'
run: |
echo "PR_BRANCH_NAME=-${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV
# - name: Running on a pull request branch, so get branch name to add to Version
# if: steps.branch-name.outputs.is_default == 'false'
# run: |
# echo "PR_BRANCH_NAME=-${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_ENV

- name: Update project file version
uses: jacobtomlinson/gha-find-replace@v3
with:
find: '(<Version>\d+\.\d+)\.(\d+)(<)'
replace: '$1.${{ github.run_number }}${{ env.PR_BRANCH_NAME }}$3'
include: './Directory.Build.props'
# - name: Update project file version
# uses: jacobtomlinson/gha-find-replace@v3
# with:
# find: '(<Version>\d+\.\d+)\.(\d+)(<)'
# replace: '$1.${{ github.run_number }}${{ env.PR_BRANCH_NAME }}$3'
# include: './Directory.Build.props'

# Force GeneratePackageOnBuild to false since dotnet pack does not build when
# it is true (https://github.com/dotnet/sdk/issues/10335)
- name: Build solution and generate NuGet package
run: |
dotnet pack './${{ env.PACKAGE_PROJECT_DIR }}/${{ env.PACKAGE_PROJECT_NAME }}.csproj' -c Release -o out /p:GeneratePackageOnBuild=false
# # Force GeneratePackageOnBuild to false since dotnet pack does not build when
# # it is true (https://github.com/dotnet/sdk/issues/10335)
# - name: Build solution and generate NuGet package
# run: |
# dotnet pack './${{ env.PACKAGE_PROJECT_DIR }}/${{ env.PACKAGE_PROJECT_NAME }}.csproj' -c Release -o out /p:GeneratePackageOnBuild=false

# Skip duplicates since GPR does not support symbols in a separate nupkg file
- name: Push generated package to GitHub registry
run: dotnet nuget push ./out/*.nupkg --skip-duplicate
on-failure:
# # Skip duplicates since GPR does not support symbols in a separate nupkg file
# - name: Push generated package to GitHub registry
# run: dotnet nuget push ./out/*.nupkg --skip-duplicate
# on-failure:

runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'
# runs-on: ubuntu-latest
# if: ${{ github.event.workflow_run.conclusion == 'failure' }}
# steps:
# - run: echo 'The triggering workflow failed'

96 changes: 48 additions & 48 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
name: Run Tests

on:
push:
branches:
- master
pull_request:

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
proj: [Monitoring.Test, Monitoring.Web.Test]

defaults:
run:
working-directory: ./src

name: Running Tests - ${{ matrix.proj }}
env:
PACKAGE_PROJECT_DIR: DR.Common.${{ matrix.proj }}
PACKAGE_PROJECT_NAME: DR.Common.${{ matrix.proj }}

steps:

- name: Checkout repository
uses: actions/checkout@v3

- name: Setup .NET Core @ Latest
uses: actions/setup-dotnet@v2
with:
source-url: https://nuget.pkg.github.com/drdk/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
# name: Run Tests

# on:
# push:
# branches:
# - master
# pull_request:

# jobs:
# build:

# runs-on: ubuntu-latest
# strategy:
# matrix:
# proj: [Monitoring.Test, Monitoring.Web.Test]

# defaults:
# run:
# working-directory: ./src

# name: Running Tests - ${{ matrix.proj }}
# env:
# PACKAGE_PROJECT_DIR: DR.Common.${{ matrix.proj }}
# PACKAGE_PROJECT_NAME: DR.Common.${{ matrix.proj }}

# steps:

# - name: Checkout repository
# uses: actions/checkout@v3

# - name: Setup .NET Core @ Latest
# uses: actions/setup-dotnet@v2
# with:
# source-url: https://nuget.pkg.github.com/drdk/index.json
# env:
# NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Build test project and run tests
if: env.PACKAGE_PROJECT_NAME != ''
run: |
dotnet test './${{ env.PACKAGE_PROJECT_NAME }}/${{ env.PACKAGE_PROJECT_NAME }}.csproj' --logger "trx;LogFileName=test-results.trx"
# - name: Build test project and run tests
# if: env.PACKAGE_PROJECT_NAME != ''
# run: |
# dotnet test './${{ env.PACKAGE_PROJECT_NAME }}/${{ env.PACKAGE_PROJECT_NAME }}.csproj' --logger "trx;LogFileName=test-results.trx"

- name: Test Report
uses: dorny/test-reporter@v1
if: always()
with:
name: DotNET Tests
path: "**/test-results.trx"
reporter: dotnet-trx
fail-on-error: true
# - name: Test Report
# uses: dorny/test-reporter@v1
# if: always()
# with:
# name: DotNET Tests
# path: "**/test-results.trx"
# reporter: dotnet-trx
# fail-on-error: true


99 changes: 99 additions & 0 deletions .github/workflows/test-build-push-nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Test dependent packaging

on:
push:
branches:
- master

jobs:
test:

runs-on: ubuntu-latest
strategy:
matrix:
proj: [Monitoring.Test, Monitoring.Web.Test]

defaults:
run:
working-directory: ./src

name: Unit testing - ${{ matrix.proj }}
env:
PACKAGE_PROJECT_DIR: DR.Common.${{ matrix.proj }}
PACKAGE_PROJECT_NAME: DR.Common.${{ matrix.proj }}

steps:

- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_branch }}

- name: Setup .NET Core @ Latest
uses: actions/setup-dotnet@v2
with:
source-url: https://nuget.pkg.github.com/drdk/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Build test project and run tests
if: env.PACKAGE_PROJECT_NAME != ''
run: |
dotnet test './${{ env.PACKAGE_PROJECT_NAME }}/${{ env.PACKAGE_PROJECT_NAME }}.csproj' --logger "trx;LogFileName=test-results.trx"
- name: Test Report
uses: dorny/test-reporter@v1
if: always()
with:
name: DotNET Tests
path: "**/test-results.trx"
reporter: dotnet-trx
fail-on-error: true

deploy:

runs-on: ubuntu-latest
needs: test
strategy:
matrix:
proj: [Monitoring, Monitoring.Web]

defaults:
run:
working-directory: ./src

name: Update NuGet package - ${{ matrix.proj }}
env:
PACKAGE_PROJECT_DIR: DR.Common.${{ matrix.proj }}
PACKAGE_PROJECT_NAME: DR.Common.${{ matrix.proj }}

steps:

- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.workflow_run.head_branch }}

- name: Setup .NET Core @ Latest
uses: actions/setup-dotnet@v2
with:
source-url: https://nuget.pkg.github.com/drdk/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Update project file version
uses: jacobtomlinson/gha-find-replace@v3
with:
find: '(<Version>\d+\.\d+)\.(\d+)(<)'
replace: '$1.${{ github.run_number }}${{ env.PR_BRANCH_NAME }}$3'
include: './Directory.Build.props'

# Force GeneratePackageOnBuild to false since dotnet pack does not build when
# it is true (https://github.com/dotnet/sdk/issues/10335)
- name: Build solution and generate NuGet package
run: |
dotnet pack './${{ env.PACKAGE_PROJECT_DIR }}/${{ env.PACKAGE_PROJECT_NAME }}.csproj' -c Release -o out /p:GeneratePackageOnBuild=false
# Skip duplicates since GPR does not support symbols in a separate nupkg file
- name: Push generated package to GitHub registry
run: dotnet nuget push ./out/*.nupkg --skip-duplicate

0 comments on commit 352766e

Please sign in to comment.