Repository navigation
200 lines (174 loc) · 7.96 KB
/
Copy pathci.yml
File metadata and controls
200 lines (174 loc) · 7.96 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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: "Build"
on:
workflow_dispatch:
inputs:
version:
description: 'Package version that replaces the one GitVersion works out, such as 1.5.6.1. Leave empty for the usual version.'
required: false
type: string
push:
paths-ignore:
- '**.md'
- '**/NuGet.yml'
pull_request:
paths-ignore:
- '**.md'
schedule:
- cron: "15 */12 * * *"
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-14]
arch: ['amd64']
fail-fast: false
name: Build library (${{ matrix.os }})
runs-on: ${{ matrix.os }}
env:
ReleaseVersion: ${{ inputs.version }}
steps:
- name: Set Build Branch
if: github.event_name == 'schedule'
run: |
echo "BuildBranch=nightly-builds" >> "$GITHUB_ENV"
echo "BuildBranch=nightly-builds" >> $env:GITHUB_ENV
# Nightly native libraries: artifacts.duckdb.org/<branch>/, where 'latest' is DuckDB's main branch.
# Tracks the v2.0 release branch until DuckDB 2.0 ships; switch back to 'latest' after that.
- name: Set Env
if: startsWith(github.ref_name, 'nightly') || startsWith(env.BuildBranch, 'nightly')
run: |
echo "DuckDbArtifactRoot=https://artifacts.duckdb.org/v2.0-cyanoptera" >> "$GITHUB_ENV"
echo "NightlyBuild=true" >> "$GITHUB_ENV"
echo "DuckDbArtifactRoot=https://artifacts.duckdb.org/v2.0-cyanoptera" >> $env:GITHUB_ENV
echo "NightlyBuild=true" >> $env:GITHUB_ENV
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ env.BuildBranch }}
# The workspace of a hosted Windows runner is on D:, the NuGet cache and temporary files are on the slower C:.
# With both on D: the build took 37 s instead of about 92 s, in 9 runs against 7.
- name: Use the D drive for the NuGet cache and temporary files
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force 'D:\nuget\packages', 'D:\tmp' | Out-Null
'NUGET_PACKAGES=D:\nuget\packages' >> $env:GITHUB_ENV
'TEMP=D:\tmp' >> $env:GITHUB_ENV
'TMP=D:\tmp' >> $env:GITHUB_ENV
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v5
with:
global-json-file: global.json
- name: Build
run: dotnet build --configuration Release /p:BuildType=Full
- name: Pack
if: matrix.os == 'ubuntu-latest' && github.event_name != 'pull_request'
run: |
dotnet pack DuckDB.NET.Bindings/Bindings.csproj --configuration Release
dotnet pack DuckDB.NET.Data/Data.csproj --configuration Release
dotnet pack DuckDB.NET.Bindings/Bindings.csproj --configuration Release /p:BuildType=Full
dotnet pack DuckDB.NET.Data/Data.csproj --configuration Release /p:BuildType=Full
- name: Get DuckDB version
shell: pwsh
run: |
$rid = @{ Linux = 'linux-x64'; Windows = 'win-x64'; macOS = 'osx' }['${{ runner.os }}']
$library = Get-ChildItem "DuckDB.NET.Bindings/obj/runtimes/$rid/native/*" -Include *.so, *.dll, *.dylib | Select-Object -First 1
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public static class DuckDBLibrary
{
[DllImport(@"$($library.FullName)")]
private static extern IntPtr duckdb_library_version();
public static string Version => Marshal.PtrToStringUTF8(duckdb_library_version());
}
"@
"DuckDBVersion=$([DuckDBLibrary]::Version)" >> $env:GITHUB_ENV
# The connection stress tests took 272 of about 300 s of the tests on Windows. They run when code that opens,
# shares or closes the native database changed, for every push to main or a tag, for scheduled and manual runs,
# and whenever there is no earlier commit to compare with.
- name: Decide whether to run the connection stress tests
shell: bash
env:
EVENT: ${{ github.event_name }}
REF: ${{ github.ref }}
BEFORE: ${{ github.event.before }}
PR_BASE: ${{ github.event.pull_request.base.sha }}
run: |
base=""
if [ "$EVENT" = "pull_request" ]; then base="$PR_BASE"; fi
if [ "$EVENT" = "push" ] && [ "$REF" != "refs/heads/main" ] && [[ "$REF" != refs/tags/* ]]; then base="$BEFORE"; fi
if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ] || ! git cat-file -e "$base^{commit}" 2>/dev/null; then
echo "Connection stress tests run: $EVENT on $REF, or no earlier commit to compare with"
exit 0
fi
paths='^(DuckDB\.NET\.Data/Connection/|DuckDB\.NET\.Data/DuckDBConnection\.cs$|DuckDB\.NET\.Data/DuckDBDataReader\.cs$|DuckDB\.NET\.Data/DuckDBCommand\.cs$|DuckDB\.NET\.Data/PreparedStatement/|DuckDB\.NET\.Bindings/DuckDBWrapperObjects\.cs$|DuckDB\.NET\.Bindings/Bindings\.csproj$|DuckDB\.NET\.Test/DuckDBConnectionTests\.cs$|\.github/workflows/ci\.yml$)'
changed=$(git diff --name-only "$base" HEAD | grep -E "$paths" || true)
if [ -n "$changed" ]; then
echo "Connection stress tests run, because of:"
echo "$changed"
else
echo "TestFilter=Stress!=Connection" >> "$GITHUB_ENV"
echo "Connection stress tests skipped: no connection code changed since $base"
fi
- name: Run tests (DuckDB ${{ env.DuckDBVersion }})
env:
CoverletOutputFormat: lcov
run: dotnet test --configuration Release --verbosity normal --logger GitHubActions /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:BuildType=Full /p:DoesNotReturnAttribute="DoesNotReturnAttribute" ${{ env.TestFilter && format('--filter "{0}"', env.TestFilter) || '' }}
- name: Upload coverage reports to Coveralls Parallel
uses: coverallsapp/github-action@v2
if: github.event_name != 'schedule'
with:
github-token: ${{ secrets.github_token }}
flag-name: run-${{ matrix.os }}
path-to-lcov: DuckDB.NET.Test/coverage.net8.0.info
parallel: true
format: lcov
- name: Upload coverage reports to Codecov
if: matrix.os == 'ubuntu-latest' && github.event_name != 'schedule'
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: Giorgi/DuckDB.NET
- name: Upload Artifacts
if: matrix.os == 'ubuntu-latest' && github.event_name != 'pull_request' && github.actor == 'Giorgi'
uses: actions/upload-artifact@v7
with:
name: nugetPackages-${{github.ref_name}}
path: ./**/bin/Release/*.nupkg
publish:
needs: build
name: Publish Packages
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop' && github.event_name != 'pull_request' && github.event_name != 'schedule'
steps:
- name: Download nuget package artifact
uses: actions/download-artifact@v8
with:
name: nugetPackages-${{github.ref_name}}
- name: Display structure of downloaded files
run: ls -R
- name: Prep packages
run: dotnet nuget add source --username Giorgi --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Giorgi/index.json"
- name: Get package version
run: |
package=$(find . -name 'DuckDB.NET.Data.[0-9]*.nupkg' | head -n 1)
version=$(basename "$package" .nupkg)
echo "PackageVersion=${version#DuckDB.NET.Data.}" >> "$GITHUB_ENV"
- name: Push package to GitHub packages (${{ env.PackageVersion }})
run: dotnet nuget push "**/*.nupkg" --api-key ${{ secrets.GITHUB_TOKEN }} --source "github"
Finish-Coveralls-Collection:
needs: build
name: Finish Coveralls Collection
runs-on: ubuntu-latest
if: github.event_name != 'schedule'
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true