-
-
Notifications
You must be signed in to change notification settings - Fork 5
113 lines (106 loc) · 3.89 KB
/
WebExtensions.Net-Build.yml
File metadata and controls
113 lines (106 loc) · 3.89 KB
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
name: Build
on:
push:
branches: [ main ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DOTNET_VERSION: '10.0'
permissions:
contents: read
jobs:
version:
runs-on: ubuntu-latest
outputs:
MajorMinorPatch: ${{ steps.gitversion.outputs.MajorMinorPatch }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4.1.0
with:
versionSpec: 6.x
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v4.1.0
buildAndTest:
needs: version
runs-on: windows-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: 17
distribution: 'zulu'
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}.x
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v4
with:
path: ${{ runner.temp }}\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path ${{ runner.temp }}\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path ${{ runner.temp }}\scanner
- name: Install Coverlet Console
shell: powershell
run: |
New-Item -Path ${{ runner.temp }}\coverlet -ItemType Directory
dotnet tool install coverlet.console --tool-path ${{ runner.temp }}\coverlet
- name: Restore dependencies
run: dotnet restore
- name: Begin analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ${{ runner.temp }}\scanner\dotnet-sonarscanner begin /k:"WebExtensions.Net" /o:"mingyaulee" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /v:"v${{ needs.version.outputs.MajorMinorPatch }}" /d:sonar.cs.vstest.reportsPaths="test/TestResults/*.trx" /d:sonar.cs.opencover.reportsPaths="test/TestResults/**/*.opencover.xml"
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Install Playwright
run: .\test\WebExtensions.Net.IntegrationTestsRunner\bin\Release\net${{ env.DOTNET_VERSION }}\playwright.ps1 install chromium --with-deps
- name: Test
run: ${{ runner.temp }}\coverlet\coverlet ./test/WebExtensions.Net.BrowserExtensionIntegrationTest/bin/Release/net${{ env.DOTNET_VERSION }}/browserextension/framework --include "[WebExtensions.Net]*" --target "dotnet" --targetargs "test --solution . --no-restore --no-build --configuration Release" --format opencover --output ./test/TestResults/coverage --verbosity detailed
- name: End analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ${{ runner.temp }}\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
tag:
needs: [version, buildAndTest]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Check if tag exists
uses: mukunku/tag-exists-action@v1.6.0
id: tagExistsCheck
with:
tag: 'v${{ needs.version.outputs.MajorMinorPatch }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create tag
if: steps.tagExistsCheck.outputs.exists == 'false'
uses: negz/create-tag@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: v${{ needs.version.outputs.MajorMinorPatch }}