Skip to content

C# EF Core

C# EF Core #357

name: C# EF Core
on:
pull_request:
paths:
- '.github/workflows/lang-csharp-efcore.yml'
- 'by-language/csharp-efcore/**'
- '/requirements.txt'
push:
branches: [ main ]
paths:
- '.github/workflows/lang-csharp-efcore.yml'
- 'by-language/csharp-efcore/**'
- '/requirements.txt'
# Allow job to be triggered manually.
workflow_dispatch:
# Run job each night after CrateDB nightly has been published.
schedule:
- cron: '0 3 * * *'
# Cancel in-progress jobs when pushing to the same branch.
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
defaults:
run:
shell: bash
jobs:
test:
name: "
.NET: ${{ matrix.dotnet-version }}
Npgsql EF: ${{ matrix.npgsql-version }}
CrateDB: ${{ matrix.cratedb-version }}
on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-latest' ]
dotnet-version: [
'8.x',
'9.x',
'10.x',
]
npgsql-version: [
'8.*',
'9.*',
'10.*',
'prerelease',
]
cratedb-version: [ 'nightly' ]
# Npgsql.EntityFrameworkCore.PostgreSQL 10.0.0 and higher needs .NET10.
exclude:
- dotnet-version: '8.x'
npgsql-version: '10.*'
- dotnet-version: '8.x'
npgsql-version: 'prerelease'
- dotnet-version: '9.x'
npgsql-version: '10.*'
- dotnet-version: '9.x'
npgsql-version: 'prerelease'
# https://docs.github.com/en/free-pro-team@latest/actions/guides/about-service-containers
services:
cratedb:
image: crate/crate:${{ matrix.cratedb-version }}
ports:
- 4200:4200
- 5432:5432
env:
CRATE_HEAP_SIZE: 4g
steps:
- name: Acquire sources
uses: actions/checkout@v6
- name: Set up .NET ${{ matrix.dotnet-version }}
id: dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ matrix.dotnet-version }}
# Note: Unless a concrete version is specified in the `global.json` file,
# the latest .NET version installed on the runner (including preinstalled
# versions) will be used by default. To control this behavior, you may want
# to use temporary `global.json` files.
# https://github.com/actions/setup-dotnet/blob/main/README.md#matrix-testing
- name: Create `global.json`
run: |
echo '{"sdk":{"version": "${{ steps.dotnet.outputs.dotnet-version }}"}}' > ./global.json
# Propagate the Npgsql version from the test matrix slot value,
# display the current list of packages with versions,
# and invoke the test suite.
- name: "Validate by-language/csharp-efcore, Npgsql ${{ matrix.npgsql-version }}"
run: |
set -e
cd by-language/csharp-efcore
if [[ "${{ matrix.npgsql-version }}" = "prerelease" ]]; then
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL --prerelease
elif [[ "${{ matrix.npgsql-version }}" = "latest" ]]; then
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL --version=*
else
dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL --version=${{ matrix.npgsql-version }}
fi
dotnet list package
dotnet run test