Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cockroachDB to EFcore CI #2280

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 75 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ env:
jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -198,3 +197,78 @@ jobs:
- name: Publish to nuget.org
run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_ORG_API_KEY }} --source https://api.nuget.org/v3/index.json
working-directory: nupkgs

build-cockroach:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04 ]
crdb_major: [ v21.2.5, master ]
config: [Release]
include:
- os: ubuntu-20.04
crdb_major: master
config: Debug
outputs:
is_release: ${{ steps.analyze_tag.outputs.is_release }}
is_prerelease: ${{ steps.analyze_tag.outputs.is_prerelease }}

steps:
- name: Checkout
uses: actions/[email protected]

- name: Setup .NET Core SDK
uses: actions/[email protected]
with:
dotnet-version: ${{ env.dotnet_sdk_version }}

- name: Build
run: dotnet build --configuration Debug
shell: bash

- name: Start CockroachDB ${{ matrix.crdb_major }} (Linux)
if: startsWith(matrix.os, 'ubuntu')
run: |
# First uninstall any cockroachDB installed on the image
sudo rm -f /usr/local/bin/cockroach
# Install CRDB

if [[ ${{ matrix.crdb_major }} == "master" ]]; then
wget --no-verbose -O cockroach https://edge-binaries.cockroachdb.com/cockroach/cockroach.linux-gnu-amd64.LATEST
chmod u+x cockroach
sudo mv ./cockroach /usr/local/bin/cockroach
else
curl https://binaries.cockroachdb.com/cockroach-v21.2.5.linux-amd64.tgz | tar -xz && sudo cp -i cockroach-v21.2.5.linux-amd64/cockroach /usr/local/bin/
sudo mkdir -p /usr/local/lib/cockroach
sudo cp -i cockroach-v21.2.5.linux-amd64/lib/libgeos.so /usr/local/lib/cockroach/
sudo cp -i cockroach-v21.2.5.linux-amd64/lib/libgeos_c.so /usr/local/lib/cockroach/
fi

which cockroach
cockroach version
# Create certificates
rm -rf cockroach-data
cockroach cert create-ca --certs-dir=certs --ca-key=certs/ca.key
cockroach cert create-client --certs-dir=certs --ca-key=certs/ca.key root
cockroach cert create-node --certs-dir=certs --ca-key=certs/ca.key 127.0.0.1 127.0.0.1
# Start the initialization
cockroach start-single-node --certs-dir=certs --advertise-addr=127.0.0.1:26257 --background
cockroach sql --certs-dir=certs -e "CREATE USER crdb_tests WITH PASSWORD 'crdb_tests'; GRANT admin TO crdb_tests" --url="postgresql://[email protected]:26257/defaultdb?sslcert=certs%2Fclient.root.crt&sslkey=certs%2Fclient.root.key&sslmode=verify-full&sslrootcert=certs%2Fca.crt"
- name: Test CockroachDB
run: TEST_COCKROACH_DB=true dotnet test -c ${{ matrix.config }} --logger "GitHubActions;report-warnings=false"
shell: bash

- id: analyze_tag
name: Analyze tag
shell: bash
run: |
if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "Release tag detected"
echo "::set-output name=is_release::true"
if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+.*- ]]; then
echo "Prerelease tag detected"
echo "::set-output name=is_prerelease::true"
fi
fi

12 changes: 9 additions & 3 deletions test/EFCore.PG.FunctionalTests/TestUtilities/TestEnvironment.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Globalization;
using System;
using System.Globalization;
using Microsoft.Extensions.Configuration;

namespace Npgsql.EntityFrameworkCore.PostgreSQL.TestUtilities;
Expand All @@ -15,8 +16,13 @@ static TestEnvironment()
.AddJsonFile("config.test.json", optional: true)
.AddEnvironmentVariables();

var SectionName = "Test:Npgsql";
if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("TEST_COCKROACH_DB")))
SectionName = "Test:CockroachDB";


Config = configBuilder.Build()
.GetSection("Test:Npgsql");
.GetSection(SectionName);

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
}
Expand Down Expand Up @@ -62,4 +68,4 @@ public static bool IsPostgisAvailable
return _isPostgisAvailable.Value;
}
}
}
}
3 changes: 3 additions & 0 deletions test/EFCore.PG.FunctionalTests/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"Test": {
"Npgsql": {
"DefaultConnection": "Server=localhost;Username=npgsql_tests;Password=npgsql_tests"
},
"CockroachDB": {
"DefaultConnection": "Server=localhost;Username=crdb_tests;Password=crdb_tests;Port=26257"
}
}
}