Skip to content

Commit c615e61

Browse files
authored
chore: Adding GitHub Actions release workflow (#146)
* chore: Adding GitHub Actions release workflow * Changed script to powershell * Fixed syntax error in ps script * Correctly reading env variables in ps1 script * Fixing custom claims integration tests to be order independent
1 parent 0b4c026 commit c615e61

File tree

5 files changed

+118
-3
lines changed

5 files changed

+118
-3
lines changed
1.69 KB
Binary file not shown.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2020 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
mkdir -p FirebaseAdmin/FirebaseAdmin.IntegrationTests/resources
16+
17+
gpg --quiet --batch --yes --decrypt --passphrase=$Env:FIREBASE_SERVICE_ACCT_KEY `
18+
--output FirebaseAdmin/FirebaseAdmin.IntegrationTests/resources/integration_cert.json `
19+
.github/resources/integ-service-account.json.gpg
20+
21+
echo $Env:FIREBASE_API_KEY > FirebaseAdmin/FirebaseAdmin.IntegrationTests/resources/integration_apikey.txt
22+
23+
dotnet test FirebaseAdmin/FirebaseAdmin.IntegrationTests

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Continuous Integration
22

3-
on: [push, pull_request]
3+
on: push
44

55
jobs:
66
build:

.github/workflows/release.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Copyright 2020 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Release Candidate
16+
17+
on:
18+
# Only run the workflow when a PR is updated or when a developer explicitly requests
19+
# a build by sending a 'firebase_build' event.
20+
pull_request:
21+
types: [opened, synchronize, closed]
22+
23+
repository_dispatch:
24+
types:
25+
- firebase_build
26+
27+
jobs:
28+
stage_release:
29+
# To publish a release, merge the release PR with the label 'release:publish'.
30+
# To stage a release without publishing it, send a 'firebase_build' event or apply
31+
# the 'release:stage' label to a PR.
32+
if: github.event.action == 'firebase_build' ||
33+
contains(github.event.pull_request.labels.*.name, 'release:stage') ||
34+
(github.event.pull_request.merged &&
35+
contains(github.event.pull_request.labels.*.name, 'release:publish'))
36+
37+
runs-on: windows-latest
38+
39+
env:
40+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
41+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
42+
43+
# When manually triggering the build, the requester can specify a target branch or a tag
44+
# via the 'ref' client parameter.
45+
steps:
46+
- name: Checkout source for staging
47+
uses: actions/checkout@v2
48+
with:
49+
ref: ${{ github.event.client_payload.ref || github.ref }}
50+
51+
- name: Build with dotnet
52+
run: dotnet build FirebaseAdmin/FirebaseAdmin
53+
54+
- name: Run unit tests
55+
run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests
56+
57+
- name: Run integration tests
58+
run: ./.github/scripts/run_integration_tests
59+
env:
60+
FIREBASE_SERVICE_ACCT_KEY: ${{ secrets.FIREBASE_SERVICE_ACCT_KEY }}
61+
FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
62+
63+
- name: Package release artifacts
64+
run: dotnet pack -c Release FirebaseAdmin/FirebaseAdmin
65+
66+
# Attach the packaged artifacts to the workflow output. These can be manually
67+
# downloaded for later inspection if necessary.
68+
- name: Archive artifacts
69+
uses: actions/upload-artifact@v1
70+
with:
71+
name: Release
72+
path: FirebaseAdmin/FirebaseAdmin/bin/Release

FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseAuthTest.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,40 @@ public async Task CreateCustomTokenWithoutServiceAccount()
9797
[Fact]
9898
public async Task SetCustomUserClaims()
9999
{
100+
var user = await FirebaseAuth.DefaultInstance.CreateUserAsync(new UserRecordArgs());
100101
var customClaims = new Dictionary<string, object>()
101102
{
102103
{ "admin", true },
103104
};
104105

105-
await FirebaseAuth.DefaultInstance.SetCustomUserClaimsAsync("testuser", customClaims);
106+
try
107+
{
108+
await FirebaseAuth.DefaultInstance.SetCustomUserClaimsAsync(user.Uid, customClaims);
109+
user = await FirebaseAuth.DefaultInstance.GetUserAsync(user.Uid);
110+
Assert.True((bool)user.CustomClaims["admin"]);
111+
}
112+
finally
113+
{
114+
await FirebaseAuth.DefaultInstance.DeleteUserAsync(user.Uid);
115+
}
106116
}
107117

108118
[Fact]
109119
public async Task SetCustomUserClaimsWithEmptyClaims()
110120
{
121+
var user = await FirebaseAuth.DefaultInstance.CreateUserAsync(new UserRecordArgs());
111122
var customClaims = new Dictionary<string, object>();
112123

113-
await FirebaseAuth.DefaultInstance.SetCustomUserClaimsAsync("testuser", customClaims);
124+
try
125+
{
126+
await FirebaseAuth.DefaultInstance.SetCustomUserClaimsAsync(user.Uid, customClaims);
127+
user = await FirebaseAuth.DefaultInstance.GetUserAsync(user.Uid);
128+
Assert.Empty(user.CustomClaims);
129+
}
130+
finally
131+
{
132+
await FirebaseAuth.DefaultInstance.DeleteUserAsync(user.Uid);
133+
}
114134
}
115135

116136
[Fact]

0 commit comments

Comments
 (0)