Skip to content

Commit

Permalink
chore(): GitHub action revamp (#2701)
Browse files Browse the repository at this point in the history
* Github Actions for releases and more pure tests
* Randomize filenames in storage tests
* Test Node 10, 12, and 14
  • Loading branch information
jamesdaniels authored Dec 3, 2020
1 parent 37d1437 commit da8c660
Show file tree
Hide file tree
Showing 26 changed files with 175 additions and 114 deletions.
135 changes: 111 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,120 @@
name: Unit tests
name: Test and publish

on:
push:
branches:
- master
pull_request:
- "**"
paths-ignore:
- "**/*.md"
release:
types:
- published

jobs:
build:
runs-on: ubuntu-latest
name: Build
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
with:
node-version: '12'
check-latest: true
- name: yarn cache dir
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-
- name: yarn test
run: |
yarn install --frozen-lockfile --prefer-offline
yarn lint
yarn build
yarn test:all
- name: Checkout
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2-beta
with:
node-version: '14'
- name: Get cache directory
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Use yarn cache
uses: actions/cache@v2
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
~/.npm-packages-offline-cache
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-
- name: Install deps
run: |
yarn config set yarn-offline-mirror ~/.npm-packages-offline-cache
yarn config set yarn-offline-mirror-pruning true
yarn install --frozen-lockfile --prefer-offline
- name: Build
id: yarn-pack-dir
run: ./tools/build.sh
- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
with:
name: angularfire-${{ github.run_id }}
path: |
angularfire.tgz
publish.sh
unpack.sh
retention-days: 1
test:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
node: ["10", "12", "14"]
name: Test Node.js ${{ matrix.node }} (Ubuntu)
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v2-beta
with:
node-version: ${{ matrix.node }}
check-latest: true
- name: Get cache directory
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Use yarn cache
uses: actions/cache@v2
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
~/.npm-packages-offline-cache
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-
- name: Use Firebase emulator cache
uses: actions/cache@v2
with:
path: ~/.cache/firebase/emulators
key: firebase_emulators
- name: Install deps
run: |
yarn config set yarn-offline-mirror ~/.npm-packages-offline-cache
yarn config set yarn-offline-mirror-pruning true
yarn install --frozen-lockfile --prefer-offline
- name: 'Download Artifacts'
uses: actions/download-artifact@v2
- name: Expand Artifact
run: |
mkdir -p dist/packages-dist
chmod +x angularfire-${{ github.run_id }}/unpack.sh
./angularfire-${{ github.run_id }}/unpack.sh
- name: Run tests
run: yarn test:all
publish:
runs-on: ubuntu-latest
name: Publish (NPM)
needs: test
if: ${{ github.ref == 'refs/heads/master' || github.event_name == 'release' }}
steps:
- name: Setup node
uses: actions/setup-node@v2-beta
with:
node-version: '14'
registry-url: 'https://registry.npmjs.org'
- name: 'Download Artifacts'
uses: actions/download-artifact@v2
- name: Publish
run: |
cd ./angularfire-${{ github.run_id }}/
chmod +x publish.sh
./publish.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ tools/build.js
coverage
*.log
api-*.json
src/**/base.ts
src/**/base.ts
angularfire.tgz
unpack.sh
publish.sh
29 changes: 0 additions & 29 deletions cloudbuild.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion src/analytics/analytics.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestBed } from '@angular/core/testing';
import { AngularFireModule, FirebaseApp } from '@angular/fire';
import { AngularFireAnalytics, AngularFireAnalyticsModule } from './public_api';
import { AngularFireAnalytics, AngularFireAnalyticsModule } from '@angular/fire/analytics';
import { COMMON_CONFIG } from '../test-config';
import { rando } from '../firestore/utils.spec';

Expand Down
7 changes: 4 additions & 3 deletions src/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ export class AngularFireAnalytics {

const analytics = of(undefined).pipe(
observeOn(new ɵAngularFireSchedulers(zone).outsideAngular),
switchMap(() => import('firebase/analytics')),
switchMap(() => firebase.analytics.isSupported().then(it => it, () => false)),
switchMap(() => isPlatformBrowser(platformId) ? zone.runOutsideAngular(() => import('firebase/analytics')) : EMPTY),
// SEMVER can switch to isSupported() when we only target v8
// switchMap(() => firebase.analytics.isSupported().then(it => it, () => false)),
// TODO server-side investigate use of the Universal Analytics API
switchMap(supported => supported ? of(undefined) : EMPTY),
// switchMap(supported => supported ? of(undefined) : EMPTY),
map(() => {
return ɵfetchInstance(`analytics`, 'AngularFireAnalytics', app, () => {
const analytics = app.analytics();
Expand Down
2 changes: 1 addition & 1 deletion src/auth-guard/auth-guard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TestBed } from '@angular/core/testing';
import { AngularFireModule, FirebaseApp } from '@angular/fire';
import { COMMON_CONFIG } from '../test-config';
import { AngularFireAuthGuard, AngularFireAuthGuardModule } from './public_api';
import { AngularFireAuthGuard, AngularFireAuthGuardModule } from '@angular/fire/auth-guard';
import { Router, RouterModule } from '@angular/router';
import { APP_BASE_HREF } from '@angular/common';
import { rando } from '../firestore/utils.spec';
Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import firebase from 'firebase/app';
import { Observable, Subject } from 'rxjs';
import { TestBed } from '@angular/core/testing';
import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire';
import { AngularFireAuth, AngularFireAuthModule } from './public_api';
import { AngularFireAuth, AngularFireAuthModule } from '@angular/fire/auth';
import { COMMON_CONFIG } from '../test-config';
import 'firebase/auth';
import { rando } from '../firestore/utils.spec';
Expand Down
3 changes: 1 addition & 2 deletions src/core/angularfire2.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { TestBed } from '@angular/core/testing';
import { CompilerFactory, NgModule, NgZone, PlatformRef } from '@angular/core';
import { AngularFireModule, FirebaseApp } from './public_api';
import { AngularFireModule, FirebaseApp, ɵAngularFireSchedulers, ɵkeepUnstableUntilFirstFactory, ɵZoneScheduler } from '@angular/fire';
import { Observable, of, Subject } from 'rxjs';
import { COMMON_CONFIG } from '../test-config';
import { BrowserModule } from '@angular/platform-browser';
import firebase from 'firebase/app';
import { ɵAngularFireSchedulers, ɵkeepUnstableUntilFirstFactory, ɵZoneScheduler } from './angularfire2';
import { tap } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { rando } from '../firestore/utils.spec';
Expand Down
2 changes: 1 addition & 1 deletion src/database/database.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire';
import { AngularFireDatabase, AngularFireDatabaseModule, URL } from './public_api';
import { AngularFireDatabase, AngularFireDatabaseModule, URL } from '@angular/fire/database';
import { TestBed } from '@angular/core/testing';
import { COMMON_CONFIG } from '../test-config';
import { NgZone } from '@angular/core';
Expand Down
6 changes: 3 additions & 3 deletions src/database/list/audit-trail.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { DatabaseReference } from '../interfaces';
import { AngularFireModule, FirebaseApp } from '@angular/fire';
import { AngularFireDatabase, AngularFireDatabaseModule, auditTrail, ChildEvent, URL } from '../public_api';
import { AngularFireDatabase, AngularFireDatabaseModule, auditTrail, ChildEvent, URL } from '@angular/fire/database';
import { TestBed } from '@angular/core/testing';
import { COMMON_CONFIG } from '../../test-config';
import { skip } from 'rxjs/operators';
import 'firebase/database';
import firebase from 'firebase/app';
import { rando } from '../../firestore/utils.spec';

describe('auditTrail', () => {
let app: FirebaseApp;
let db: AngularFireDatabase;
let createRef: (path: string) => DatabaseReference;
let createRef: (path: string) => firebase.database.Reference;
let batch = {};
const items = [{ name: 'zero' }, { name: 'one' }, { name: 'two' }].map((item, i) => ({ key: i.toString(), ...item }));
Object.keys(items).forEach((key, i) => {
Expand Down
2 changes: 1 addition & 1 deletion src/database/list/snapshot-changes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import firebase from 'firebase/app';
import { AngularFireModule, FirebaseApp } from '@angular/fire';
import { AngularFireDatabase, AngularFireDatabaseModule, ChildEvent, snapshotChanges, URL } from '../public_api';
import { AngularFireDatabase, AngularFireDatabaseModule, ChildEvent, snapshotChanges, URL } from '@angular/fire/database';
import { TestBed } from '@angular/core/testing';
import { COMMON_CONFIG } from '../../test-config';
import { BehaviorSubject } from 'rxjs';
Expand Down
2 changes: 1 addition & 1 deletion src/database/list/state-changes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import firebase from 'firebase/app';
import { AngularFireModule, FirebaseApp } from '@angular/fire';
import { AngularFireDatabase, AngularFireDatabaseModule, ChildEvent, stateChanges, URL } from '../public_api';
import { AngularFireDatabase, AngularFireDatabaseModule, ChildEvent, stateChanges, URL } from '@angular/fire/database';
import { TestBed } from '@angular/core/testing';
import { COMMON_CONFIG } from '../../test-config';
import { skip } from 'rxjs/operators';
Expand Down
6 changes: 3 additions & 3 deletions src/database/observable/fromRef.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { DatabaseReference } from '../interfaces';
import { AngularFireModule, FirebaseApp, ɵZoneScheduler } from '@angular/fire';
import { AngularFireDatabase, AngularFireDatabaseModule, fromRef } from '../public_api';
import { AngularFireDatabase, AngularFireDatabaseModule, fromRef } from '@angular/fire/database';
import { TestBed } from '@angular/core/testing';
import { COMMON_CONFIG } from '../../test-config';
import { take } from 'rxjs/operators';
import { TestScheduler } from 'rxjs/testing';
import { rando } from '../../firestore/utils.spec';
import firebase from 'firebase/app';

describe('fromRef', () => {
let app: FirebaseApp;
let db: AngularFireDatabase;
let ref: (path: string) => DatabaseReference;
let ref: (path: string) => firebase.database.Reference;
let batch = {};
const items = [{ name: 'one' }, { name: 'two' }, { name: 'three' }].map(item => ({ key: rando(), ...item }));
Object.keys(items).forEach((key) => {
Expand Down
3 changes: 1 addition & 2 deletions src/firestore/collection-group/collection-group.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { AngularFireModule, FirebaseApp } from '@angular/fire';
import { AngularFirestore, AngularFirestoreCollectionGroup, AngularFirestoreModule, SETTINGS } from '../public_api';
import { QueryGroupFn, Query } from '../interfaces';
import { QueryGroupFn, Query , AngularFirestore, AngularFirestoreCollectionGroup, AngularFirestoreModule, SETTINGS } from '@angular/fire/firestore';
import { BehaviorSubject } from 'rxjs';
import { skip, switchMap, take } from 'rxjs/operators';
import { TestBed } from '@angular/core/testing';
Expand Down
5 changes: 1 addition & 4 deletions src/firestore/collection/collection.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { AngularFireModule, FirebaseApp } from '@angular/fire';
import { AngularFirestore, SETTINGS } from '../firestore';
import { AngularFirestoreModule } from '../firestore.module';
import { AngularFirestoreCollection } from './collection';
import { QueryFn, CollectionReference } from '../interfaces';
import { AngularFirestore, SETTINGS, AngularFirestoreModule, AngularFirestoreCollection, QueryFn, CollectionReference } from '@angular/fire/firestore';
import { BehaviorSubject } from 'rxjs';
import { skip, switchMap, take } from 'rxjs/operators';
import 'firebase/firestore';
Expand Down
6 changes: 1 addition & 5 deletions src/firestore/document/document.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { AngularFireModule, FirebaseApp } from '@angular/fire';
import { AngularFirestore, SETTINGS } from '../firestore';
import { AngularFirestoreModule } from '../firestore.module';
import { Subscription } from 'rxjs';
import { AngularFirestoreDocument } from './document';
import { DocumentReference } from '../interfaces';
import { AngularFirestore, SETTINGS, AngularFirestoreModule, AngularFirestoreDocument, DocumentReference } from '@angular/fire/firestore';
import { take } from 'rxjs/operators';

import { TestBed } from '@angular/core/testing';
Expand Down
5 changes: 1 addition & 4 deletions src/firestore/firestore.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire';
import { AngularFirestore, SETTINGS } from './firestore';
import { AngularFirestoreModule } from './firestore.module';
import { AngularFirestoreDocument } from './document/document';
import { AngularFirestoreCollection } from './collection/collection';
import { AngularFirestore, SETTINGS, AngularFirestoreModule, AngularFirestoreDocument, AngularFirestoreCollection } from '@angular/fire/firestore';

import { TestBed } from '@angular/core/testing';
import { COMMON_CONFIG } from '../test-config';
Expand Down
2 changes: 1 addition & 1 deletion src/firestore/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import firebase from 'firebase/app';
import { AngularFirestoreCollection } from './collection/collection';
import { AngularFirestoreCollection } from '@angular/fire/firestore';

export interface Stock {
name: string;
Expand Down
2 changes: 1 addition & 1 deletion src/functions/functions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestBed } from '@angular/core/testing';
import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire';
import { AngularFireFunctions, AngularFireFunctionsModule, ORIGIN, REGION } from './public_api';
import { AngularFireFunctions, AngularFireFunctionsModule, ORIGIN, REGION } from '@angular/fire/functions';
import { COMMON_CONFIG } from '../test-config';
import 'firebase/functions';
import { rando } from '../firestore/utils.spec';
Expand Down
2 changes: 1 addition & 1 deletion src/messaging/messaging.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestBed } from '@angular/core/testing';
import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire';
import { AngularFireMessaging, AngularFireMessagingModule } from './public_api';
import { AngularFireMessaging, AngularFireMessagingModule } from '@angular/fire/messaging';
import { COMMON_CONFIG } from '../test-config';
import { rando } from '../firestore/utils.spec';

Expand Down
2 changes: 1 addition & 1 deletion src/performance/performance.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestBed } from '@angular/core/testing';
import { AngularFireModule, FirebaseApp } from '@angular/fire';
import { AngularFirePerformance, AngularFirePerformanceModule } from './public_api';
import { AngularFirePerformance, AngularFirePerformanceModule } from '@angular/fire/performance';
import { COMMON_CONFIG } from '../test-config';
import { rando } from '../firestore/utils.spec';

Expand Down
2 changes: 1 addition & 1 deletion src/remote-config/remote-config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestBed } from '@angular/core/testing';
import { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire';
import { AngularFireRemoteConfig, AngularFireRemoteConfigModule, DEFAULTS, SETTINGS } from './public_api';
import { AngularFireRemoteConfig, AngularFireRemoteConfigModule, DEFAULTS, SETTINGS } from '@angular/fire/remote-config';
import { COMMON_CONFIG } from '../test-config';
import { rando } from '../firestore/utils.spec';

Expand Down
Loading

0 comments on commit da8c660

Please sign in to comment.