|
1 |
| -# This workflow will build a .NET project |
2 |
| -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net |
3 |
| - |
4 |
| -name: build-and-test (reusable workflow) |
5 |
| - |
6 |
| -on: |
7 |
| - workflow_call: |
8 |
| - inputs: |
9 |
| - dotnet-version: |
10 |
| - description: "required dotnet version. The default is '8.0.x'." |
11 |
| - required: true |
12 |
| - type: string |
13 |
| - default: '8.0.x' |
14 |
| - dotnet-framework: |
15 |
| - description: "target framework for dotnet test. The default is 'net8.0'." |
16 |
| - required: true |
17 |
| - type: string |
18 |
| - default: 'net8.0' |
19 |
| - configuration: |
20 |
| - description: "The configuration to use for building the package. The default is 'Release'." |
21 |
| - required: true |
22 |
| - type: string |
23 |
| - default: 'Release' |
24 |
| - |
25 |
| -jobs: |
26 |
| - build-and-test: |
27 |
| - runs-on: ubuntu-latest |
28 |
| - env: |
29 |
| - NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages |
30 |
| - steps: |
31 |
| - - run: echo "The inputs.dotnet version is ${{ inputs.dotnet-version }}, framework is ${{ inputs.dotnet-framework }}." |
32 |
| - - run: echo "The inputs.configuration is ${{ inputs.configuration }}." |
33 |
| - - run: echo "The job was automatically triggered by a ${{ github.event_name }} event." |
34 |
| - - run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!" |
35 |
| - - run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." |
36 |
| - |
37 |
| - - name: Check out repository code |
38 |
| - uses: actions/checkout@v4 |
39 |
| - - run: echo "The ${{ github.repository }} repository has been cloned to the runner." |
40 |
| - - run: echo "The workflow is now ready to test your code on the runner." |
41 |
| - - name: List files in the repository |
42 |
| - run: | |
43 |
| - ls -la ${{ github.workspace }} |
44 |
| - |
45 |
| - - name: Setup dotnet |
46 |
| - uses: actions/setup-dotnet@v4 |
47 |
| - with: |
48 |
| - dotnet-version: ${{ inputs.dotnet-version }} |
49 |
| - global-json-file: global.json |
50 |
| - cache: false |
51 |
| - - name: Display dotnet version |
52 |
| - run: dotnet --version |
53 |
| - |
54 |
| - - name: Install dependencies |
55 |
| - run: dotnet restore |
56 |
| - - name: Build |
57 |
| - run: dotnet build --no-restore --configuration ${{ inputs.configuration }} |
58 |
| - |
59 |
| - - name: Test with the dotnet CLI |
60 |
| - run: dotnet test --no-build --framework ${{ inputs.dotnet-framework }} --configuration ${{ inputs.configuration }} --verbosity normal --logger trx --results-directory "TestResults-${{ inputs.configuration }}-${{ inputs.dotnet-framework }}" |
61 |
| - - name: Upload dotnet test results |
62 |
| - uses: actions/upload-artifact@v4 |
63 |
| - with: |
64 |
| - name: dontet-results-${{ inputs.configuration }}-${{ inputs.dotnet-framework }} |
65 |
| - path: TestResults-${{ inputs.configuration }}-${{ inputs.dotnet-framework }} |
66 |
| - if: ${{ always() }} |
67 |
| - |
68 |
| - - run: echo "This job's status is ${{ job.status }}." |
69 |
| - |
| 1 | +# This workflow will build a .NET project |
| 2 | +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net |
| 3 | + |
| 4 | +name: build-and-test (reusable workflow) |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_call: |
| 8 | + inputs: |
| 9 | + dotnet-version: |
| 10 | + description: "required dotnet version. The default is '8.0.x'." |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + default: '8.0.x' |
| 14 | + dotnet-framework: |
| 15 | + description: "target framework for dotnet test. The default is 'net8.0'." |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + default: 'net8.0' |
| 19 | + configuration: |
| 20 | + description: "The configuration to use for building the package. The default is 'Release'." |
| 21 | + required: true |
| 22 | + type: string |
| 23 | + default: 'Release' |
| 24 | + |
| 25 | +jobs: |
| 26 | + build-and-test: |
| 27 | + runs-on: ubuntu-22.04 |
| 28 | + env: |
| 29 | + NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages |
| 30 | + steps: |
| 31 | + - run: echo "The inputs.dotnet version is ${{ inputs.dotnet-version }}, framework is ${{ inputs.dotnet-framework }}." |
| 32 | + - run: echo "The inputs.configuration is ${{ inputs.configuration }}." |
| 33 | + - run: echo "The job was automatically triggered by a ${{ github.event_name }} event." |
| 34 | + - run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!" |
| 35 | + - run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." |
| 36 | + |
| 37 | + - name: Check out repository code |
| 38 | + uses: actions/checkout@v4 |
| 39 | + - run: echo "The ${{ github.repository }} repository has been cloned to the runner." |
| 40 | + - run: echo "The workflow is now ready to test your code on the runner." |
| 41 | + - name: List files in the repository |
| 42 | + run: | |
| 43 | + ls -la ${{ github.workspace }} |
| 44 | + sudo cat ./.github/workflows/build-and-test.yml |
| 45 | + |
| 46 | + - name: Setup dotnet |
| 47 | + uses: actions/setup-dotnet@v4 |
| 48 | + with: |
| 49 | + dotnet-version: ${{ inputs.dotnet-version }} |
| 50 | + global-json-file: global.json |
| 51 | + cache: false |
| 52 | + |
| 53 | + - name: Display dotnet version |
| 54 | + run: | |
| 55 | + DOTNET_VERSION=$(dotnet --version) |
| 56 | + echo "DOTNET_VERSION=$DOTNET_VERSION" >> $GITHUB_ENV |
| 57 | + DOTNET_VERSION_MAJOR=$(echo $DOTNET_VERSION | cut -d '.' -f 1) |
| 58 | + DOTNET_VERSION_MINOR=$(echo $DOTNET_VERSION | cut -d '.' -f 2) |
| 59 | + echo "DOTNET_VERSION_MAJOR=$DOTNET_VERSION_MAJOR" >> $GITHUB_ENV |
| 60 | + echo "DOTNET_VERSION_MINOR=$DOTNET_VERSION_MINOR" >> $GITHUB_ENV |
| 61 | + echo "DOTNET_VERSION_MAJOR_MINOR=$DOTNET_VERSION_MAJOR.$DOTNET_VERSION_MINOR" >> $GITHUB_ENV |
| 62 | +
|
| 63 | + - run: echo "dotnet ${{ env.DOTNET_VERSION }} is installed." |
| 64 | + |
| 65 | + - name: Fixing error 'No usable version of libssl was found' for dotnet 3.1.x |
| 66 | + if: ${{ env.DOTNET_VERSION_MAJOR_MINOR == '3.1' }} |
| 67 | + run: | |
| 68 | + sudo apt-get update |
| 69 | + sudo apt-get install -y libssl-dev libssl1.1 |
| 70 | + |
| 71 | + - name: Install dependencies |
| 72 | + run: dotnet restore |
| 73 | + - name: Build |
| 74 | + run: dotnet build --no-restore --configuration ${{ inputs.configuration }} |
| 75 | + |
| 76 | + - name: Test with the dotnet CLI |
| 77 | + run: dotnet test --no-build --framework ${{ inputs.dotnet-framework }} --configuration ${{ inputs.configuration }} --verbosity normal --logger trx --results-directory "TestResults-${{ inputs.configuration }}-${{ inputs.dotnet-framework }}" |
| 78 | + - name: Upload dotnet test results |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + name: dontet-results-${{ inputs.configuration }}-${{ inputs.dotnet-framework }} |
| 82 | + path: TestResults-${{ inputs.configuration }}-${{ inputs.dotnet-framework }} |
| 83 | + if: ${{ always() }} |
| 84 | + |
| 85 | + - run: echo "This job's status is ${{ job.status }}." |
| 86 | + |
0 commit comments