-
Notifications
You must be signed in to change notification settings - Fork 49
333 lines (313 loc) · 12.7 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
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
name: CI
on:
push:
pull_request:
schedule:
# Run daily at 00:00 so we get notified if CI is broken before a pull request
# is submitted.
- cron: '0 0 * * *'
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
PUBLISH_RELEASE: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !github.event.repository.fork }}
permissions:
contents: read
jobs:
# Note that vcpkg dependencies takes the majority of the build time.
# We cache them using GitHub Actions cache, making the scripts below a bit more complex.
check-format:
if: github.event_name == 'schedule' || github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
name: Check format
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET SDK v8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Code formating check
run: |
dotnet tool restore
dotnet jb cleanupcode "csharp" "csharp.test" "csharp.benchmark" --profile="Built-in: Reformat Code" --settings="ParquetSharp.DotSettings" --verbosity=WARN
files=($(git diff --name-only))
if [ ${#files[@]} -gt 0 ]
then
for file in $files; do echo "::error file=$file::Code format check failed"; done
exit 1
fi
# Build everything on all platorms (thus testing the developer workflow).
# Upload the native shared libraries as artifacts.
build-native:
# Do not run this job for pull requests where both branches are from the same repo.
# Other jobs will be skipped too, as they depend on this one.
# This prevents duplicate CI runs for our own pull requests, whilst preserving the ability to
# run the CI for each branch push to a fork, and for each pull request originating from a fork.
if: github.event_name == 'schedule' || github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
strategy:
matrix:
os: [ubuntu-20.04, macos-12, windows-2022]
arch: [x64, arm64]
exclude:
- os: windows-2022
arch: arm64
fail-fast: false
name: Build native ${{ matrix.arch }} library (${{ matrix.os }})
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
# Compute vcpkg triplet and root
- name: Compute vcpkg triplet and root
id: vcpkg-info
run: |
triplet="${{ matrix.arch }}-"
case ${{ runner.os }} in
Linux)
triplet+="linux"
;;
macOS)
triplet+="osx"
;;
Windows)
triplet+="windows-static"
;;
esac
echo "triplet=$triplet" >> $GITHUB_OUTPUT
echo "root=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_OUTPUT
shell: bash
# Get cmake version, which is used by the CentOS 7 container.
- name: Get cmake version
id: cmake-info
run: echo "version=$(cmake --version | head -n1 | awk '{print $3}')" >> $GITHUB_OUTPUT
shell: bash
# Ensure vcpkg builtin registry is up-to-date
- name: Update vcpkg builtin registry
working-directory: ${{ steps.vcpkg-info.outputs.root }}
run: |
git reset --hard
git pull
# Setup a CentOS 7 container to build on Linux x64 for backwards compatibility.
- name: Start CentOS container and install toolchain
if: runner.os == 'Linux' && matrix.arch == 'x64'
run: |
docker run -d --name centos --entrypoint tail -v $PWD:$PWD -v $VCPKG_INSTALLATION_ROOT:$VCPKG_INSTALLATION_ROOT quay.io/pypa/manylinux2014_x86_64 -f /dev/null
docker exec centos sh -c "yum install -y devtoolset-7 rh-git227 httpd24-curl flex bison perl-Data-Dumper perl-IPC-Cmd && \
curl -fsSL -o /tmp/cmake.sh https://github.com/Kitware/CMake/releases/download/v${{ steps.cmake-info.outputs.version }}/cmake-${{ steps.cmake-info.outputs.version }}-linux-x86_64.sh && \
sh /tmp/cmake.sh --skip-license --prefix=/usr/local && \
rm /tmp/cmake.sh"
# Install arm64 cross-compilation toolchain if required
- name: Install arm64 cross-compilation toolchain
if: runner.os == 'Linux' && matrix.arch == 'arm64'
run: |
sudo apt-get update
sudo apt install g++-aarch64-linux-gnu
# Install vcpkg dependencies
- name: Install vcpkg build dependencies (macOS)
if: runner.os == 'macOS'
run: brew install bison
# .NET Core Setup (and also MSBuild for Windows).
- name: Setup .NET SDK v8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Setup MSBuild
if: runner.os == 'Windows'
uses: microsoft/setup-msbuild@v2
# Expose GitHub Runtime environment variables for vcpkg caching.
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
# Compile ParquetSharp and C++ dependencies (and upload the native library as an artifact).
- name: Compile native ParquetSharp library (Unix)
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
if [ "${{ runner.os }}" == "Linux" ] && [ "${{ matrix.arch }}" == "x64" ]; then
exec="docker exec -w $PWD -e GITHUB_ACTIONS -e ACTIONS_CACHE_URL -e ACTIONS_RUNTIME_TOKEN -e VCPKG_BINARY_SOURCES -e VCPKG_INSTALLATION_ROOT centos scl enable devtoolset-7 rh-git227 httpd24 --"
fi
$exec ./build_unix.sh ${{ matrix.arch }}
env:
VCPKG_BINARY_SOURCES: clear;x-gha,readwrite
- name: Compile native ParquetSharp library (Windows)
if: runner.os == 'Windows'
run: ./build_windows.ps1
env:
VCPKG_BINARY_SOURCES: clear;x-gha,readwrite
- name: Upload vcpkg arrow logs
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: ${{ steps.vcpkg-info.outputs.triplet }}-vcpkg-arrow-logs
path: ${{ steps.vcpkg-info.outputs.root }}/buildtrees/arrow/*.log
- name: Build .NET benchmarks & unit tests
run: |
dotnet build csharp.benchmark --configuration=Release -p:OSArchitecture=${{ matrix.arch }}
dotnet build csharp.test --configuration=Release -p:OSArchitecture=${{ matrix.arch }}
dotnet build fsharp.test --configuration=Release -p:OSArchitecture=${{ matrix.arch }}
- name: Upload native ParquetSharp library
uses: actions/upload-artifact@v4
with:
name: ${{ steps.vcpkg-info.outputs.triplet }}-native-library
path: bin
- name: Stop CentOS container
if: runner.os == 'Linux' && matrix.arch == 'x64'
run: docker rm -f centos
# Download all native shared libraries and create the nuget package.
# Upload nuget package as an artifact.
build-nuget:
name: Build NuGet package
runs-on: ubuntu-latest
needs: build-native
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Copy native ParquetSharp libraries
run: |
mkdir bin
cp -rv artifacts/*-native-library/* bin/
- name: Setup .NET SDK v8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Get version
id: get-version
shell: pwsh
run: |
$version_prefix=$((Select-Xml -Path ./csharp/ParquetSharp.csproj -XPath '/Project/PropertyGroup/VersionPrefix/text()').node.Value)
if ( "${env:PUBLISH_RELEASE}" -eq "true") {
$version_suffix=""
$version="${version_prefix}"
} else {
$version_suffix="$(git rev-parse --short HEAD)"
$version="${version_prefix}-${version_suffix}"
}
echo "version=${version}"
echo "version=${version}" >> $env:GITHUB_OUTPUT
echo "version_suffix=${version_suffix}" >> $env:GITHUB_OUTPUT
- name: Build NuGet package
run: dotnet build csharp --configuration=Release --version-suffix "${{ steps.get-version.outputs.version_suffix }}"
- name: Upload NuGet artifact
uses: actions/upload-artifact@v4
with:
name: nuget-package
path: nuget
# Run .NET unit tests with the nuget package on all platforms and all supported .NET runtimes (thus testing the user workflow).
test-nuget:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04-arm64, macos-12, macos-13, macos-14, windows-2022]
dotnet: [netcoreapp3.1, net6.0, net7.0, net8.0]
include:
- os: windows-2022
dotnet: net472
exclude:
- os: ubuntu-22.04-arm64
dotnet: netcoreapp3.1
- os: macos-14
dotnet: netcoreapp3.1
fail-fast: false
name: Test NuGet package (${{ matrix.dotnet }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: build-nuget
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download NuGet artifact
uses: actions/download-artifact@v4
with:
name: nuget-package
path: nuget
- name: Setup .NET Core SDK v3.1.x
if: matrix.dotnet == 'netcoreapp3.1'
uses: actions/setup-dotnet@v4
with:
dotnet-version: 3.1.x
- name: Setup .NET SDK v6.0.x
if: matrix.dotnet == 'net6.0'
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
- name: Setup .NET SDK v7.0.x
if: matrix.dotnet == 'net7.0'
uses: actions/setup-dotnet@v4
with:
dotnet-version: 7.0.x
- name: Setup .NET SDK v8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Add local NuGet feed
run: |
dotnet new nugetconfig
dotnet nuget add source -n local $PWD/nuget
- name: Change test project references to use local NuGet package
run: |
dotnet remove csharp.test reference csharp/ParquetSharp.csproj
dotnet add csharp.test package ParquetSharp -v ${{ needs.build-nuget.outputs.version }}
dotnet remove fsharp.test reference csharp/ParquetSharp.csproj
dotnet add fsharp.test package ParquetSharp -v ${{ needs.build-nuget.outputs.version }}
- name: Build & Run C# unit tests
run: dotnet test csharp.test --configuration=Release --framework ${{ matrix.dotnet }}
- name: Build & Run F# unit tests
run: dotnet test fsharp.test --configuration=Release --framework ${{ matrix.dotnet }}
# Virtual job that can be configured as a required check before a PR can be merged.
# As GitHub considers a check as successful if it is skipped, we need to check its status in
# another workflow (check-required.yml) and create a check there.
all-required-checks-done:
name: All required checks done
needs:
- check-format
- test-nuget
runs-on: ubuntu-latest
steps:
- run: echo "All required checks done"
# Create a GitHub release and publish the NuGet packages to nuget.org when a tag is pushed.
publish-release:
# This should match env.PUBLISH_RELEASE (which we can't access in an if condition)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !github.event.repository.fork
name: Publish release
runs-on: ubuntu-latest
permissions:
contents: write
needs: [build-nuget,all-required-checks-done]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check version
id: check-version
shell: pwsh
run: |
$version = "${{ needs.build-nuget.outputs.version }}"
$tag = "${{ github.ref }}".SubString(10)
if (-not ($tag -eq $version)) {
echo "::error ::There is a mismatch between the project version ($version) and the tag ($tag)"
exit 1
}
- name: Download NuGet artifact
uses: actions/download-artifact@v4
with:
name: nuget-package
path: nuget
- name: Setup .NET SDK v8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
# if version contains "-" treat it as pre-release
# example: 1.0.0-beta1
- name: Create release
uses: softprops/action-gh-release@v2
with:
name: ParquetSharp ${{ needs.build-nuget.outputs.version }}
draft: true
prerelease: ${{ contains(needs.build-nuget.outputs.version, '-') }}
files: |
nuget/ParquetSharp.${{ needs.build-nuget.outputs.version }}.nupkg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to NuGet
run: dotnet nuget push nuget/ParquetSharp.${{ needs.build-nuget.outputs.version }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json