-
Notifications
You must be signed in to change notification settings - Fork 2
154 lines (131 loc) · 5.19 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# ITNOA
# Based on https://github.com/flcdrg/VsShowMissing
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
DOTNET_VERSION: '6.0.412' # The .NET SDK version to use
PRODUCT_VERSION: '0.1.0'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build-and-test:
name: build-and-test-${{matrix.os}}
strategy:
matrix:
include:
- solution: BSN.IpTables.Api.sln
os: [ubuntu-20.04]
# The type of runner that the job will run on
runs-on: ${{ matrix.os }}
outputs:
GitAssemblyInformationalVersion: ${{ steps.gitversion.outputs.GitAssemblyInformationalVersion }}
GitBuildVersion: ${{ steps.gitversion.outputs.GitBuildVersion }}
GitBuildVersionSimple: ${{ steps.gitversion.outputs.GitBuildVersionSimple }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- uses: actions/cache@v3
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Install dependencies
run: dotnet restore
- name: Build with Cake
uses: cake-build/cake-action@v1
with:
target: JustBuild
script-path: Build/linux-build.cake
verbosity: Diagnostic
arguments: |
projectVersion: ${{ env.PRODUCT_VERSION }}
- name: Build
id: build
run: dotnet build --configuration Release --no-restore
- name: Git Version
id: gitversion
uses: codacy/[email protected]
# set pr number, if it's a pr build
- name: set pr build number
id: PRNUMBER
if: ${{ github.event_name == 'pull_request' }}
uses: kkak10/[email protected]
# set report file and title
- name: Set Test Title
run: |
if ${{ github.event_name == 'pull_request' }}
then
echo "title=Test Run for PR #${{steps.PRNUMBER.outputs.pr}} (${{github.run_number}})" >> $GITHUB_ENV
echo "file_name=TestReport.${{steps.PRNUMBER.outputs.pr}}.${{github.run_number}}.md" >> $GITHUB_ENV
else
echo "title=Test Run ${{github.run_number}}" >> $GITHUB_ENV
echo "file_name=TestReport.${{github.run_number}}.md" >> $GITHUB_ENV
fi
# run tests with built project
- name: Test with Cake
uses: cake-build/cake-action@v1
with:
target: JustTest
script-path: Build/linux-build.cake
verbosity: Diagnostic
arguments: |
projectVersion: ${{ env.PRODUCT_VERSION }}
- name: Test
run: |
sudo dotnet test --no-restore --verbosity normal --logger trx --results-directory Build/artifacts
sudo dotnet test --no-restore --no-build --configuration Release --logger:"liquid.md;LogFileName=${{github.workspace}}/${{env.file_name}};Title=${{env.title}};"
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3
with:
# Artifact name
name: Test Results
# A file, directory or wildcard pattern that describes what to upload
path: 'Build/artifacts/*.xml'
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
# add report as PR comment (if PR)
- name: comment PR
uses: machine-learning-apps/pr-comment@master
if: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
path: ${{env.file_name}}
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
update_release_draft:
name: Update release draft
runs-on: ubuntu-latest
needs: [build-and-test]
env:
GitAssemblyInformationalVersion: ${{ needs.build-and-test.outputs.GitAssemblyInformationalVersion }}
GitBuildVersion: ${{ needs.build-and-test.outputs.GitBuildVersion }}
GitBuildVersionSimple: ${{ needs.build-and-test.outputs.GitBuildVersionSimple }}
if: github.ref == 'refs/heads/main' # Running this job only for master branch
steps:
- uses: actions/checkout@v4
- uses: release-drafter/release-drafter@v5
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: ${{ needs.build-and-test.outputs.GitBuildVersionSimple }}