Skip to content

Commit

Permalink
Change build environment to Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
virzak committed Jan 1, 2024
1 parent 4b93ee0 commit 2db32e1
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ indent_size = 2
# C# files
[*.cs]
csharp_style_namespace_declarations = file_scoped
end_of_line = crlf
dotnet_diagnostic.IDE0005.severity = warning

#### Core EditorConfig Options ####
Expand Down
45 changes: 41 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,64 @@ on:
env:
Configuration: Release
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
postgis_version: 3
DOTNET_CLI_TELEMETRY_OPTOUT: 1
pg_major: 16

jobs:
build:

runs-on: windows-latest
runs-on: ubuntu-latest

services:
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: 1
SA_PASSWORD: P@ssw0rd
ports:
- 1433:1433
defaults:
run:
shell: bash

steps:
- name: Start PostgreSQL on Windows
if: ${{ runner.os == 'Windows' }}
run: |
$pgService = Get-Service -Name postgresql*
Set-Service -InputObject $pgService -Status running -StartupType automatic
Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru
- name: Set up PostgreSQL test user
if: ${{ runner.os == 'Windows' }}
env:
PGUSER: postgres
PGPASSWORD: root
run: |
& $env:PGBIN\psql -c "CREATE USER npgsql_tests SUPERUSER PASSWORD 'npgsql_tests'"
# Borrow from https://github.com/npgsql/efcore.pg/blob/1cb8fb5d6380b1005bdfe3c56908d6fdd1f43cc2/.github/workflows/build.yml#L54
- name: Set up PostgreSQL for Linux
if: ${{ runner.os != 'Windows' }}
env:
PGUSER: postgres
PGPASSWORD: root
run: |
# First uninstall any PostgreSQL installed on the image
dpkg-query -W --showformat='${Package}\n' 'postgresql-*' | xargs sudo dpkg -P postgresql
# Import the repository signing key
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ jammy-pgdg main ${{ env.pg_major }}" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update -qq
sudo apt-get install -qq postgresql-${{ env.pg_major }}
sudo sed -i 's/max_connections = 100/max_connections = 200/g' /etc/postgresql/${{ env.pg_major }}/main/postgresql.conf
sudo systemctl restart postgresql
sudo -u postgres psql -c "CREATE USER npgsql_tests SUPERUSER PASSWORD 'npgsql_tests'"
- uses: actions/checkout@v3
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
Expand All @@ -47,8 +84,6 @@ jobs:
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
include-prerelease: true

Expand All @@ -63,6 +98,8 @@ jobs:
- name: Build
run: dotnet build -c Release --no-restore
- name: Test
env:
Zomp_EF_Data__ConnectionString: Server=localhost;Database={0};User ID=sa;Password=P@ssw0rd;MultipleActiveResultSets=true;Connect Timeout=30;TrustServerCertificate=True;
run: dotnet test -c Release --no-build --verbosity normal --settings tests/coverlet.runsettings
- name: Generate code coverage report
run: dotnet tool run reportgenerator -reports:**/coverage.cobertura.xml -targetdir:./reports/coverage
Expand All @@ -72,7 +109,7 @@ jobs:
name: coverage
path: reports/coverage
- name: Pack
run: dotnet pack --property:PackageOutputPath=$env:GITHUB_WORKSPACE/packages --no-build
run: dotnet pack --property:PackageOutputPath=${GITHUB_WORKSPACE}/packages --no-build
- name: Upload artifacts (.nupkg)
uses: actions/upload-artifact@v3
with:
Expand Down
11 changes: 10 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ if [ -n "$1" ]; then
formatLevel=$1
fi

if hash dotnet 2>/dev/null; then
dotnet=dotnet
elif hash dotnet.exe 2>/dev/null; then
dotnet=dotnet.exe
else
echo Must have dotnet
exit 1
fi

EXIT_STATUS=0
dotnet.exe tool run dotnet-format --verify-no-changes Zomp.EFCore.Extensions.sln -v $formatLevel whitespace || EXIT_STATUS=$?
$dotnet tool run dotnet-format --verify-no-changes Zomp.EFCore.Extensions.sln -v $formatLevel whitespace || EXIT_STATUS=$?
exit $EXIT_STATUS

0 comments on commit 2db32e1

Please sign in to comment.