-
Notifications
You must be signed in to change notification settings - Fork 1
148 lines (114 loc) · 4.74 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
test-and-build:
name: Test And Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Setup .NET 7.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.x
- name: Setup .NET 6.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.x
- name: Prep Auth For NuGet
run: dotnet nuget add source --username ${{secrets.NUGETUSERNAME}} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/dibiancoj/index.json"
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Dotnet Format
run: dotnet format --verify-no-changes --no-restore --verbosity d
- name: Test
run: dotnet test --collect "XPlat Code Coverage" --filter FullyQualifiedName!~LibraryCore.IntegrationTests --no-build --verbosity minimal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
#verbosity normal will show all completed tests
env: #the env variables below fixes a .net 7 issue where the code coverage is json and doesn't get outputted right. These can be removed once they make a fix https://github.com/coverlet-coverage/coverlet/issues/1391
CollectCoverage: true
CoverletOutputFormat: opencover
- name: Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true # optional (default = false)
token: ${{ secrets.CODECOVERAGETOKEN }}
integration-tests:
name: Integration Tests
runs-on: ${{ matrix.os }}
needs: test-and-build
strategy:
matrix:
os: [ ubuntu-latest ]
steps:
- uses: actions/checkout@v3
- name: Setup .NET 8.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Prep Auth For NuGet
run: dotnet nuget add source --username ${{secrets.NUGETUSERNAME}} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/dibiancoj/index.json"
- name: Docker Compose Up
working-directory: ./IntegrationTests
run: docker-compose up -d --remove-orphans
env:
DB_PW: ${{secrets.IntegrationTestSqlPw}}
- name: Core Integration Tests
run: dotnet test ./IntegrationTests/LibraryCore.IntegrationTests/LibraryCore.IntegrationTests.csproj -f net8.0 -c release
env:
Db_ConnectionString: Data Source=localhost;Initial Catalog=IntegrationTest;User Id=sa;Password=${{secrets.IntegrationTestSqlPw}};trustServerCertificate=true
- name: Mongo Integration Tests
run: dotnet test ./IntegrationTests/LibraryCore.IntegrationTests.Mongo/LibraryCore.IntegrationTests.Mongo.csproj -f net8.0 -c release
env:
Db_ConnectionString: mongodb://root:${{secrets.IntegrationTestSqlPw}}@localhost:27017
- name: Kafka Integration Tests
run: dotnet test ./IntegrationTests/LibraryCore.IntegrationTests.Kafka/LibraryCore.IntegrationTests.Kafka.csproj -f net8.0 -c release
- name: Docker Compose Down
working-directory: ./IntegrationTests
run: docker-compose down
publish-nuget-package:
name: Publish Nuget Packages
runs-on: ubuntu-latest
needs: [test-and-build, integration-tests]
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.x
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.x
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
#broke around 11/16. No changes on my end and after .net 7 came out. This step fixes it which I don't like as much.
- name: Prep Auth For NuGet
run: dotnet nuget add source --username ${{secrets.NUGETUSERNAME}} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/dibiancoj/index.json"
- name: Package The Build
run: dotnet pack --configuration Release
- name: Push The Nuget Build
run: dotnet nuget push "**/*.nupkg" --source "github" --api-key ${GITHUB_TOKEN} --skip-duplicate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}