-
Notifications
You must be signed in to change notification settings - Fork 63
128 lines (123 loc) · 4.15 KB
/
ci.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
name: publish
on:
workflow_dispatch:
push:
branches:
- 'main'
tags:
- '*'
pull_request:
branches:
- '*'
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{github.workspace}}/nuget
defaults:
run:
shell: pwsh
jobs:
create_nuget:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Get all the history so MinGit can compute the version
- name: Set up latest .NET 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- run: dotnet pack NGitLab.sln --configuration Release --output ${{env.NuGetDirectory}} /bl
- uses: actions/upload-artifact@v4
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{env.NuGetDirectory}}/**/*
- uses: actions/upload-artifact@v4
with:
name: binlogs
if-no-files-found: error
retention-days: 7
path: '**/*.binlog'
build_and_test:
runs-on: ubuntu-22.04
env:
TestResultsDirectory: ${{github.workspace}}/TestResults
strategy:
matrix:
# Keep in sync with the version in GitLabDockerContainer.cs
# Available tags: https://hub.docker.com/r/gitlab/gitlab-ee/tags
gitlab:
- 'gitlab/gitlab-ee:15.11.9-ee.0'
- 'gitlab/gitlab-ee:16.11.4-ee.0'
- 'gitlab/gitlab-ee:17.0.2-ee.0'
configuration: [Release]
fail-fast: false
services:
gitlab:
image: ${{matrix.gitlab}}
ports:
- 48624:48624
env:
GITLAB_OMNIBUS_CONFIG: "external_url 'http://localhost:48624/'"
GITLAB_ROOT_PASSWORD: "Pa$$w0rd"
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up latest .NET 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Set artifact name
id: set-artifact-name
run: |
$value = "${{matrix.gitlab}}-${{matrix.configuration}}".Replace(':', '-').Replace('/', '-')
"artifact_name=test-results-$value" >> $env:GITHUB_OUTPUT
- name: Run tests
run: dotnet test --configuration ${{matrix.configuration}} --logger trx --results-directory "${{env.TestResultsDirectory}}" --collect:"XPlat Code Coverage" /p:RunAnalyzers=false
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{steps.set-artifact-name.outputs.artifact_name}}
if-no-files-found: error
retention-days: 3
path: ${{env.TestResultsDirectory}}/**/*
- name: Test Report
uses: dorny/test-reporter@v1
if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork && (success() || failure())
with:
name: test-results-${{steps.set-artifact-name.outputs.artifact_name}}
path: ${{env.TestResultsDirectory}}/**/*.trx
path-replace-backslashes: 'true'
reporter: dotnet-trx
deploy:
runs-on: ubuntu-22.04
needs: [create_nuget, build_and_test]
steps:
- uses: actions/download-artifact@v4
with:
name: nuget
path: ${{env.NuGetDirectory}}
- name: Set up latest .NET 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Publish NuGet packages
run: |
Write-Host "Current ref: $env:GITHUB_REF"
Write-Host "Searching nupkg in folder: ${{env.NuGetDirectory}}"
$files = Get-ChildItem "${{env.NuGetDirectory}}/*" -Include *.nupkg
foreach ($file in $files) {
if ($env:GITHUB_REF -clike 'refs/tags/*')
{
Write-Host "Pushing NuGet package: $($file.FullName)"
& dotnet nuget push "$($file.FullName)" --api-key "${{secrets.NUGET_APIKEY}}" --source https://api.nuget.org/v3/index.json --force-english-output --skip-duplicate
}
else
{
Write-Host "Not on a tag => Do not push: $($file.FullName)"
}
}