Skip to content

Commit

Permalink
Add temporary directory input and upload built source option to dotne…
Browse files Browse the repository at this point in the history
…t action
  • Loading branch information
btungut committed Jan 24, 2025
1 parent b6fbb1a commit d71f6d8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
46 changes: 40 additions & 6 deletions .github/actions/dotnet-common/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ inputs:
description: 'Verbosity level for dotnet pack: quiet, minimal, normal, detailed, diagnostic'
required: true
default: 'minimal'
dir-tmp:
description: 'The directory of the temporary files'
required: true
dir-sln:
description: 'The directory of the solution file'
required: true
Expand All @@ -17,11 +20,32 @@ inputs:
required: true
dir-integration-tests:
description: 'The directory of the integration tests project'
upload-built-src:
description: 'Upload the built source code'
required: true



runs:
using: "composite"
steps:
- name: tmp_dir
id: tmp_dir
shell: bash
run: |
set -euo pipefail
TMP_DIR_ROOT="${{ inputs.dir-tmp }}"
# echo and exit if TMP_DIR_ROOT does not exist command single line
[ -d "$TMP_DIR_ROOT" ] || { echo "TMP_DIR_ROOT does not exist: $TMP_DIR_ROOT"; exit 1; }
DOTNET_TMP_DIR="${TMP_DIR_ROOT}/dotnet"
rm -rf $DOTNET_TMP_DIR
mkdir -p $DOTNET_TMP_DIR
echo "DOTNET_TMP_DIR=$DOTNET_TMP_DIR" >> $GITHUB_ENV
echo "DOTNET_TMP_DIR=$DOTNET_TMP_DIR"
- name: dotnet_restore_and_build
id: dotnet_restore_and_build
shell: bash
Expand Down Expand Up @@ -64,32 +88,32 @@ runs:
exit 1
fi
cp $coverage_files ${{ runner.temp }}/result.xml
cp $coverage_files "${{ env.DOTNET_TMP_DIR }}/result.xml"
working-directory: ${{ inputs.dir-unit-tests }}


- uses: danielpalme/[email protected]
with:
reports: ${{ runner.temp }}/result.xml
reports: ${{ env.DOTNET_TMP_DIR }}/result.xml
reporttypes: "Html;MarkdownSummaryGithub;Cobertura"
toolpath: 'reportgeneratortool'
targetdir: ${{ runner.temp }}/coveragereport
targetdir: ${{ env.DOTNET_TMP_DIR }}/coveragereport
tag: ${{ runner.name }}


- name: Upload coverage report artifact
uses: actions/upload-artifact@v4
with:
name: CoverageReport
path: ${{ runner.temp }}/coveragereport
path: ${{ env.DOTNET_TMP_DIR }}/coveragereport


- name: Publish coverage in build summary
run: |
set -euo pipefail
# find md file, if not exist or exist more than one fail, else get the path
md_files=$(find ${{ runner.temp }}/coveragereport -name '*.md')
md_files=$(find ${{ env.DOTNET_TMP_DIR }}/coveragereport -name '*.md')
if [ $(echo "$md_files" | wc -l) -ne 1 ]; then
echo "Markdown file not found or found more than one: $md_files"
exit 1
Expand All @@ -101,7 +125,7 @@ runs:
cat $md_files >> $GITHUB_STEP_SUMMARY
shell: bash
working-directory: ${{ runner.temp }}/coveragereport
working-directory: ${{ env.DOTNET_TMP_DIR }}/coveragereport


- name: dotnet_integration_test
Expand All @@ -112,3 +136,13 @@ runs:
dotnet test -c Release --no-build --no-restore --verbosity ${{ inputs.dotnet-verbosity }}
working-directory: ${{ inputs.dir-integration-tests }}
if: ${{ success() && (inputs.dir-integration-tests != '') }}

- name: upload_built_src
uses: actions/upload-artifact@v4
with:
path: ${{ inputs.dir-src-project }}
name: src
compression-level: 9
if-no-files-found: error
include-hidden-files: true
if: ${{ inputs.upload-built-src }}
12 changes: 3 additions & 9 deletions .github/workflows/rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,14 @@ jobs:
- uses: ./app/.github/actions/dotnet-common
with:
dotnet-verbosity: ${{ env.DOTNET_VERBOSITY }}
dir-tmp: ${{ steps.common.outputs.workflow-tmp-dir }}
dir-sln: app
dir-src-project: app/src
dir-unit-tests: app/tests
dir-integration-tests: app/tests_integration
upload-built-src: true

- name: upload_src
uses: actions/upload-artifact@v4
with:
path: app/src
name: src
compression-level: 9
if-no-files-found: error
include-hidden-files: true


- name: dotnet_pack
id: dotnet_pack
shell: bash
Expand Down

0 comments on commit d71f6d8

Please sign in to comment.