Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: firebase/firebase-functions
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.11.0
Choose a base ref
...
head repository: firebase/firebase-functions
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.12.0
Choose a head ref
  • 8 commits
  • 20 files changed
  • 6 contributors

Commits on Aug 21, 2020

  1. Copy the full SHA
    85af5e1 View commit details

Commits on Sep 14, 2020

  1. Update tests to change region based on env variable FIREBASE_FUNCTION…

    …S_TEST_REGION (#780)
    
    * update tests to change region based on environment variable FIREBASE_FUNCTIONS_TEST_REGION
    
    * formats
    joehan authored Sep 14, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7e2c0ec View commit details

Commits on Nov 2, 2020

  1. Adding required tags to page template. (#804)

    * Adding required tags to page template.
    
    * Adding formatting and fixing typo discovered in internal review.
    
    * More fixes/additions discovered in internal review.
    
    * Fixing format of toc.yaml file.
    egilmorez authored Nov 2, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f59ff8c View commit details

Commits on Nov 18, 2020

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2988a2b View commit details

Commits on Nov 25, 2020

  1. Add ingress settings support (#815)

    * Add IngressSettings support
    
    * Add IngressSettings support
    
    * Format
    
    Co-authored-by: Marcel Goya <marcel@lingu.social>
    Co-authored-by: joehan <joehanley@google.com>
    3 people authored Nov 25, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ecfefd1 View commit details

Commits on Nov 30, 2020

  1. introduce package-lock.json (#781)

    * initial package-lock
    
    * remove npmrc
    
    * update package-lock
    
    * update typedoc
    
    * remove istanbul; audit fixes
    
    Co-authored-by: joehan <joehanley@google.com>
    bkendall and joehan authored Nov 30, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c11e5b3 View commit details
  2. Switches to Github Actions from travis, and adds CHANGELOG (#818)

    * Switches to Github Actions over travis, and adds CHNAGELOG entries for recent PRs
    
    * formats
    joehan authored Nov 30, 2020

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    93047d5 View commit details
  3. 3.12.0

    google-oss-bot committed Nov 30, 2020
    Copy the full SHA
    3932876 View commit details
35 changes: 35 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI Tests

on:
- pull_request
- push

env:
CI: true

jobs:
unit:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 8.x
- 10.x
- 12.x
- 14.x
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Cache npm
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}

- run: npm install
- run: npm run lint
- run: npm run format
- run: npm run test
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Adds support for `vpcConnector` and `vpcConnectorEgressSettings` fields in `functions.runWith()`. **Must be used in conjunction with firebase-tools v8.9.0 or higher.** Thanks @pcboy! (#752)
- Adds `4GB` as a `memory` option for `runWith()`.
- Adds support for choosing `ingressSettings` via `runWith()`.
25 changes: 20 additions & 5 deletions docgen/content-sources/toc.yaml
Original file line number Diff line number Diff line change
@@ -23,6 +23,20 @@ toc:
- title: 'config.Config'
path: /docs/reference/functions/config_.config.config.html

- title: 'functions.function-configuration'
path: /docs/reference/functions/function_configuration_.html
section:
- title: 'config.DeploymentOptions'
path: /docs/reference/functions/function_configuration_.deploymentoptions.html
- title: 'config.FailurePolicy'
path: /docs/reference/functions/function_configuration_.failurepolicy.html
- title: 'config.RuntimeOptions'
path: /docs/reference/functions/function_configuration_.runtimeoptions.html
- title: 'config.Schedule'
path: /docs/reference/functions/function_configuration_.schedule.html
- title: 'config.ScheduleRetryConfig'
path: /docs/reference/functions/function_configuration_.scheduleretryconfig.html

- title: 'functions.analytics'
path: /docs/reference/functions/providers_analytics_.html
section:
@@ -127,11 +141,6 @@ toc:
- title: 'ObjectMetadata'
path: /docs/reference/functions/providers_storage_.objectmetadata.html

- title: 'functions.handler'
path: /docs/reference/functions/handler_builder_.html
section:
- title: 'HandlerBuilder'
path: /docs/reference/functions/handler_builder_.handlerbuilder.html
- title: 'functions.testLab'
path: /docs/reference/functions/providers_testlab_.html
section:
@@ -143,3 +152,9 @@ toc:
path: /docs/reference/functions/providers_testlab_.testmatrix.html
- title: 'testLab.testMatrixBuilder'
path: /docs/reference/functions/providers_testlab_.testmatrixbuilder.html

- title: 'functions.handler'
path: /docs/reference/functions/handler_builder_.html
section:
- title: 'HandlerBuilder'
path: /docs/reference/functions/handler_builder_.handlerbuilder.html
2 changes: 2 additions & 0 deletions docgen/theme/layouts/default.hbs
Original file line number Diff line number Diff line change
@@ -7,6 +7,8 @@
<meta name="project_path" value="/_project.yaml" />
<meta name="book_path" value="/docs/reference/_book.yaml" />
<meta name="gtm_var" data-key="docType" data-value="reference">
<meta name="page_type" value="reference" />
<meta name="translation" value="disabled" />
<title>{{#ifCond model.name '==' project.name}}{{project.name}}{{else}}{{model.name}} | {{project.name}}{{/ifCond}}</title>
<meta name="description" content="Reference for {{model.name}}">
<meta name="viewport" content="width=device-width, initial-scale=1">
108 changes: 61 additions & 47 deletions integration_test/functions/src/auth-tests.ts
Original file line number Diff line number Diff line change
@@ -3,68 +3,82 @@ import * as functions from 'firebase-functions';
import { expectEq, TestSuite } from './testing';
import UserMetadata = admin.auth.UserRecord;

export const createUserTests: any = functions.auth.user().onCreate((u, c) => {
const testId: string = u.displayName;
console.log(`testId is ${testId}`);
const REGION = process.env.FIREBASE_FUNCTIONS_TEST_REGION || 'us-central1';

return new TestSuite<UserMetadata>('auth user onCreate')
.it('should have a project as resource', (user, context) =>
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`)
)
export const createUserTests: any = functions
.region(REGION)
.auth.user()
.onCreate((u, c) => {
const testId: string = u.displayName;
console.log(`testId is ${testId}`);

.it('should not have a path', (user, context) =>
expectEq((context as any).path, undefined)
)
return new TestSuite<UserMetadata>('auth user onCreate')
.it('should have a project as resource', (user, context) =>
expectEq(
context.resource.name,
`projects/${process.env.GCLOUD_PROJECT}`
)
)

.it('should have the correct eventType', (user, context) =>
expectEq(context.eventType, 'google.firebase.auth.user.create')
)
.it('should not have a path', (user, context) =>
expectEq((context as any).path, undefined)
)

.it('should have an eventId', (user, context) => context.eventId)
.it('should have the correct eventType', (user, context) =>
expectEq(context.eventType, 'google.firebase.auth.user.create')
)

.it('should have a timestamp', (user, context) => context.timestamp)
.it('should have an eventId', (user, context) => context.eventId)

.it('should not have auth', (user, context) =>
expectEq((context as any).auth, undefined)
)
.it('should have a timestamp', (user, context) => context.timestamp)

.it('should not have action', (user, context) =>
expectEq((context as any).action, undefined)
)
.it('should not have auth', (user, context) =>
expectEq((context as any).auth, undefined)
)

.it('should have properly defined meta', (user, context) => user.metadata)
.it('should not have action', (user, context) =>
expectEq((context as any).action, undefined)
)

.run(testId, u, c);
});
.it('should have properly defined meta', (user, context) => user.metadata)

export const deleteUserTests: any = functions.auth.user().onDelete((u, c) => {
const testId: string = u.displayName;
console.log(`testId is ${testId}`);
.run(testId, u, c);
});

return new TestSuite<UserMetadata>('auth user onDelete')
.it('should have a project as resource', (user, context) =>
expectEq(context.resource.name, `projects/${process.env.GCLOUD_PROJECT}`)
)
export const deleteUserTests: any = functions
.region(REGION)
.auth.user()
.onDelete((u, c) => {
const testId: string = u.displayName;
console.log(`testId is ${testId}`);

.it('should not have a path', (user, context) =>
expectEq((context as any).path, undefined)
)
return new TestSuite<UserMetadata>('auth user onDelete')
.it('should have a project as resource', (user, context) =>
expectEq(
context.resource.name,
`projects/${process.env.GCLOUD_PROJECT}`
)
)

.it('should have the correct eventType', (user, context) =>
expectEq(context.eventType, 'google.firebase.auth.user.delete')
)
.it('should not have a path', (user, context) =>
expectEq((context as any).path, undefined)
)

.it('should have an eventId', (user, context) => context.eventId)
.it('should have the correct eventType', (user, context) =>
expectEq(context.eventType, 'google.firebase.auth.user.delete')
)

.it('should have a timestamp', (user, context) => context.timestamp)
.it('should have an eventId', (user, context) => context.eventId)

.it('should not have auth', (user, context) =>
expectEq((context as any).auth, undefined)
)
.it('should have a timestamp', (user, context) => context.timestamp)

.it('should not have action', (user, context) =>
expectEq((context as any).action, undefined)
)
.it('should not have auth', (user, context) =>
expectEq((context as any).auth, undefined)
)

.run(testId, u, c);
});
.it('should not have action', (user, context) =>
expectEq((context as any).action, undefined)
)

.run(testId, u, c);
});
6 changes: 4 additions & 2 deletions integration_test/functions/src/database-tests.ts
Original file line number Diff line number Diff line change
@@ -4,9 +4,11 @@ import { expectEq, expectMatches, TestSuite } from './testing';
import DataSnapshot = admin.database.DataSnapshot;

const testIdFieldName = 'testId';
const REGION = process.env.FIREBASE_FUNCTIONS_TEST_REGION || 'us-central1';

export const databaseTests: any = functions.database
.ref('dbTests/{testId}/start')
export const databaseTests: any = functions
.region(REGION)
.database.ref('dbTests/{testId}/start')
.onWrite((ch, ctx) => {
if (ch.after.val() === null) {
console.log(
2 changes: 2 additions & 0 deletions integration_test/functions/src/firestore-tests.ts
Original file line number Diff line number Diff line change
@@ -4,11 +4,13 @@ import { expectDeepEq, expectEq, TestSuite } from './testing';
import DocumentSnapshot = admin.firestore.DocumentSnapshot;

const testIdFieldName = 'documentId';
const REGION = process.env.FIREBASE_FUNCTIONS_TEST_REGION || 'us-central1';

export const firestoreTests: any = functions
.runWith({
timeoutSeconds: 540,
})
.region(REGION)
.firestore.document('tests/{documentId}')
.onCreate((s, c) => {
return new TestSuite<DocumentSnapshot>('firestore document onWrite')
4 changes: 3 additions & 1 deletion integration_test/functions/src/https-tests.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,9 @@ import * as functions from 'firebase-functions';
import * as _ from 'lodash';
import { expectEq, TestSuite } from './testing';

export const callableTests: any = functions.https.onCall((d) => {
const REGION = process.env.FIREBASE_FUNCTIONS_TEST_REGION || 'us-central1';

export const callableTests: any = functions.region(REGION).https.onCall((d) => {
return new TestSuite('https onCall')
.it('should have the correct data', (data) =>
expectEq(_.get(data, 'foo'), 'bar')
4 changes: 3 additions & 1 deletion integration_test/functions/src/index.ts
Original file line number Diff line number Diff line change
@@ -20,13 +20,14 @@ import * as testLab from './testLab-utils';
import 'firebase-functions'; // temporary shim until process.env.FIREBASE_CONFIG available natively in GCF(BUG 63586213)
const firebaseConfig = JSON.parse(process.env.FIREBASE_CONFIG);
admin.initializeApp();
const REGION = functions.config().functions.test_region;

// TODO(klimt): Get rid of this once the JS client SDK supports callable triggers.
function callHttpsTrigger(name: string, data: any, baseUrl) {
return utils.makeRequest(
{
method: 'POST',
host: 'us-central1-' + firebaseConfig.projectId + '.' + baseUrl,
host: REGION + '-' + firebaseConfig.projectId + '.' + baseUrl,
path: '/' + name,
headers: {
'Content-Type': 'application/json',
@@ -62,6 +63,7 @@ function callScheduleTrigger(functionName: string, region: string) {
}

export const integrationTests: any = functions
.region(REGION)
.runWith({
timeoutSeconds: 540,
})
12 changes: 8 additions & 4 deletions integration_test/functions/src/pubsub-tests.ts
Original file line number Diff line number Diff line change
@@ -3,10 +3,13 @@ import * as functions from 'firebase-functions';
import { evaluate, expectEq, success, TestSuite } from './testing';
import PubsubMessage = functions.pubsub.Message;

const REGION = process.env.FIREBASE_FUNCTIONS_TEST_REGION || 'us-central1';

// TODO(inlined) use multiple queues to run inline.
// Expected message data: {"hello": "world"}
export const pubsubTests: any = functions.pubsub
.topic('pubsubTests')
export const pubsubTests: any = functions
.region(REGION)
.pubsub.topic('pubsubTests')
.onPublish((m, c) => {
let testId: string;
try {
@@ -59,8 +62,9 @@ export const pubsubTests: any = functions.pubsub
.run(testId, m, c);
});

export const schedule: any = functions.pubsub
.schedule('every 10 hours') // This is a dummy schedule, since we need to put a valid one in.
export const schedule: any = functions
.region(REGION)
.pubsub.schedule('every 10 hours') // This is a dummy schedule, since we need to put a valid one in.
// For the test, the job is triggered by the jobs:run api
.onRun((context) => {
let testId;
10 changes: 6 additions & 4 deletions integration_test/functions/src/remoteConfig-tests.ts
Original file line number Diff line number Diff line change
@@ -2,8 +2,11 @@ import * as functions from 'firebase-functions';
import { expectEq, TestSuite } from './testing';
import TemplateVersion = functions.remoteConfig.TemplateVersion;

export const remoteConfigTests: any = functions.remoteConfig.onUpdate(
(v, c) => {
const REGION = process.env.FIREBASE_FUNCTIONS_TEST_REGION || 'us-central1';

export const remoteConfigTests: any = functions
.region(REGION)
.remoteConfig.onUpdate((v, c) => {
return new TestSuite<TemplateVersion>('remoteConfig onUpdate')
.it('should have a project as resource', (version, context) =>
expectEq(
@@ -25,5 +28,4 @@ export const remoteConfigTests: any = functions.remoteConfig.onUpdate(
)

.run(v.description, v, c);
}
);
});
3 changes: 3 additions & 0 deletions integration_test/functions/src/storage-tests.ts
Original file line number Diff line number Diff line change
@@ -2,10 +2,13 @@ import * as functions from 'firebase-functions';
import { expectEq, TestSuite } from './testing';
import ObjectMetadata = functions.storage.ObjectMetadata;

const REGION = process.env.FIREBASE_FUNCTIONS_TEST_REGION || 'us-central1';

export const storageTests: any = functions
.runWith({
timeoutSeconds: 540,
})
.region(REGION)
.storage.bucket()
.object()
.onFinalize((s, c) => {
2 changes: 2 additions & 0 deletions integration_test/functions/src/testLab-tests.ts
Original file line number Diff line number Diff line change
@@ -2,11 +2,13 @@ import * as functions from 'firebase-functions';
import * as _ from 'lodash';
import { TestSuite, expectEq } from './testing';
import TestMatrix = functions.testLab.TestMatrix;
const REGION = process.env.FIREBASE_FUNCTIONS_TEST_REGION || 'us-central1';

export const testLabTests: any = functions
.runWith({
timeoutSeconds: 540,
})
.region(REGION)
.testLab.testMatrix()
.onComplete((matrix, context) => {
return new TestSuite<TestMatrix>('test matrix complete')
Loading