Skip to content

Commit 0664b5c

Browse files
authored
change: Update Target Frameworks and Dependancies (#390)
* chore: Bump supported .NET versions to `net462` and `net6.0`+ (#377) * Add net6.0 to targeted frameworks * Add net6.0 to CI * fix: update target frameworks for integration tests ans snippets * Refactor build process and test multiple frameworks * Refactor build process and test multiple frameworks * fix script call * Refactor and update nightly and release workflows * Trigger Integration Tests * fix running unit tests in release stage * fix build before running integration tests * fix: revert to expected build name * try only 3.1 * try no specific version * fix set `Microsoft.NET.Test.Sdk` to 15.0.0 * Add Microsoft.TestPlatform.ObjectModel package for net462 * fix: Update xunit Packages and remove Microsoft.TestPlatform.ObjectModel package for net462 * Fix: tests * fix: added preprocessor directives to handle differences in tests between .net versions * Add netcoreapp3.1, net7.0 and net8.0 * fix: Add conditional package references and tests for netcoreapp3.1 * fix conditional test * Update workflows * fix: build before running integration tests * Removed netcoreap3.1 and redundant net7 and net8 * (chore): Upgrade Dependancies (#385) * [chore] Update Github action workflows to fix node version and `set-output` deprecation warnings (#376) * Add `README.md` to Nuget and update `CONTRIBUTING.md` (#389) * Trigger Integration tests * fix: correct target framework from merge. * fix: remove previous deprecation note
1 parent bef3b4c commit 0664b5c

32 files changed

+198
-165
lines changed

.github/scripts/publish_preflight_check.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ if [[ ! "${RELEASE_VERSION}" =~ ^([0-9]*)\.([0-9]*)\.([0-9]*)$ ]]; then
7070
fi
7171

7272
echo_info "Extracted release version: ${RELEASE_VERSION}"
73-
echo "::set-output name=version::v${RELEASE_VERSION}"
73+
echo "version=v${RELEASE_VERSION}" >> $GITHUB_OUTPUT
7474

7575

7676
echo_info ""
@@ -155,12 +155,13 @@ readonly CHANGELOG=`${CURRENT_DIR}/generate_changelog.sh`
155155
echo "$CHANGELOG"
156156

157157
# Parse and preformat the text to handle multi-line output.
158-
# See https://github.community/t5/GitHub-Actions/set-output-Truncates-Multiline-Strings/td-p/37870
158+
# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string
159+
# and https://github.com/github/docs/issues/21529#issue-1418590935
159160
FILTERED_CHANGELOG=`echo "$CHANGELOG" | grep -v "\\[INFO\\]"` || true
160-
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//'%'/'%25'}"
161-
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\n'/'%0A'}"
162-
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\r'/'%0D'}"
163-
echo "::set-output name=changelog::${FILTERED_CHANGELOG}"
161+
FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\''/'"'}"
162+
echo "changelog<<CHANGELOGEOF" >> $GITHUB_OUTPUT
163+
echo -e "$FILTERED_CHANGELOG" >> $GITHUB_OUTPUT
164+
echo "CHANGELOGEOF" >> $GITHUB_OUTPUT
164165

165166

166167
echo ""

.github/scripts/run_integration_tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ gpg --quiet --batch --yes --decrypt --passphrase="${FIREBASE_SERVICE_ACCT_KEY}"
2525

2626
echo "${FIREBASE_API_KEY}" > FirebaseAdmin/FirebaseAdmin.IntegrationTests/resources/integration_apikey.txt
2727

28-
dotnet test FirebaseAdmin/FirebaseAdmin.IntegrationTests
28+
dotnet test FirebaseAdmin/FirebaseAdmin.IntegrationTests --configuration Release --framework net462
29+
dotnet test FirebaseAdmin/FirebaseAdmin.IntegrationTests --configuration Release --framework net6.0

.github/workflows/ci.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ jobs:
77
strategy:
88
matrix:
99
os: [ubuntu-latest]
10+
framework-version: [net462, net6.0]
1011

1112
env:
1213
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
@@ -17,21 +18,20 @@ jobs:
1718

1819
steps:
1920
- name: Checkout code
20-
uses: actions/checkout@v1
21+
uses: actions/checkout@v4
2122

22-
- name: Setup .NET Core 2.1
23-
uses: actions/setup-dotnet@v1
23+
24+
- name: Setup .NET
25+
uses: actions/setup-dotnet@v4
2426
with:
25-
dotnet-version: 2.1.x
27+
dotnet-version: 6.0.x
2628

2729
- name: Install dependencies
28-
run: dotnet msbuild /t:restore FirebaseAdmin
30+
run: dotnet restore FirebaseAdmin/FirebaseAdmin.sln
2931

3032
- name: Build with dotnet
31-
run: |
32-
dotnet msbuild FirebaseAdmin/FirebaseAdmin
33-
dotnet msbuild FirebaseAdmin/FirebaseAdmin.Snippets
34-
dotnet msbuild FirebaseAdmin/FirebaseAdmin.IntegrationTests
33+
run: dotnet build FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore
3534

3635
- name: Run unit tests
37-
run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests
36+
run: |
37+
dotnet test FirebaseAdmin/FirebaseAdmin.Tests --configuration Release --no-restore --no-build --framework ${{ matrix.framework-version }}

.github/workflows/nightly.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,30 @@ jobs:
2828
runs-on: ubuntu-latest
2929

3030
env:
31-
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
32-
DOTNET_CLI_TELEMETRY_OPTOUT: 1
33-
DOTNET_NOLOGO: 1
31+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
32+
DOTNET_CLI_TELEMETRY_OPTOUT: true
33+
DOTNET_NOLOGO: true
3434

3535
steps:
3636
- name: Checkout source for staging
37-
uses: actions/checkout@v2
37+
uses: actions/checkout@v4
3838
with:
3939
ref: ${{ github.event.client_payload.ref || github.ref }}
4040

41-
- name: Setup .NET Core 2.1
42-
uses: actions/setup-dotnet@v1
41+
42+
- name: Setup .NET
43+
uses: actions/setup-dotnet@v4
4344
with:
44-
dotnet-version: 2.1.x
45+
dotnet-version: 6.0.x
4546

4647
- name: Install dependencies
47-
run: dotnet msbuild /t:restore FirebaseAdmin
48+
run: dotnet restore FirebaseAdmin/FirebaseAdmin.sln
4849

4950
- name: Build with dotnet
50-
run: dotnet msbuild FirebaseAdmin/FirebaseAdmin
51+
run: dotnet build FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore
5152

5253
- name: Run unit tests
53-
run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests
54+
run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests --configuration Release --no-restore --no-build
5455

5556
- name: Run integration tests
5657
run: ./.github/scripts/run_integration_tests.sh
@@ -59,7 +60,8 @@ jobs:
5960
FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
6061

6162
- name: Package release artifacts
62-
run: dotnet pack -c Release FirebaseAdmin/FirebaseAdmin
63+
run: dotnet pack FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore --no-build
64+
6365

6466
# Attach the packaged artifacts to the workflow output. These can be manually
6567
# downloaded for later inspection if necessary.

.github/workflows/release.yml

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,24 @@ jobs:
4646
# via the 'ref' client parameter.
4747
steps:
4848
- name: Checkout source for staging
49-
uses: actions/checkout@v2
49+
uses: actions/checkout@v4
5050
with:
5151
ref: ${{ github.event.client_payload.ref || github.ref }}
5252

53-
- name: Setup .NET Core 2.1
54-
uses: actions/setup-dotnet@v1
53+
54+
- name: Setup .NET
55+
uses: actions/setup-dotnet@v4
5556
with:
56-
dotnet-version: 2.1.x
57+
dotnet-version: 6.0.x
5758

5859
- name: Install dependencies
59-
run: dotnet msbuild /t:restore FirebaseAdmin
60+
run: dotnet restore FirebaseAdmin/FirebaseAdmin.sln
6061

6162
- name: Build with dotnet
62-
run: dotnet msbuild FirebaseAdmin/FirebaseAdmin
63+
run: dotnet build FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore
6364

6465
- name: Run unit tests
65-
run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests
66+
run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests --configuration Release --no-restore --no-build
6667

6768
- name: Run integration tests
6869
run: ./.github/scripts/run_integration_tests.sh
@@ -71,7 +72,7 @@ jobs:
7172
FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
7273

7374
- name: Package release artifacts
74-
run: dotnet pack -c Release FirebaseAdmin/FirebaseAdmin
75+
run: dotnet pack FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore --no-build
7576

7677
# Attach the packaged artifacts to the workflow output. These can be manually
7778
# downloaded for later inspection if necessary.
@@ -100,36 +101,31 @@ jobs:
100101

101102
steps:
102103
- name: Checkout source for publish
103-
uses: actions/checkout@v2
104+
uses: actions/checkout@v4
104105

105106
# Download the artifacts created by the stage_release job.
106107
- name: Download release candidates
107108
uses: actions/download-artifact@v1
108109
with:
109110
name: Release
110111

111-
- name: Setup .NET Core
112-
uses: actions/setup-dotnet@v1
112+
113+
- name: Setup .NET
114+
uses: actions/setup-dotnet@v4
113115
with:
114-
dotnet-version: 2.2.108
116+
dotnet-version: 6.0.x
115117

116118
- name: Publish preflight check
117119
id: preflight
118120
run: ./.github/scripts/publish_preflight_check.sh
119121

120-
# We pull this action from a custom fork of a contributor until
121-
# https://github.com/actions/create-release/pull/32 is merged. Also note that v1 of
122-
# this action does not support the "body" parameter.
122+
# See: https://cli.github.com/manual/gh_release_create
123123
- name: Create release tag
124-
uses: fleskesvor/create-release@1a72e235c178bf2ae6c51a8ae36febc24568c5fe
125124
env:
126125
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127-
with:
128-
tag_name: ${{ steps.preflight.outputs.version }}
129-
release_name: Firebase Admin .NET SDK ${{ steps.preflight.outputs.version }}
130-
body: ${{ steps.preflight.outputs.changelog }}
131-
draft: false
132-
prerelease: false
126+
run: gh release create ${{ steps.preflight.outputs.version }}
127+
--title "Firebase Admin .NET SDK ${{ steps.preflight.outputs.version }}"
128+
--notes '${{ steps.preflight.outputs.changelog }}'
133129

134130
- name: Publish to Nuget
135131
run: ./.github/scripts/publish_package.sh

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ This section explains how to set up a development environment on Linux or Mac. W
9292
should be able to import the solution file (`FirebaseAdmin/FirebaseAdmin.sln`) into Visual
9393
Studio.
9494

95-
Start by installing [.NET Core](https://www.microsoft.com/net/download) 2.1 or higher. This
96-
installs the `dotnet` command-line utility into the system.
95+
Start by installing [.NET](https://dotnet.microsoft.com/en-us/download) 6 or higher or
96+
[.NET Framework](https://dotnet.microsoft.com/en-us/download/dotnet-framework) 4.6.2 or
97+
higher. This installs the `dotnet` command-line utility into the system.
9798

9899
Run the following commands from the command line to get your local environmentset up:
99100

FirebaseAdmin/FirebaseAdmin.IntegrationTests/Auth/AbstractFirebaseAuthTest.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
using System.Linq;
1818
using System.Text;
1919
using System.Threading.Tasks;
20-
using System.Web;
2120
using FirebaseAdmin.Auth;
2221
using FirebaseAdmin.Auth.Hash;
2322
using Google.Apis.Auth.OAuth2;
23+
using Microsoft.AspNetCore.WebUtilities;
2424
using Xunit;
2525

2626
namespace FirebaseAdmin.IntegrationTests.Auth
@@ -93,7 +93,8 @@ public async Task CreateCustomTokenWithoutServiceAccount()
9393
Credential = GoogleCredential.FromAccessToken(token),
9494
ServiceAccountId = serviceAcct.Id,
9595
ProjectId = serviceAcct.ProjectId,
96-
}, "IAMSignApp");
96+
},
97+
"IAMSignApp");
9798

9899
try
99100
{
@@ -603,7 +604,7 @@ public async Task EmailVerificationLink()
603604
user.Email, EmailLinkSettings);
604605

605606
var uri = new Uri(link);
606-
var query = HttpUtility.ParseQueryString(uri.Query);
607+
var query = QueryHelpers.ParseQuery(uri.Query);
607608
Assert.Equal(ContinueUrl, query["continueUrl"]);
608609
Assert.Equal("verifyEmail", query["mode"]);
609610
}
@@ -617,7 +618,7 @@ public async Task PasswordResetLink()
617618
user.Email, EmailLinkSettings);
618619

619620
var uri = new Uri(link);
620-
var query = HttpUtility.ParseQueryString(uri.Query);
621+
var query = QueryHelpers.ParseQuery(uri.Query);
621622
Assert.Equal(ContinueUrl, query["continueUrl"]);
622623

623624
var request = new ResetPasswordRequest()
@@ -645,7 +646,7 @@ public async Task SignInWithEmailLink()
645646
user.Email, EmailLinkSettings);
646647

647648
var uri = new Uri(link);
648-
var query = HttpUtility.ParseQueryString(uri.Query);
649+
var query = QueryHelpers.ParseQuery(uri.Query);
649650
Assert.Equal(ContinueUrl, query["continueUrl"]);
650651

651652
var idToken = await AuthIntegrationUtils.SignInWithEmailLinkAsync(

FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseAdmin.IntegrationTests.csproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFrameworks>net462;net6.0</TargetFrameworks>
55
<LangVersion>latest</LangVersion>
66
<IsPackable>false</IsPackable>
77
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
88
<CodeAnalysisRuleSet>../../stylecop_test.ruleset</CodeAnalysisRuleSet>
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
13-
<PackageReference Include="xunit" Version="2.4.1" />
14-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
13+
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
14+
<PackageReference Include="System.Text.Json" Version="8.0.3" />
15+
<PackageReference Include="xunit" Version="2.7.0" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
1517
<PrivateAssets>all</PrivateAssets>
1618
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1719
</PackageReference>
1820
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
19-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.1-beta.61">
21+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
2022
<PrivateAssets>all</PrivateAssets>
2123
</PackageReference>
2224
</ItemGroup>
23-
2425
<ItemGroup>
2526
<ProjectReference Include="..\FirebaseAdmin\FirebaseAdmin.csproj" />
2627
</ItemGroup>

FirebaseAdmin/FirebaseAdmin.IntegrationTests/IntegrationTestUtils.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ internal static class IntegrationTestUtils
3030
Credential = GoogleCredential.FromFile(ServiceAccountFile),
3131
};
3232
return FirebaseApp.Create(options);
33-
}, true);
33+
},
34+
true);
3435

3536
public static FirebaseApp EnsureDefaultApp()
3637
{

FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAdmin.Snippets.csproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFrameworks>net462;net6.0</TargetFrameworks>
55
<IsPackable>false</IsPackable>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
77
<CodeAnalysisRuleSet>../../stylecop_test.ruleset</CodeAnalysisRuleSet>
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Google.Apis.Auth" Version="1.49.0" />
11+
<PackageReference Include="Google.Apis.Auth" Version="1.67.0" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
1213
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
1314
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
15+
<PackageReference Include="System.Text.Json" Version="8.0.3" />
16+
<PackageReference Include=" System.Security.Cryptography.Xml" Version="8.0.0" />
17+
<PackageReference Include="System.Net.Http" Version="4.3.4" />
18+
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
1419
</ItemGroup>
1520

1621
<ItemGroup>
1722
<ProjectReference Include="..\FirebaseAdmin\FirebaseAdmin.csproj" />
18-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.1-beta.61">
23+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
1924
<PrivateAssets>all</PrivateAssets>
2025
</PackageReference>
2126
</ItemGroup>

FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAuthSnippets.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using System;
1616
using System.Collections.Generic;
17+
using System.Linq;
1718
using System.Text;
1819
using System.Threading.Tasks;
1920
using FirebaseAdmin.Auth;
@@ -582,9 +583,10 @@ internal static async Task SetCustomUserClaimsIncrementalAsync()
582583
object isAdmin;
583584
if (user.CustomClaims.TryGetValue("admin", out isAdmin) && (bool)isAdmin)
584585
{
585-
var claims = new Dictionary<string, object>(user.CustomClaims);
586+
var claims = user.CustomClaims.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
586587
// Add level.
587-
claims["level"] = 10;
588+
var level = 10;
589+
claims["level"] = level;
588590
// Add custom claims for additional privileges.
589591
await FirebaseAuth.DefaultInstance.SetCustomUserClaimsAsync(user.Uid, claims);
590592
}

0 commit comments

Comments
 (0)