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

change: Update Target Frameworks and Dependancies #390

Merged
merged 8 commits into from
Apr 11, 2024
Merged
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
13 changes: 7 additions & 6 deletions .github/scripts/publish_preflight_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if [[ ! "${RELEASE_VERSION}" =~ ^([0-9]*)\.([0-9]*)\.([0-9]*)$ ]]; then
fi

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


echo_info ""
Expand Down Expand Up @@ -155,12 +155,13 @@ readonly CHANGELOG=`${CURRENT_DIR}/generate_changelog.sh`
echo "$CHANGELOG"

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


echo ""
Expand Down
3 changes: 2 additions & 1 deletion .github/scripts/run_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ gpg --quiet --batch --yes --decrypt --passphrase="${FIREBASE_SERVICE_ACCT_KEY}"

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

dotnet test FirebaseAdmin/FirebaseAdmin.IntegrationTests
dotnet test FirebaseAdmin/FirebaseAdmin.IntegrationTests --configuration Release --framework net462
dotnet test FirebaseAdmin/FirebaseAdmin.IntegrationTests --configuration Release --framework net6.0
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
framework-version: [net462, net6.0]

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
Expand All @@ -17,21 +18,20 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Setup .NET Core 2.1
uses: actions/setup-dotnet@v1

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 2.1.x
dotnet-version: 6.0.x

- name: Install dependencies
run: dotnet msbuild /t:restore FirebaseAdmin
run: dotnet restore FirebaseAdmin/FirebaseAdmin.sln

- name: Build with dotnet
run: |
dotnet msbuild FirebaseAdmin/FirebaseAdmin
dotnet msbuild FirebaseAdmin/FirebaseAdmin.Snippets
dotnet msbuild FirebaseAdmin/FirebaseAdmin.IntegrationTests
run: dotnet build FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore

- name: Run unit tests
run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests
run: |
dotnet test FirebaseAdmin/FirebaseAdmin.Tests --configuration Release --no-restore --no-build --framework ${{ matrix.framework-version }}
24 changes: 13 additions & 11 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,30 @@ jobs:
runs-on: ubuntu-latest

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true

steps:
- name: Checkout source for staging
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.event.client_payload.ref || github.ref }}

- name: Setup .NET Core 2.1
uses: actions/setup-dotnet@v1

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 2.1.x
dotnet-version: 6.0.x

- name: Install dependencies
run: dotnet msbuild /t:restore FirebaseAdmin
run: dotnet restore FirebaseAdmin/FirebaseAdmin.sln

- name: Build with dotnet
run: dotnet msbuild FirebaseAdmin/FirebaseAdmin
run: dotnet build FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore

- name: Run unit tests
run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests
run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests --configuration Release --no-restore --no-build

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

- name: Package release artifacts
run: dotnet pack -c Release FirebaseAdmin/FirebaseAdmin
run: dotnet pack FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore --no-build


# Attach the packaged artifacts to the workflow output. These can be manually
# downloaded for later inspection if necessary.
Expand Down
40 changes: 18 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,24 @@ jobs:
# via the 'ref' client parameter.
steps:
- name: Checkout source for staging
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.event.client_payload.ref || github.ref }}

- name: Setup .NET Core 2.1
uses: actions/setup-dotnet@v1

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 2.1.x
dotnet-version: 6.0.x

- name: Install dependencies
run: dotnet msbuild /t:restore FirebaseAdmin
run: dotnet restore FirebaseAdmin/FirebaseAdmin.sln

- name: Build with dotnet
run: dotnet msbuild FirebaseAdmin/FirebaseAdmin
run: dotnet build FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore

- name: Run unit tests
run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests
run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests --configuration Release --no-restore --no-build

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

- name: Package release artifacts
run: dotnet pack -c Release FirebaseAdmin/FirebaseAdmin
run: dotnet pack FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore --no-build

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

steps:
- name: Checkout source for publish
uses: actions/checkout@v2
uses: actions/checkout@v4

# Download the artifacts created by the stage_release job.
- name: Download release candidates
uses: actions/download-artifact@v1
with:
name: Release

- name: Setup .NET Core
uses: actions/setup-dotnet@v1

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 2.2.108
dotnet-version: 6.0.x

- name: Publish preflight check
id: preflight
run: ./.github/scripts/publish_preflight_check.sh

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

- name: Publish to Nuget
run: ./.github/scripts/publish_package.sh
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ This section explains how to set up a development environment on Linux or Mac. W
should be able to import the solution file (`FirebaseAdmin/FirebaseAdmin.sln`) into Visual
Studio.

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using FirebaseAdmin.Auth;
using FirebaseAdmin.Auth.Hash;
using Google.Apis.Auth.OAuth2;
using Microsoft.AspNetCore.WebUtilities;
using Xunit;

namespace FirebaseAdmin.IntegrationTests.Auth
Expand Down Expand Up @@ -93,7 +93,8 @@ public async Task CreateCustomTokenWithoutServiceAccount()
Credential = GoogleCredential.FromAccessToken(token),
ServiceAccountId = serviceAcct.Id,
ProjectId = serviceAcct.ProjectId,
}, "IAMSignApp");
},
"IAMSignApp");

try
{
Expand Down Expand Up @@ -603,7 +604,7 @@ public async Task EmailVerificationLink()
user.Email, EmailLinkSettings);

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

var uri = new Uri(link);
var query = HttpUtility.ParseQueryString(uri.Query);
var query = QueryHelpers.ParseQuery(uri.Query);
Assert.Equal(ContinueUrl, query["continueUrl"]);

var request = new ResetPasswordRequest()
Expand Down Expand Up @@ -645,7 +646,7 @@ public async Task SignInWithEmailLink()
user.Email, EmailLinkSettings);

var uri = new Uri(link);
var query = HttpUtility.ParseQueryString(uri.Query);
var query = QueryHelpers.ParseQuery(uri.Query);
Assert.Equal(ContinueUrl, query["continueUrl"]);

var idToken = await AuthIntegrationUtils.SignInWithEmailLinkAsync(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisRuleSet>../../stylecop_test.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.1-beta.61">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FirebaseAdmin\FirebaseAdmin.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ internal static class IntegrationTestUtils
Credential = GoogleCredential.FromFile(ServiceAccountFile),
};
return FirebaseApp.Create(options);
}, true);
},
true);

public static FirebaseApp EnsureDefaultApp()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisRuleSet>../../stylecop_test.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Apis.Auth" Version="1.49.0" />
<PackageReference Include="Google.Apis.Auth" Version="1.67.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
<PackageReference Include=" System.Security.Cryptography.Xml" Version="8.0.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\FirebaseAdmin\FirebaseAdmin.csproj" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.1-beta.61">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAuthSnippets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FirebaseAdmin.Auth;
Expand Down Expand Up @@ -582,9 +583,10 @@ internal static async Task SetCustomUserClaimsIncrementalAsync()
object isAdmin;
if (user.CustomClaims.TryGetValue("admin", out isAdmin) && (bool)isAdmin)
{
var claims = new Dictionary<string, object>(user.CustomClaims);
var claims = user.CustomClaims.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
// Add level.
claims["level"] = 10;
var level = 10;
claims["level"] = level;
// Add custom claims for additional privileges.
await FirebaseAuth.DefaultInstance.SetCustomUserClaimsAsync(user.Uid, claims);
}
Expand Down
Loading