Skip to content

Commit d7406c8

Browse files
authored
Move to GitHub Actions (#88)
1 parent e58de8e commit d7406c8

File tree

6 files changed

+60
-14
lines changed

6 files changed

+60
-14
lines changed

.github/workflows/node.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI Tests
2+
3+
on:
4+
- pull_request
5+
- push
6+
7+
env:
8+
CI: true
9+
10+
jobs:
11+
unit:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
node-version:
16+
- 8.x
17+
- 10.x
18+
steps:
19+
- uses: actions/checkout@v1
20+
- uses: actions/setup-node@v1
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
24+
- name: Cache npm
25+
uses: actions/cache@v1
26+
with:
27+
path: ~/.npm
28+
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
29+
30+
- run: npm install
31+
32+
- name: "Set up Cloud credentials"
33+
run: echo ${{ secrets.service_account_json_base64 }} | base64 -d > ./scripts/service-account.json
34+
35+
- name: "Lint and Test"
36+
env:
37+
FIREBASE_TOKEN: ${{ secrets.firebase_token }}
38+
run: ./scripts/test.sh

.travis.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ We love contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
99

1010
## Build Status
1111

12-
[![Build Status](https://travis-ci.org/firebase/snippets-node.svg?branch=master)](https://travis-ci.org/firebase/snippets-node)
12+
[![Actions Status][gh-actions-badge]][gh-actions]
13+
[gh-actions]: https://github.com/firebase/snippets-node/actions
14+
[gh-actions-badge]: https://github.com/firebase/snippets-node/workflows/CI%20Tests/badge.svg

firestore/main/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,12 +1062,9 @@ function deleteQueryBatch(db, query, resolve, reject) {
10621062
// ============================================================================
10631063

10641064
describe('Firestore Smoketests', () => {
1065-
let db;
10661065

1067-
before(() => {
1068-
admin.initializeApp();
1069-
db = admin.firestore();
1070-
});
1066+
admin.initializeApp();
1067+
const db = admin.firestore();
10711068

10721069
it('should get an empty document', () => {
10731070
return getDocumentEmpty(db);

scripts/set-credentials.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
5+
6+
if [[ -z $CI ]]; then
7+
echo "CI is unset, assuming local testing."
8+
else
9+
echo "CI=${CI}, setting GOOGLE_APPLICATION_CREDENTIALS"
10+
export GOOGLE_APPLICATION_CREDENTIALS="${DIR}/service-account.json"
11+
fi
12+
13+
echo "Application Default Credentials: ${GOOGLE_APPLICATION_CREDENTIALS}"

scripts/test.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
set -e
22

3+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
4+
35
# 0) Bootstrap
46
echo "Bootstrapping..."
57
npm run lerna-bootstrap
@@ -9,4 +11,5 @@ echo "Linting..."
911
npm run lint
1012

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

0 commit comments

Comments
 (0)