Skip to content
# Heavyweight integration tests
name: Integration tests
on:
push:
branches:
- main
- chore/separate-cmdline-tests-step
paths-ignore:
- docs/
workflow_dispatch:
jobs:
set-version-number:
name: Set version number
runs-on: ubuntu-latest
outputs:
nuGetVersion: ${{ steps.gitversion.outputs.nuGetVersionV2 }}
semVer: ${{ steps.gitversion.outputs.fullSemVer }}
is-release: ${{ steps.gitversion.outputs.CommitsSinceVersionSource == 0 }}
#is-release: 'true'
steps:
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
build-netcore-tool:
needs: set-version-number
name: Build .NET Core (global) tool
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet pack ./src/grate/grate.csproj -p:SelfContained=false -p:PackAsTool=true -p:PackageOutputPath=/tmp/grate/nupkg
env:
VERSION: ${{ needs.set-version-number.outputs.nuGetVersion }}
- name: Upload published tool artifact
uses: actions/upload-artifact@v4
with:
name: grate-dotnet-tool-${{ needs.set-version-number.outputs.nuGetVersion }}
path: /tmp/grate/nupkg/*
build-standalone:
name: Build cli
needs: set-version-number
runs-on: ubuntu-latest
strategy:
matrix:
arch: [ "win-x64", "win-x86", "win-arm64",
"linux-musl-x64", "linux-musl-arm64", "linux-x64", "linux-arm64",
"osx-x64"
]
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Publish self-contained ${{ matrix.arch }}
run: dotnet publish ./src/grate/grate.csproj -f net8.0 -r ${{ matrix.arch }} -c release --self-contained -p:SelfContained=true -o ./publish/${{ matrix.arch }}/self-contained
env:
VERSION: ${{ needs.set-version-number.outputs.nuGetVersion }}
- name: Upload self-contained ${{ matrix.arch }}
uses: actions/upload-artifact@v4
with:
name: grate-${{ matrix.arch }}-self-contained-${{ needs.set-version-number.outputs.nuGetVersion }}
path: ./publish/${{ matrix.arch }}/self-contained/*
build-standalone-mac-arm64:
name: Build cli
needs: set-version-number
# Use macos-14 to build osx-arm64, it runs on M1, see
# https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/
#
# I've earlier had problems with that the trimmed, self-contained binary for osx-arm64 that was built on Linux
# did not work when opened on an actual mac with arm64.
runs-on: macos-14
strategy:
matrix:
arch: [ "osx-arm64" ]
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Publish self-contained ${{ matrix.arch }}
run: dotnet publish ./src/grate/grate.csproj -f net8.0 -r ${{ matrix.arch }} -c release --self-contained -p:SelfContained=true -o ./publish/${{ matrix.arch }}/self-contained
env:
VERSION: ${{ needs.set-version-number.outputs.nuGetVersion }}
- name: Upload self-contained ${{ matrix.arch }}
uses: actions/upload-artifact@v4
with:
name: grate-${{ matrix.arch }}-self-contained-${{ needs.set-version-number.outputs.nuGetVersion }}
path: ./publish/${{ matrix.arch }}/self-contained/*
integration-test:
name: Tests cli
needs:
- set-version-number
- build-standalone
strategy:
# We could really like to:
# - Start each database (on another host, using Docker, or other means, e.g. Azure SQL, etc
# - On all architectures available (windows-latest, linux-latest, macos-latest, and macos-14),
# - Run command-line tests against each database.
#
# This way, we can test against all variations of each database too, e.g. Azure SQL, SQL Server "on prem" (in docker),
# hosted Oracle databases, aws databases, etc. But we need to find a way to provision these databases both very fast,
# and cheap, for each one.
matrix:
database:
- name: SqlServer Conn1
project: SqlServer
connectionstring: "DbConn SqlServer Conn1"
- name: SqlServer Conn2
project: SqlServer
connectionstring: "DbConn SqlServer Conn2"
- name: "PostgreSQL Conn1"
project: PostgreSQL
connectionstring: "DbConn PostgreSQL Conn1"
- name: "PostgreSQL Conn2"
project: PostgreSQL
connectionstring: "DbConn PostgreSQL Conn2"
# - name: MariaDB
# connectionstrings:
# - "MariaDB Conn1"
# - "MariaDB Conn2"
# - name: Sqlite
# connectionstrings:
# - "Sqlite Conn1"
# - name: Oracle
# connectionstrings:
# - "Oracle Conn1"
# - "Oracle Conn2"
os:
- name: windows-latest
arch: win-x64
executable: grate.exe
- name: ubuntu-latest
arch: linux-x64
executable: grate
- name: macos-latest
arch: osx-x64
executable: grate
# macos-14 is M1 (arm64)
- name: macos-14
arch: osx-x64
executable: grate
runs-on: ${{ matrix.os.name }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: grate-${{ matrix.os.arch }}-self-contained-${{ needs.set-version-number.outputs.nuGetVersion }}
path: executables/${{ matrix.os.arch }}
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: chmod u+x
run: chmod u+x $GrateExecutablePath
if: ${{ matrix.os.arch != 'win-x64' }}
env:
GrateExecutablePath: ${{ github.workspace }}/executables/${{ matrix.os.arch }}/${{ matrix.os.executable }}
- name: Test
run: >
dotnet test
unittests/CommandLine/CommandLine.${{ matrix.database.name }}
--logger:"xunit;LogFilePath=/tmp/test-results/${{ matrix.os.arch }}/CommandLine.${{ matrix.database.name }}.xml" --
-MaxCpuCount 2
env:
LogLevel: Warning
GrateExecutablePath: ${{ github.workspace }}/executables/${{ matrix.os.arch }}/${{ matrix.os.executable }}
GrateTestConfig__AdminConnectionString: ${{ matrix.database.connectionstring }}
TZ: UTC