Skip to content

Commit 4731db3

Browse files
committed
Added github workflows.
1 parent 147531e commit 4731db3

6 files changed

Lines changed: 377 additions & 760 deletions

File tree

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ci-${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
17+
env:
18+
BUILD_CONFIGURATION: Release
19+
20+
jobs:
21+
build-test:
22+
runs-on: windows-latest
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Setup .NET SDK
29+
uses: actions/setup-dotnet@v4
30+
with:
31+
global-json-file: global.json
32+
cache: true
33+
cache-dependency-path: |
34+
global.json
35+
Directory.Packages.props
36+
**/*.csproj
37+
38+
- name: Restore
39+
run: dotnet restore CosmosDBShell.sln
40+
41+
- name: Build solution
42+
run: dotnet build CosmosDBShell.sln --configuration $env:BUILD_CONFIGURATION --no-restore
43+
shell: pwsh
44+
45+
- name: Test solution
46+
run: >-
47+
dotnet test CosmosDBShell.sln
48+
--configuration $env:BUILD_CONFIGURATION
49+
--no-build
50+
--no-restore
51+
--logger "trx;LogFileName=test-results.trx"
52+
--results-directory TestResults
53+
--collect "Code coverage"
54+
shell: pwsh
55+
56+
- name: Run fuzzer smoke test
57+
working-directory: CosmosDBShell.Fuzzer
58+
run: dotnet run --configuration $env:BUILD_CONFIGURATION --no-build -- --all
59+
shell: pwsh
60+
61+
- name: Upload test results
62+
if: always()
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: test-results
66+
path: TestResults
67+
if-no-files-found: ignore
68+
69+
- name: Upload fuzzer findings
70+
if: always()
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: fuzz-findings
74+
path: CosmosDBShell.Fuzzer/findings
75+
if-no-files-found: ignore
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Package Unsigned Artifacts
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- v*
8+
9+
concurrency:
10+
group: package-unsigned-${{ github.ref }}
11+
cancel-in-progress: false
12+
13+
permissions:
14+
contents: read
15+
16+
env:
17+
BUILD_CONFIGURATION: Release
18+
19+
jobs:
20+
package:
21+
runs-on: windows-latest
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup .NET SDK
28+
uses: actions/setup-dotnet@v4
29+
with:
30+
global-json-file: global.json
31+
cache: true
32+
cache-dependency-path: |
33+
global.json
34+
Directory.Packages.props
35+
**/*.csproj
36+
37+
- name: Compute version properties
38+
id: version
39+
shell: pwsh
40+
run: |
41+
$version = "1.0.${{ github.run_number }}"
42+
if ("${{ github.ref_type }}" -eq "tag") {
43+
$version = "${{ github.ref_name }}"
44+
if ($version.StartsWith('v')) {
45+
$version = $version.Substring(1)
46+
}
47+
}
48+
49+
$parts = $version.Split('.')
50+
if ($parts.Count -eq 2) {
51+
$fileVersion = "$version.${{ github.run_number }}.0"
52+
} elseif ($parts.Count -eq 3) {
53+
$fileVersion = "$version.${{ github.run_number }}"
54+
} elseif ($parts.Count -ge 4) {
55+
$fileVersion = ($parts[0..3] -join '.')
56+
} else {
57+
$fileVersion = "1.0.${{ github.run_number }}.0"
58+
}
59+
60+
$infoVersion = "$version+${{ github.sha }}"
61+
62+
"package_version=$version" >> $env:GITHUB_OUTPUT
63+
"file_version=$fileVersion" >> $env:GITHUB_OUTPUT
64+
"informational_version=$infoVersion" >> $env:GITHUB_OUTPUT
65+
66+
- name: Restore
67+
run: dotnet restore CosmosDBShell.sln
68+
69+
- name: Build solution
70+
run: dotnet build CosmosDBShell.sln --configuration $env:BUILD_CONFIGURATION --no-restore
71+
shell: pwsh
72+
73+
- name: Test solution
74+
run: >-
75+
dotnet test CosmosDBShell.sln
76+
--configuration $env:BUILD_CONFIGURATION
77+
--no-build
78+
--no-restore
79+
--logger "trx;LogFileName=test-results.trx"
80+
--results-directory TestResults
81+
--collect "Code coverage"
82+
shell: pwsh
83+
84+
- name: Publish runtime artifacts
85+
shell: pwsh
86+
run: |
87+
$rids = @('win-x64', 'linux-x64', 'linux-arm64', 'osx-x64', 'osx-arm64')
88+
foreach ($rid in $rids) {
89+
dotnet publish CosmosDBShell/CosmosDBShell.csproj `
90+
--configuration $env:BUILD_CONFIGURATION `
91+
--no-restore `
92+
-r $rid `
93+
--output "out/$rid" `
94+
/p:Version=${{ steps.version.outputs.package_version }} `
95+
/p:FileVersion=${{ steps.version.outputs.file_version }} `
96+
/p:InformationalVersion=${{ steps.version.outputs.informational_version }}
97+
}
98+
99+
- name: Pack unsigned NuGet artifacts
100+
shell: pwsh
101+
run: |
102+
New-Item -ItemType Directory -Path out/nupkg -Force | Out-Null
103+
dotnet pack CosmosDBShell/CosmosDBShell.csproj `
104+
--configuration $env:BUILD_CONFIGURATION `
105+
--no-build `
106+
--no-restore `
107+
--output out/nupkg `
108+
/p:PackageVersion=${{ steps.version.outputs.package_version }} `
109+
/p:ContinuousIntegrationBuild=true
110+
111+
- name: Validate NuGet package set
112+
shell: pwsh
113+
run: |
114+
$pkgDir = Join-Path $pwd 'out/nupkg'
115+
$ridPatterns = @(
116+
'CosmosDBShell.win-x64.*.nupkg',
117+
'CosmosDBShell.linux-x64.*.nupkg',
118+
'CosmosDBShell.linux-arm64.*.nupkg',
119+
'CosmosDBShell.osx-x64.*.nupkg',
120+
'CosmosDBShell.osx-arm64.*.nupkg'
121+
)
122+
123+
foreach ($pattern in $ridPatterns) {
124+
$matches = Get-ChildItem -Path (Join-Path $pkgDir $pattern) -ErrorAction SilentlyContinue
125+
if (-not $matches -or $matches.Count -eq 0) {
126+
Write-Error "Expected package was not generated: $pattern"
127+
exit 1
128+
}
129+
}
130+
131+
$allPackages = Get-ChildItem -Path (Join-Path $pkgDir 'CosmosDBShell.*.nupkg') -ErrorAction SilentlyContinue
132+
$pointerPackages = $allPackages | Where-Object {
133+
$_.Name -notmatch '^CosmosDBShell\.(win-x64|linux-x64|linux-arm64|osx-x64|osx-arm64)\..+\.nupkg$'
134+
}
135+
136+
if (-not $pointerPackages -or $pointerPackages.Count -ne 1) {
137+
$names = @($pointerPackages | ForEach-Object { $_.Name })
138+
Write-Error "Expected exactly one pointer package (non-RID). Found: $($names -join ', ')"
139+
exit 1
140+
}
141+
142+
- name: Upload unsigned artifacts
143+
uses: actions/upload-artifact@v4
144+
with:
145+
name: unsigned-build-artifacts
146+
path: |
147+
out
148+
TestResults
149+
if-no-files-found: error

0 commit comments

Comments
 (0)