-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (105 loc) · 4.6 KB
/
build.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
name: Build and Test
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/[email protected]
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: create check
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const check = await github.rest.checks.create({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
head_sha: context.sha,
status: 'in_progress',
name: 'SUCESSO🚀'
});
console.log(check);
const checkUpdate = await github.rest.checks.update({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
check_run_id: check.data.id,
name: 'SUCESSO🚀',
started_at: '2018-05-04T01:14:52Z',
status: 'completed',
conclusion: 'failure',
completed_at: '2018-05-04T01:14:52Z'
});
console.log(checkUpdate);
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore DotNet Tools
run: dotnet tool restore
- name: Restore dependencies
run: dotnet restore ./PubDev.Store.sln
- name: Build
run: dotnet build ./PubDev.Store.sln --no-restore
- name: Test
run: dotnet test ./PubDev.Store.sln /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.11
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v1
with:
path: ./.sonar/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: pwsh
run: |
New-Item -Path ./.sonar/scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: pwsh
run: |
./.sonar/scanner/dotnet-sonarscanner begin /k:"Pub-Dev_Lesson-DotNet-Test-Mutation" /o:"pub-dev" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build ./PubDev.Store.sln --no-restore
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
- name: Run Mutations
if: steps.branch-name.outputs.is_default == 'false'
run: dotnet stryker -tp "tests/API.Tests/PubDev.Store.API.Tests.csproj" --reporter "dashboard" --with-baseline:${{ steps.branch-name.outputs.base_ref_branch }} --dashboard-api-key ${{ secrets.STRYKER_API_KEY }} --version ${{ steps.branch-name.outputs.head_ref_branch }}
- name: "Comment PR"
uses: actions/[email protected]
if: github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { issue: { number: issue_number }, repo: { owner, repo } } = context;
const message = `🚀 **Stryker report generated** 🚀
[![Mutation testing badge](https://img.shields.io/endpoint?style=for-the-badge&url=https://badge-api.stryker-mutator.io/github.com/Pub-Dev/Lesson-DotNet-Test-Mutation/${{ steps.branch-name.outputs.head_ref_branch }})](https://dashboard.stryker-mutator.io/reports/github.com/Pub-Dev/Lesson-DotNet-Test-Mutation/${{ steps.branch-name.outputs.head_ref_branch }})
to more details: https://dashboard.stryker-mutator.io/reports/github.com/Pub-Dev/Lesson-DotNet-Test-Mutation/${{ steps.branch-name.outputs.head_ref_branch }}`;
github.issues.createComment({
issue_number,
owner,
repo,
body: message
});