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

[ODS-6169] Update Code Generation to .NET 8 #920

Merged
merged 30 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
43e0a0f
Overlooked these log4net updates in the prior PR
stephenfuqua Jan 23, 2024
c9f5a3c
Update to .NET 8
stephenfuqua Jan 23, 2024
c006c36
Opportunistic C# improvements#
stephenfuqua Jan 23, 2024
b4e5477
Correct a bad refactor
stephenfuqua Jan 23, 2024
3988624
Update packages
stephenfuqua Jan 24, 2024
b66fdfd
Fix namespace issues
stephenfuqua Jan 24, 2024
cf06f61
Approval test updates that should have been in patch2.
stephenfuqua Jan 24, 2024
2bfa3dc
Explanatory note
stephenfuqua Jan 24, 2024
ef71116
Apply change from ODS-6086
stephenfuqua Jan 24, 2024
522595b
Pull request worfklow for code generation
stephenfuqua Jan 24, 2024
5f38e5f
Case correction
stephenfuqua Jan 24, 2024
8367de0
Integration tests require the Extensions repository
stephenfuqua Jan 24, 2024
cd0ce8e
Fix checkout of Extensions
stephenfuqua Jan 24, 2024
c6c2f6a
ODS is not in the extension repo name
stephenfuqua Jan 24, 2024
18bc8a7
Tweak the artifact upload
stephenfuqua Jan 24, 2024
1b9782f
FIxup the code gen publishing action
stephenfuqua Jan 25, 2024
70bbbbb
Change the extensions path
stephenfuqua Jan 25, 2024
635d10b
Only run this action when required
stephenfuqua Jan 25, 2024
ab18405
Another attempt to get the right path
stephenfuqua Jan 25, 2024
ac2f60a
Try creating a soft link
stephenfuqua Jan 25, 2024
80ae97d
debugging
stephenfuqua Jan 25, 2024
607b89f
Switch to using ubuntu
stephenfuqua Jan 25, 2024
e0195b6
debugging
stephenfuqua Jan 25, 2024
82c5929
debugging
stephenfuqua Jan 25, 2024
6de17d2
capital R!
stephenfuqua Jan 25, 2024
85bcfb5
Need these env vars for the CheckoutBranch script
stephenfuqua Jan 25, 2024
8166bd9
Remove some debugging code
stephenfuqua Jan 25, 2024
2fa0816
Need to watch one more path
stephenfuqua Jan 25, 2024
1640e46
Restore commented out code
stephenfuqua Jan 25, 2024
be5e109
Update .github/workflows/edFi.admin.dataaccess pullrequest.yml
stephenfuqua Jan 25, 2024
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Declare files that will always have CRLF line endings on checkout.
*.tt eol=crlf
*.ttinclude eol=crlf
DatabaseViews.generated.json text eol=lf
DatabaseViews.mustache text eol=lf
9 changes: 9 additions & 0 deletions .github/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
41 changes: 22 additions & 19 deletions .github/workflows/Packages - EdFi.Ods.CodeGen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
workflow_dispatch:

env:
INFORMATIONAL_VERSION: "6.1"
BUILD_INCREMENTER: "210"
INFORMATIONAL_VERSION: "6.2"
BUILD_INCREMENTER: "1"
CONFIGURATION: "Release"
AZURE_ARTIFACT_URL: "https://pkgs.dev.azure.com/ed-fi-alliance/Ed-Fi-Alliance-OSS/_packaging/EdFi/nuget/v3/index.json"
AZURE_ARTIFACT_NUGET_KEY: ${{ secrets.AZURE_ARTIFACTS_PERSONAL_ACCESS_TOKEN }}
Expand All @@ -21,49 +21,48 @@ env:

jobs:
build:

runs-on: windows-latest

runs-on: ubuntu-latest
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything in this script that would require Windows instead of Ubuntu. Note: In the Admin API project, we publish NuGet packages to Azure Artifacts using Ubuntu.

steps:
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2
- name: Setup .NET
uses: actions/setup-dotnet@c0d4ad69d8bd405d234f1c9166d383b7a4f69ed8 # 2.1.0
with:
dotnet-version: 6.0.x
- name: Support longpaths
run: git config --system core.longpaths true
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Checkout Ed-Fi-ODS
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: Ed-Fi-Alliance-OSS/Ed-Fi-ODS
path: Ed-Fi-ODS/

- name: Checkout Ed-Fi-ODS-Implementation
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: Ed-Fi-Alliance-OSS/Ed-Fi-ODS-Implementation
path: Ed-Fi-ODS-Implementation/

- name: Is pull request branch exists in Ed-Fi-ODS-Implementation
working-directory: ./Ed-Fi-ODS/
shell: pwsh
run: |
./build.githubactions.ps1 CheckoutBranch -RelativeRepoPath "../Ed-Fi-ODS-Implementation"

- name: Checkout Ed-Fi-Extensions
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: Ed-Fi-Alliance-OSS/Ed-Fi-Extensions
path: Ed-Fi-Extensions/

- name: Is pull request branch exists in Ed-Fi-Extensions
working-directory: ./Ed-Fi-ODS/
shell: pwsh
run: |
./build.githubactions.ps1 CheckoutBranch -RelativeRepoPath "../Ed-Fi-Extensions"

- name: build
working-directory: ./Ed-Fi-ODS/
run: |
.\build.githubactions.ps1 build -Configuration ${{ env.CONFIGURATION }} -InformationalVersion ${{ env.INFORMATIONAL_VERSION}} -BuildCounter ${{ github.run_number }} -BuildIncrementer ${{env.BUILD_INCREMENTER}} -Solution "$env:GITHUB_WORKSPACE/Ed-Fi-ODS/Utilities/CodeGeneration/EdFi.Ods.CodeGen.sln"
shell: pwsh
- name: Run Unit tests for codegen Project
working-directory: ./Ed-Fi-ODS/

- name: Run Unit tests for codegen Project
working-directory: ./Ed-Fi-ODS/
run: |
$ErrorActionPreference = 'Stop'
$solution = "$env:GITHUB_WORKSPACE\Ed-Fi-ODS\Utilities\CodeGeneration\EdFi.Ods.CodeGen.sln"
Expand All @@ -75,22 +74,26 @@ jobs:
$reportName = $reports + "EdFi.Ods.CodeGen.sln.xml"
& dotnet test $solution --configuration ${{ env.CONFIGURATION }} --filter TestCategory!=LocalOnly --logger "trx;LogFileName=$reportName"
shell: pwsh

- name: pack codegen
working-directory: ./Ed-Fi-ODS/
run: |
.\build.githubactions.ps1 pack -InformationalVersion ${{ env.INFORMATIONAL_VERSION }} -BuildCounter ${{ github.run_number }} -BuildIncrementer ${{env.BUILD_INCREMENTER}} -ProjectFile "$env:GITHUB_WORKSPACE/Ed-Fi-ODS/Utilities/CodeGeneration/EdFi.Ods.CodeGen/EdFi.Ods.CodeGen.csproj" -PackageName "EdFi.Suite3.Ods.CodeGen"
shell: pwsh

- name: Install-credential-handler
run: iex "& { $(irm https://aka.ms/install-artifacts-credprovider.ps1) } -AddNetfx"
shell: pwsh

- name: publish codegen
working-directory: ./Ed-Fi-ODS/
working-directory: ./Ed-Fi-ODS/
run: |
.\build.githubactions.ps1 publish -InformationalVersion ${{ env.INFORMATIONAL_VERSION }} -BuildCounter ${{ github.run_number }} -BuildIncrementer ${{env.BUILD_INCREMENTER}} -NuGetApiKey ${{ env.AZURE_ARTIFACT_NUGET_KEY }} -EdFiNuGetFeed ${{env.AZURE_ARTIFACT_URL}} -ProjectFile "$env:GITHUB_WORKSPACE/Ed-Fi-ODS/Utilities/CodeGeneration/EdFi.Ods.CodeGen/EdFi.Ods.CodeGen.csproj" -PackageName "EdFi.Suite3.Ods.CodeGen"
shell: pwsh

- name: Upload EdFi.Ods.CodeGen NugetPackage
if: success()
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: NugetPackage.Artifacts
path: ${{ github.workspace }}/Ed-Fi-ODS/NugetPackages/*.nupkg
path: ${{ github.workspace }}/Ed-Fi-ODS/NugetPackages/*.nupkg
6 changes: 5 additions & 1 deletion .github/workflows/edFi.admin.dataaccess pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ name: EdFi.Admin.DataAccess Pull request build and test
on:
workflow_dispatch:
pull_request:
branches:
branches:
- main-6x
paths:
- Application/EdFi.Admin.DataAccess/**/*
- Application/EdFi.Admin.DataAccess.UnitTests/**/*
stephenfuqua marked this conversation as resolved.
Show resolved Hide resolved
- Application/EdFi.Common/**/*
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JBrenesSimpat I didn't think of this when reviewing your ticket: we only need to run this action when files in one of these three directories have changed. Please take the same approach with the Security. DataAccess.

@semalaiappan you might want to think about doing the same thing in the main branch. In limiting the action this way, a pull request only runs the jobs that are truly required - and that means we'll get feedback on the pull request more quickly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a small adjustment here, the path for the unit test should be - test/EdFi.Admin.DataAccess.UnitTests/**/*

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


env:
INFORMATIONAL_VERSION: "6.2"
Expand Down
99 changes: 99 additions & 0 deletions .github/workflows/edfi.codegen pullrequest.yml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 6.1-patch2 tag has a bug that prevents Code Generation from compiling. This workflow would have stopped that from happening.

I created a ticket to do the same in the main branch.

Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# SPDX-License-Identifier: Apache-2.0
# Licensed to the Ed-Fi Alliance under one or more agreements.
# The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
# See the LICENSE and NOTICES files in the project root for more information.

name: EdFi.Ods.CodeGen Pull Request Build and Test

on:
pull_request:
branches:
- main
- main-6x
paths:
- Utilities/CodeGeneration/**/*
- Application/EdFi.Common/**/*

env:
# These vars are used by `build.githubactions.ps1 CheckoutBranch`
REPOSITORY_DISPATCH_BRANCH: ${{ github.event.client_payload.branch }}
HEAD_REF: ${{ GITHUB.HEAD_REF }}
REF_NAME: ${{ GITHUB.REF_NAME }}

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out Ed-Fi-ODS
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
path: Ed-Fi-ODS/

- name: Build Code Generation
working-directory: ./Ed-Fi-ODS/Utilities/CodeGeneration
run: |
dotnet build --configuration Release

- name: Run Unit Tests
working-directory: ./Ed-Fi-ODS/Utilities/CodeGeneration
run: |
dotnet test --filter FullyQualifiedName~UnitTests --logger "trx;LogFileName=unit-tests.trx" --logger "console;verbosity=detailed"

- name: Upload Unit Test Results
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
if: always()
with:
name: unit-tests
path: ./Ed-Fi-ODS/Utilities/CodeGeneration/EdFi.Ods.CodeGen.Tests/TestResults/unit-tests.trx
retention-days: 5
if-no-files-found: warn

# Integration tests require presence of the `Ed-Fi-ODS-Implementation` and `Ed-Fi-Extensions` repositories
- name: Check out Ed-Fi-ODS-Implementation
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: Ed-Fi-Alliance-OSS/Ed-Fi-ODS-Implementation
path: Ed-Fi-ODS-Implementation

- name: Confirm Branch Exists in Ed-Fi-ODS-Implementation
working-directory: ./Ed-Fi-ODS/
shell: pwsh
run: |
./build.githubactions.ps1 CheckoutBranch -RelativeRepoPath "../Ed-Fi-ODS-Implementation"

- name: Check out Ed-Fi-ODS-Extensions
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: Ed-Fi-Alliance-OSS/Ed-Fi-Extensions
path: Ed-Fi-Extensions

- name: Confirm Branch Exists in Ed-Fi-Extensions
working-directory: ./Ed-Fi-ODS/
shell: pwsh
run: |
./build.githubactions.ps1 CheckoutBranch -RelativeRepoPath "../Ed-Fi-Extensions"

- name: Create Soft Link to Extensions
# For some reason, the integration tests when running in GitHub end up
# looking for the Extensions under Ed-Fi-ODS/Ed-Fi-ODS/Ed-Fi-Extensions,
# instead of looking in Ed-Fi-ODS/Ed-Fi-Extensions. Try resolving this
# by creating a Unix soft link to the directory.
working-directory: ./Ed-Fi-ODS/
run: |
ln -s ../Ed-Fi-Extensions .

- name: Run Integration Tests
working-directory: ./Ed-Fi-ODS/Utilities/CodeGeneration
run: |
dotnet test --filter FullyQualifiedName~IntegrationTests --logger "trx;LogFileName=integration-tests.trx" --logger "console;verbosity=detailed"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I'm logging both to file and to the console. The console logging helps in debugging if there are any failures - you don't have to download the trx file.


- name: Upload Integration Test Results
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
if: always()
with:
name: integration-tests
path: ./Ed-Fi-ODS/Utilities/CodeGeneration/EdFi.Ods.CodeGen.Tests/TestResults/integration-tests.trx
retention-days: 5
if-no-files-found: warn

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,6 @@ Utilities/SdkGen/EdFi.SdkGen.Console/csharp
appsettings.Development.json

*.log
*.trx

NugetPackages/
28 changes: 13 additions & 15 deletions Application/EdFi.Ods.Common/EdFi.Ods.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<PackageId>EdFi.Suite3.Ods.Common</PackageId>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Configurations>Debug;Release</Configurations>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<RestorePackages>true</RestorePackages>
Expand All @@ -16,22 +16,20 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="EdFi.Suite3.Common" Version="6.1.19" />
<PackageReference Include="FluentValidation" Version="10.4.0" />
<PackageReference Include="log4net" Version="2.0.13" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NHibernate" Version="5.3.11" />
<PackageReference Include="Npgsql" Version="6.0.3" />
<PackageReference Include="Quartz" Version="3.3.3" />
<PackageReference Include="Dapper" Version="2.1.28" />
<PackageReference Include="EdFi.Suite3.Common" Version="6.2.2" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.4" />
<PackageReference Include="NHibernate" Version="5.5.0" />
<PackageReference Include="Npgsql" Version="8.0.1" />
<PackageReference Include="Quartz" Version="3.8.0" />
<PackageReference Include="Sandwych.QuickGraph.Core" Version="1.0.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
</ItemGroup>
<ItemGroup>
<None Remove="Metadata\Schemas\Ed-Fi-ODS-API-Profiles.xsd" />
Expand All @@ -46,4 +44,4 @@
<ItemGroup>
<None Include="..\..\LICENSE.txt" Pack="true" PackagePath="LICENSE.txt" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// See the LICENSE and NOTICES files in the project root for more information.

using System;
using System.Runtime.Serialization;

namespace EdFi.Ods.Common.Exceptions
{
Expand Down Expand Up @@ -32,11 +31,5 @@ public ApiSecurityConfigurationException(string message) : base(message)
public ApiSecurityConfigurationException(string message, Exception inner) : base(message, inner)
{
}

protected ApiSecurityConfigurationException(
SerializationInfo info,
StreamingContext context) : base(info, context)
{
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an obsolete approach in .NET 8.

}
}
4 changes: 0 additions & 4 deletions Application/EdFi.Ods.Common/Exceptions/BadRequestException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// See the LICENSE and NOTICES files in the project root for more information.

using System;
using System.Runtime.Serialization;

namespace EdFi.Ods.Common.Exceptions
{
Expand All @@ -17,8 +16,5 @@ public BadRequestException(string message)

public BadRequestException(string message, Exception innerException)
: base(message, innerException) { }

protected BadRequestException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// See the LICENSE and NOTICES files in the project root for more information.

using System;
using System.Runtime.Serialization;

namespace EdFi.Ods.Common.Exceptions
{
Expand All @@ -25,10 +24,5 @@ public DatabaseConnectionException(string message)

public DatabaseConnectionException(string message, Exception inner)
: base(message, inner) { }

protected DatabaseConnectionException(
SerializationInfo info,
StreamingContext context)
: base(info, context) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// See the LICENSE and NOTICES files in the project root for more information.

using System;
using System.Runtime.Serialization;

namespace EdFi.Ods.Common.Exceptions
{
Expand All @@ -25,19 +24,11 @@ public DistributedCacheException(string message)

public DistributedCacheException(string message, Exception inner)
: base(message, inner) { }

protected DistributedCacheException(
SerializationInfo info,
StreamingContext context)
: base(info, context) { }
}

[Serializable]
public class SafeDistributedCacheException : DistributedCacheException
public class SafeDistributedCacheException(string message) : DistributedCacheException(message)
{
public override string StackTrace => "See log for details";

public SafeDistributedCacheException(string message)
: base(message) { }
}
}
6 changes: 0 additions & 6 deletions Application/EdFi.Ods.Common/Exceptions/NotFoundException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// See the LICENSE and NOTICES files in the project root for more information.

using System;
using System.Runtime.Serialization;

namespace EdFi.Ods.Common.Exceptions
{
Expand Down Expand Up @@ -36,11 +35,6 @@ public NotFoundException(string message, string typeName, string identifier)
public NotFoundException(string message, Exception inner)
: base(message, inner) { }

protected NotFoundException(
SerializationInfo info,
StreamingContext context)
: base(info, context) { }

public string TypeName { get; set; }

public string Identifier { get; set; }
Expand Down
Loading