Add DropDatabase and CreateDatabase to GettingStarted documentation p… #601
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Heavyweight build and test | |
name: Build and Publish | |
on: | |
push: | |
branches: | |
- main | |
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/setup@v0.13.2 | |
with: | |
versionSpec: '5.x' | |
- name: Determine Version | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0.13.2 | |
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 ./grate/grate.csproj -c release -p:PackAsTool=true -p:PackageOutputPath=/tmp/grate/nupkg | |
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 | |
if: ${{ needs.set-version-number.outputs.is-release == 'true' }} | |
with: | |
name: grate-dotnet-tool-${{ needs.set-version-number.outputs.nuGetVersion }} | |
path: /tmp/grate/nupkg/* | |
- name: Push to Nuget.org | |
if: ${{ needs.set-version-number.outputs.is-release == 'true' }} | |
run: dotnet nuget push /tmp/grate/nupkg/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_ORG_KEY}} --skip-duplicate | |
build-nuget-package: | |
needs: set-version-number | |
name: Build Nuget | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
package: [ | |
"grate.core", | |
"grate.mariadb", | |
"grate.oracle", | |
"grate.postgresql", | |
"grate.sqlite", | |
"grate.sqlserver" | |
] | |
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: Pack Nuget package ${{ matrix.package }} | |
run: dotnet pack ./src/${{ matrix.package }} -c Release --include-symbols -o /tmp/grate/nupkg /p:Version=${{ env.VERSION }} | |
env: | |
VERSION: ${{ needs.set-version-number.outputs.nuGetVersion }} | |
- name: Push to Nuget.org | |
if: ${{ needs.set-version-number.outputs.is-release == 'true' }} | |
run: dotnet nuget push /tmp/grate/nupkg/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_ORG_KEY}} --skip-duplicate | |
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 }} | |
#if: ${{ needs.set-version-number.outputs.is-release == 'true' }} | |
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 }} | |
#if: ${{ needs.set-version-number.outputs.is-release == 'true' }} | |
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-msi: | |
name: Build MSI | |
needs: | |
- set-version-number | |
- build-standalone | |
runs-on: windows-latest | |
if: ${{ needs.set-version-number.outputs.is-release == 'true' }} | |
strategy: | |
matrix: | |
arch: [ "win-x64", "win-arm64" ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: grate-${{ matrix.arch }}-self-contained-${{ needs.set-version-number.outputs.nuGetVersion }} | |
path: ${{ matrix.arch }}/ | |
- name: Create msi | |
if: ${{ needs.set-version-number.outputs.is-release == 'true' }} | |
run: ./installers/msi/Create-Installer.ps1 -grateExe ./${{ matrix.arch }}/grate.exe -Version "${{ needs.set-version-number.outputs.nuGetVersion }}" | |
env: | |
VERSION: ${{ needs.set-version-number.outputs.nuGetVersion }} | |
- name: Upload MSI ${{ matrix.arch }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: grate-msi-${{ matrix.arch }}-${{ needs.set-version-number.outputs.nuGetVersion }} | |
path: ./installers/msi/tmp/*.msi | |
build-docker-image: | |
name: Build and push docker image | |
needs: | |
- set-version-number | |
#- build-standalone ## no need, we build directly from source | |
runs-on: ubuntu-latest | |
if: ${{ needs.set-version-number.outputs.is-release == 'true' }} | |
env: | |
#REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
FULL_IMAGE_NAME: ${{ github.repository }} | |
steps: | |
- uses: actions/checkout@v4 | |
# - uses: actions/download-artifact@v4 # download from another artifact is not a good idea, we need to build directly from source | |
# with: | |
# name: grate-linux-musl-x64-self-contained-${{ needs.set-version-number.outputs.nuGetVersion }} | |
# path: installers/docker/ | |
- name: Log in to the Container registry | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d | |
with: | |
#registry: ${{ env.REGISTRY }} | |
username: ${{ github.repository_owner}} | |
password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 | |
with: | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{version}},value=${{ needs.set-version-number.outputs.semVer }} | |
type=ref,event=tag | |
#images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
images: ${{ env.IMAGE_NAME }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 | |
with: | |
file: ./installers/docker/Dockerfile | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-deb: | |
name: Build Debian package | |
needs: | |
- set-version-number | |
- build-standalone | |
runs-on: ubuntu-latest | |
if: ${{ needs.set-version-number.outputs.is-release == 'true' }} | |
strategy: | |
matrix: | |
arch: [ "linux-arm64", "linux-x64" ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: grate-${{ matrix.arch }}-self-contained-${{ needs.set-version-number.outputs.nuGetVersion }} | |
path: ${{ matrix.arch }}/ | |
- id: get-arch | |
name: Get architecture | |
run: | | |
arch=$(echo ${{ matrix.arch }} | cut -d- -f2 | sed 's/x64/amd64/') | |
echo "::set-output name=arch::$arch" | |
- name: Create dpkg # Linux with powershell script? really? YES! :D | |
if: ${{ needs.set-version-number.outputs.is-release == 'true' }} | |
run: ./installers/deb/Create-Package.ps1 -grateExe ./${{ matrix.arch }}/grate -Version "${{ needs.set-version-number.outputs.nuGetVersion }}" -arch ${{ steps.get-arch.outputs.arch}} | |
env: | |
VERSION: ${{ needs.set-version-number.outputs.nuGetVersion }} | |
- name: Upload .dpkg ${{ steps.get-arch.outputs.arch }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: grate_${{ needs.set-version-number.outputs.nuGetVersion }}-1_${{ steps.get-arch.outputs.arch}}.deb | |
path: ./installers/deb/grate_${{ needs.set-version-number.outputs.nuGetVersion }}-1_${{ steps.get-arch.outputs.arch }}.deb | |
test: | |
name: Run tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
category: [ "Basic_tests", "SqlServer", "PostgreSQL", "MariaDB", "Sqlite", "Oracle" ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET 8 | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Test | |
run: > | |
dotnet test | |
unittests/${{ matrix.category }} | |
--logger:"xunit;LogFilePath=/tmp/test-results/${{ matrix.category }}.xml" -- | |
-MaxCpuCount 2 | |
env: | |
LogLevel: Warning | |
TZ: UTC | |
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: | |
category: | |
- SqlServer | |
- PostgreSQL | |
- MariaDB | |
- Sqlite | |
- Oracle | |
os: | |
# We can only run tests on Linux for now, until we start the database separately somewhere (azure, something) | |
# and run against an external database. Because the commandline tests are also for now _dependent_ on | |
# TestContainers, and running the database in a container using Docker. And Docker is only available on Linux | |
# on Github actions. | |
# - 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.category }} | |
--logger:"xunit;LogFilePath=/tmp/test-results/${{ matrix.os.arch }}/CommandLine.${{ matrix.category }}.xml" -- | |
-MaxCpuCount 2 | |
env: | |
LogLevel: Warning | |
GrateExecutablePath: ${{ github.workspace }}/executables/${{ matrix.os.arch }}/${{ matrix.os.executable }} | |
TZ: UTC | |