Skip to content
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
38 changes: 38 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI Tests

on:
- pull_request
- push

env:
CI: true

jobs:
unit:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 8.x
- 10.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

- name: "Set up Cloud credentials"
run: echo ${{ secrets.service_account_json_base64 }} | base64 -d > ./scripts/service-account.json

- name: "Lint and Test"
env:
FIREBASE_TOKEN: ${{ secrets.firebase_token }}
run: ./scripts/test.sh
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ We love contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.

## Build Status

[![Build Status](https://travis-ci.org/firebase/snippets-node.svg?branch=master)](https://travis-ci.org/firebase/snippets-node)
[![Actions Status][gh-actions-badge]][gh-actions]
[gh-actions]: https://github.com/firebase/snippets-node/actions
[gh-actions-badge]: https://github.com/firebase/snippets-node/workflows/CI%20Tests/badge.svg
7 changes: 2 additions & 5 deletions firestore/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1062,12 +1062,9 @@ function deleteQueryBatch(db, query, batchSize, resolve, reject) {
// ============================================================================

describe('Firestore Smoketests', () => {
let db;

before(() => {
admin.initializeApp();
db = admin.firestore();
});
admin.initializeApp();
const db = admin.firestore();

it('should get an empty document', () => {
return getDocumentEmpty(db);
Expand Down
13 changes: 13 additions & 0 deletions scripts/set-credentials.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

if [[ -z $CI ]]; then
echo "CI is unset, assuming local testing."
else
echo "CI=${CI}, setting GOOGLE_APPLICATION_CREDENTIALS"
export GOOGLE_APPLICATION_CREDENTIALS="${DIR}/service-account.json"
fi

echo "Application Default Credentials: ${GOOGLE_APPLICATION_CREDENTIALS}"
5 changes: 4 additions & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

# 0) Bootstrap
echo "Bootstrapping..."
npm run lerna-bootstrap
Expand All @@ -9,4 +11,5 @@ echo "Linting..."
npm run lint

# 2) Run tests in emulator
npx firebase --project="test-snippets-node" emulators:exec --only firestore "npm run lerna-test"
source ${DIR}/set-credentials.sh
npx firebase --project="firestore-snippets" emulators:exec --only firestore "npm run lerna-test"