Skip to content

Add an actual test and switch to datetime2 #26

Add an actual test and switch to datetime2

Add an actual test and switch to datetime2 #26

name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 8.x.x
- name: Calculate Version Parameters
id: version
run: |
build=${{github.run_number}}
template=`cat ./VERSION`
shortsha=$(git rev-parse --short ${{ github.sha }})
echo "template=$template" >> $GITHUB_OUTPUT
echo "template=$template"
echo "shortsha=$shortsha" >> $GITHUB_OUTPUT
echo "shortsha=$shortsha"
echo "semver=${template//build/$build}+sha.$shortsha" >> $GITHUB_OUTPUT
echo "semver=${template//build/$build}+sha.$shortsha"
echo "msver=${template//build/$build}.0" >> $GITHUB_OUTPUT
echo "msver=${template//build/$build}.0"
# Starting the SQL Server here so that it has time to get up and running before we get to the tests, it seems doing this before the restore and build
# is consistent enough.
- name: Start SQLServer Image
run: docker run --name sql-server -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=UUID58cf785a1c9c4bb3b62cb593d530c865!" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2022-latest
- name: Restore dependencies
run: dotnet restore src/DotJEM.Json.Storage2.sln
- name: Build
working-directory: ./src
run: >
dotnet build --configuration Release --no-restore
/p:Version=${{steps.version.outputs.semver}}
/p:PackageVersion=${{steps.version.outputs.semver}}
/p:AssemblyVersion=${{steps.version.outputs.msver}}
/p:FileVersion=${{steps.version.outputs.msver}}
- name: Create Test Database
run: docker exec -i sql-server /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P UUID58cf785a1c9c4bb3b62cb593d530c865! -C -d master -Q "CREATE DATABASE storage2test" \
- name: Test
working-directory: ./src
run: dotnet test --configuration Release --no-build --verbosity normal
env:
MSSQL_SA_PASSWORD: UUID58cf785a1c9c4bb3b62cb593d530c865!
mssql_connection: "Data Source=localhost,1433; User Id=sa;Initial Catalog=storage2test;Password=UUID58cf785a1c9c4bb3b62cb593d530c865!;TrustServerCertificate=yes"
- name: Publish
if: github.event_name == 'push'
working-directory: ./src
run: dotnet nuget push **/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate