Skip to content

Commit dc21061

Browse files
authored
Convert to a mono repo to later support Angular test alongside Next.js tests (#25)
Work to build out the repository in preparation of a new Angular nightly test suite. Changes include: - Convert the repository into a monorepo. - Moved the Next.js test from the root directory to the `js-sdk-framework-tests/nextjs` directory. - Add a stub for an Angular nightly test in the `js-sdk-framework-tests/angular` directory. - This Angular project doesn't do anything yet but proves that lerna can be used to execute the Angular tests and the Next.js tests via distinct instructions. - Created two new workflows. 1. executes the Next.js test nightly (as was previously done) using the new `lerna` commands. 2. execute the Angular stubs, though no tests execute, yet. - Removed the previous workflow that executed Next.js tests. **Testing** - Tested locally with the package.json targets to initialize, setup, build, and run the tests. - Since new workflows need to be in main before they can be executed, I copied the contents of the new workflows into the older workflow to run each of them once on the branch, just to ensure that they're formatted properly and executed properly.
1 parent 215f3dc commit dc21061

File tree

103 files changed

+12123
-576
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+12123
-576
lines changed

.github/lerna.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"version": "independent",
3+
"npmClient": "yarn",
4+
"useWorkspaces": true,
5+
"packages": [
6+
"packages/*"
7+
]
8+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Copyright 2024 Google LLC
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: Firebase JS SDK Nightly Angular
16+
17+
on:
18+
schedule:
19+
- cron: "0 0 * * *" # Nightly
20+
pull_request:
21+
branches:
22+
- main
23+
paths: # Only run if files in these paths change
24+
- 'js-sdk-framework-tests/angular/**'
25+
- '.github/workflows/js-sdk-nightly-angular.yaml'
26+
- 'package.json' # Root package.json
27+
- 'lerna.json'
28+
- 'yarn.lock'
29+
workflow_dispatch:
30+
31+
permissions: read-all
32+
33+
jobs:
34+
anuglar-tests:
35+
name: Angular tests
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- name: Checkout Repo
40+
uses: actions/checkout@v4
41+
42+
- name: Set up Node (20)
43+
uses: actions/setup-node@v4
44+
with:
45+
node-version: 20.x
46+
cache: 'yarn'
47+
cache-dependency-path: yarn.lock # Root yarn.lock
48+
49+
- name: Install Monorepo Dependencies
50+
run: yarn install
51+
52+
- name: Setup Angular App
53+
run: yarn setup:angular
54+
55+
- name: Build Angular App
56+
run: yarn build:angular
57+
58+
- name: Run Angular tests
59+
run: yarn test:angular
60+
61+
- name: Send email on failure
62+
if: failure() && github.event_name == 'schedule' # Only send email for scheduled nightly runs
63+
uses: ./.github/actions/send-email
64+
with:
65+
api-key: ${{ secrets.OSS_BOT_MAILGUN_KEY }}
66+
domain: ${{ secrets.OSS_BOT_MAILGUN_DOMAIN }}
67+
from: 'GitHub <admin-github@${{ secrets.OSS_BOT_MAILGUN_DOMAIN }}>'
68+
to: ${{ secrets.FIREBASE_NEXTJS_TESTS_GITHUB_EMAILS }}
69+
subject: 'Nightly build of ${{github.repository}} failed!'
70+
html: >
71+
<b>The nightly workflow to test the Firebase JS SDK with Angular failed on: ${{github.repository}}</b>
72+
<br /><br />Navigate to the
73+
<a href="https://github.com/FirebaseExtended/firebase-sdk-nextjs-tests/actions/runs/${{github.run_id}}">failed workflow</a>
74+
to look further into what went wrong.
75+
continue-on-error: true

.github/workflows/nightly-js-sdk.yaml renamed to .github/workflows/js-sdk-nightly-next-js.yaml

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -12,65 +12,68 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: Firebase JS SDK Nightly
15+
name: Firebase JS SDK Nightly Next.js
1616

1717
on:
1818
schedule:
19-
- cron: "0 0 * * *"
19+
- cron: "0 0 * * *" # Nightly
2020
pull_request:
2121
branches:
2222
- main
23+
paths: # Only run if files in these paths change
24+
- 'js-sdk-framework-tests/nextjs/**'
25+
- '.github/workflows/js-sdk-nightly-next-js.yaml'
26+
- 'package.json' # Root package.json
27+
- 'lerna.json'
28+
- 'yarn.lock'
2329
workflow_dispatch:
2430

31+
permissions: read-all
32+
2533
jobs:
26-
run:
27-
name: Execute JS SDK Playwright tests
34+
nextjs-tests:
35+
name: Next.js Tests
2836
runs-on: ubuntu-latest
37+
2938
steps:
3039
- name: Checkout Repo
3140
uses: actions/checkout@v4
41+
3242
- name: Set up Node (20)
3343
uses: actions/setup-node@v4
3444
with:
3545
node-version: 20.x
36-
cache: 'npm'
37-
cache-dependency-path: yarn.lock
38-
- name: Restore cached node_modules
39-
uses: actions/cache@v4
40-
id: node_modules
41-
with:
42-
path: "./node_modules"
43-
key: node_modules-${{ runner.arch }}-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
44-
- name: Write Project Config
46+
cache: 'yarn'
47+
cache-dependency-path: yarn.lock # Root yarn.lock
48+
49+
- name: Install Monorepo Dependencies
50+
run: yarn install
51+
working-directory: ./ # Run yarn install from the root
52+
53+
- name: Write Project Config for Next.js
4554
env:
4655
PROJECT_CONFIG: ${{ secrets.PROJECT_CONFIG }}
4756
run: echo "export const firebaseConfig = $PROJECT_CONFIG;" > src/lib/app_tests/firebase.ts
48-
- name: Yarn install
49-
run: yarn
50-
- name: Restore yarn build cache
51-
uses: actions/cache@v4
52-
with:
53-
path: |
54-
~/.npm
55-
${{ github.workspace }}/.next/cache
56-
# Generate a new cache whenever packages or source files change.
57-
key: ${{ runner.os }}-nextjs-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
58-
# If source files changed but packages didn't, rebuild from a prior cache.
59-
restore-keys: |
60-
${{ runner.os }}-nextjs-${{ hashFiles('yarn.lock') }}-
61-
- name: Yarn build
62-
run: yarn build
57+
working-directory: ./js-sdk-framework-tests/nextjs
58+
6359
- name: Restore cached playwright browsers
6460
uses: actions/cache@v4
65-
with:
61+
with:
6662
path: ~/.cache/ms-playwright
67-
key: playwright-${{ hashFiles('playwright.config.ts') }}
68-
- name: Install Playwright browsers
69-
run: yarn playwright install --with-deps
70-
- name: Launch E2E tests workflow
71-
run: yarn test
63+
# Key uses the playwright.config.ts from the nextjs package
64+
key: playwright-browsers-${{ hashFiles('js-sdk-framework-tests/nextjs/playwright.config.ts') }}
65+
66+
- name: Setup Next.js App (Playwright browsers)
67+
run: yarn setup:nextjs
68+
69+
- name: Build Next.js App
70+
run: yarn build:nextjs
71+
72+
- name: Run Next.js tests
73+
run: yarn test:nextjs
74+
7275
- name: Send email on failure
73-
if: failure()
76+
if: failure() && github.event_name == 'schedule' # Only send email for scheduled nightly runs
7477
uses: ./.github/actions/send-email
7578
with:
7679
api-key: ${{ secrets.OSS_BOT_MAILGUN_KEY }}
@@ -79,7 +82,7 @@ jobs:
7982
to: ${{ secrets.FIREBASE_NEXTJS_TESTS_GITHUB_EMAILS }}
8083
subject: 'Nightly build of ${{github.repository}} failed!'
8184
html: >
82-
<b>The nightly workflow to test the Firebase JS SDK failed on: ${{github.repository}}</b>
85+
<b>The nightly workflow to test the Firebase JS SDK with Next.js failed on: ${{github.repository}}</b>
8386
<br /><br />Navigate to the
8487
<a href="https://github.com/FirebaseExtended/firebase-sdk-nextjs-tests/actions/runs/${{github.run_id}}">failed workflow</a>
8588
to look further into what went wrong.

README.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
# Firebase SDK Next JS Tests
2-
![Status Badge](https://github.com/FirebaseExtended/firebase-sdk-nextjs-tests/actions/workflows/nightly-js-sdk.yaml/badge.svg)
1+
# Firebase JS SDK Framework Tests
2+
![JS SDK Next.js Tests Status Badge](https://github.com/FirebaseExtended/firebase-sdk-nextjs-tests/actions/workflows/js-sdk-nightly-next-js.yaml/badge.svg)
33

4-
This repository contains automatic nightly tests that exercise the Firebase JS SDK within a Next.JS app environment via the Playwright test framework.
4+
![JS SDK Angular Tests Status Badge](https://github.com/FirebaseExtended/firebase-sdk-nextjs-tests/actions/workflows/js-sdk-nightly-angular.yaml/badge.svg)
5+
6+
This repository uses Playwright to execute Firebase JS SDK tests witin both Next.js and Angular environments. The repository is meant to run nightly against the latest upcoming Firebase JS SDK.
7+
8+
9+
## Note
10+
Angular tests are a work in progress and are not available at this time.
511

612
## Getting Started
713

@@ -11,37 +17,30 @@ This project has be built and tested with `yarn` version `1.22.11`.
1117
First, install dependencies:
1218

1319
```bash
14-
yarn
20+
yarn install
1521
```
1622

1723
### Firebase Project configuration
18-
To configure your Firebase project data, add your project configuration to `./lib/firebase.ts`.
24+
To configure your Firebase project data, add your project configuration to `js-sdk-framework-tests/nextjs/lib/firebase.ts`. Angular tests are coming soon.
1925

2026

2127
### Building and executing the tests:
2228

2329
```bash
24-
yarn build
30+
yarn setup:nextjs
2531
```
2632

27-
To execute all of the tests, run:
28-
2933
```bash
30-
yarn test
34+
yarn build:nextjs
3135
```
3236

33-
To exeucte a single test, define the playwright test spec as a command line parameter. For instance,
34-
to execute only the Auth tests:
37+
To execute all of the tests, run:
3538

3639
```bash
37-
yarn test tests/auth.spec.ts
40+
yarn test:nextjs
3841
```
3942

40-
To run the tests on an app server for manual testing:
41-
42-
```bash
43-
yarn dev
44-
```
43+
More information about running Next.js and Angular tests specifically can be found in the `README.md`s files in `js-sdk-framework-tests/nextjs` and `js-sdk-framework-tests/angular`, respectively.
4544

4645

4746

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# dependencies
2+
node_modules
3+
.pnp
4+
.pnp.js
5+
6+
# NPM Lockfiles
7+
package-lock.json
8+
9+
#angular
10+
dist
11+
.angular
12+
13+
# production
14+
/build
15+
16+
# misc
17+
.DS_Store
18+
*.pem
19+
20+
# debug
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
.pnpm-debug.log*
25+
26+
# local env files
27+
.env*.local
28+
29+
# typescript
30+
*.tsbuildinfo
31+
next-env.d.ts
32+
/test-results/
33+
/playwright-report/
34+
/playwright/.cache/
35+
36+
# Logs
37+
logs
38+
*.log
39+
npm-debug.log*
40+
yarn-debug.log*
41+
yarn-error.log*
42+
43+
# Yarn Integrity file
44+
.yarn-integrity
45+
46+
# dotenv environment variables file
47+
.env
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# MyNewApp
2+
3+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.1.1.
4+
5+
## Development server
6+
7+
To start a local development server, run:
8+
9+
```bash
10+
ng serve
11+
```
12+
13+
Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
14+
15+
## Code scaffolding
16+
17+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
18+
19+
```bash
20+
ng generate component component-name
21+
```
22+
23+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
24+
25+
```bash
26+
ng generate --help
27+
```
28+
29+
## Building
30+
31+
To build the project run:
32+
33+
```bash
34+
ng build
35+
```
36+
37+
This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
38+
39+
## Running unit tests
40+
41+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
42+
43+
```bash
44+
ng test
45+
```
46+
47+
## Running end-to-end tests
48+
49+
For end-to-end (e2e) testing, run:
50+
51+
```bash
52+
ng e2e
53+
```
54+
55+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
56+
57+
## Additional Resources
58+
59+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.

0 commit comments

Comments
 (0)