Skip to content

Commit 8358b1f

Browse files
authored
chore: updated licensing
1 parent 691662a commit 8358b1f

File tree

210 files changed

+3176
-282
lines changed

Some content is hidden

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

210 files changed

+3176
-282
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,37 @@ on:
2222
default: 'stable'
2323

2424
jobs:
25+
# Check license headers on all source files
26+
check-license-header:
27+
name: Check License Headers
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 5
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
- name: Download addlicense
35+
run: |
36+
curl -sL https://github.com/google/addlicense/releases/download/v1.2.0/addlicense_v1.2.0_Linux_x86_64.tar.gz | tar xz -C /usr/local/bin addlicense
37+
chmod +x /usr/local/bin/addlicense
38+
39+
- name: Check license headers
40+
run: |
41+
addlicense -f header_template.txt \
42+
--check \
43+
--ignore "**/*.yml" \
44+
--ignore "**/*.yaml" \
45+
--ignore "**/*.xml" \
46+
--ignore "**/*.g.dart" \
47+
--ignore "**/*.sh" \
48+
--ignore "**/*.html" \
49+
--ignore "**/*.js" \
50+
--ignore "**/*.ts" \
51+
--ignore "**/*.txt" \
52+
--ignore "**/.dart_tool/**" \
53+
--ignore "LICENSE" \
54+
.
55+
2556
lint:
2657
name: Lint (Dart ${{ matrix.dart-version }})
2758
runs-on: ubuntu-latest
@@ -353,10 +384,11 @@ jobs:
353384
build:
354385
name: Build verification (Dart ${{ matrix.dart-version }})
355386
runs-on: ubuntu-latest
356-
needs: [lint, test, test-wif]
357-
# Run even if test-wif was skipped (fork PRs), but not if lint or test failed
387+
needs: [check-license-header, lint, test, test-wif]
388+
# Run even if test-wif was skipped (fork PRs), but not if other jobs failed
358389
if: |
359390
always() &&
391+
needs.check-license-header.result == 'success' &&
360392
needs.lint.result == 'success' &&
361393
needs.test.result == 'success' &&
362394
(needs.test-wif.result == 'success' || needs.test-wif.result == 'skipped')

CONTRIBUTING.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

CONTRIBUTING.md

Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
# Contributing to Firebase Admin SDK for Dart
2+
3+
Thank you for contributing to the Firebase community!
4+
5+
- [Have a usage question?](#have-a-usage-question)
6+
- [Think you found a bug?](#think-you-found-a-bug)
7+
- [Have a feature request?](#have-a-feature-request)
8+
- [Want to submit a pull request?](#want-to-submit-a-pull-request)
9+
- [Need to get set up locally?](#need-to-get-set-up-locally)
10+
11+
## Have a usage question?
12+
13+
We get lots of those and we love helping you, but GitHub is not the best place for them. Issues which just ask about usage will be closed. Here are some resources to get help:
14+
15+
- Go through the [Firebase Admin SDK setup guide](https://firebase.google.com/docs/admin/setup/)
16+
- Read the full [API reference](https://pub.dev/documentation/dart_firebase_admin/latest/)
17+
18+
If the official documentation doesn't help, try asking on [Stack Overflow](https://stackoverflow.com/questions/tagged/firebase+dart).
19+
20+
**Please avoid double posting across multiple channels!**
21+
22+
## Think you found a bug?
23+
24+
Search through [existing issues](https://github.com/invertase/dart_firebase_admin/issues) before opening a new one — your question may have already been answered.
25+
26+
If your issue appears to be a bug and hasn't been reported, [open a new issue](https://github.com/invertase/dart_firebase_admin/issues/new) using the bug report template and include a minimal repro.
27+
28+
If you are up to the challenge, [submit a pull request](#want-to-submit-a-pull-request) with a fix!
29+
30+
## Have a feature request?
31+
32+
Share your idea through our [feature request support channel](https://firebase.google.com/support/contact/bugs-features/).
33+
34+
## Want to submit a pull request?
35+
36+
Sweet, we'd love to accept your contribution! [Open a new pull request](https://github.com/invertase/dart_firebase_admin/pulls) and fill out the provided template.
37+
38+
**If you want to implement a new feature, please open an issue with a proposal first so that we can figure out if the feature makes sense and how it will work.**
39+
40+
### Contributor License Agreement
41+
42+
Contributions to this project must be accompanied by a Contributor License Agreement (CLA). You (or your employer) retain the copyright to your contribution; the CLA gives us permission to use and redistribute your contributions as part of the project.
43+
44+
Visit <https://cla.developers.google.com/> to see your current agreements on file or to sign a new one. You generally only need to submit a CLA once, so if you have already submitted one you probably don't need to do it again.
45+
46+
### Code Reviews
47+
48+
All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more information on pull requests.
49+
50+
### Commit Messages
51+
52+
- Write clear, descriptive commit messages.
53+
- Use imperative mood (e.g., "Add App Check token verification" not "Added App Check token verification").
54+
- Reference issues with `#number` where applicable.
55+
56+
## Need to get set up locally?
57+
58+
### Prerequisites
59+
60+
- **Dart SDK** >= 3.9.0
61+
- **Java 21+** (required for the Firestore emulator)
62+
- **Node.js** (required for the Firebase Emulator and Cloud Tasks emulator)
63+
- **Melos** — Dart monorepo tool (`dart pub global activate melos`)
64+
- **Firebase CLI** (`npm install -g firebase-tools`)
65+
- **Google Cloud SDK** ([`gcloud`](https://cloud.google.com/sdk/downloads)) — required to authorise integration tests against a real Firebase project
66+
67+
### Setup
68+
69+
1. Fork and clone the repository.
70+
71+
2. Install Melos and bootstrap the workspace from the repo root:
72+
73+
```bash
74+
dart pub global activate melos
75+
melos bootstrap
76+
```
77+
78+
3. Verify your setup by running the analyzer and formatter:
79+
80+
```bash
81+
cd packages/dart_firebase_admin
82+
dart format --set-exit-if-changed .
83+
dart analyze
84+
```
85+
86+
### Repo Organization
87+
88+
This repository is a monorepo managed by [Melos](https://melos.invertase.dev/).
89+
90+
```
91+
dart_firebase_admin/ # Workspace root
92+
├── packages/
93+
│ ├── dart_firebase_admin/ # Main Firebase Admin SDK package
94+
│ │ ├── lib/
95+
│ │ │ ├── dart_firebase_admin.dart # Public API barrel file
96+
│ │ │ ├── auth.dart # Auth public exports
97+
│ │ │ ├── firestore.dart # Firestore public exports
98+
│ │ │ ├── messaging.dart # Messaging public exports
99+
│ │ │ ├── storage.dart # Storage public exports
100+
│ │ │ ├── app_check.dart # App Check public exports
101+
│ │ │ ├── security_rules.dart # Security Rules public exports
102+
│ │ │ ├── functions.dart # Functions public exports
103+
│ │ │ └── src/ # Private implementation
104+
│ │ └── test/
105+
│ │ ├── auth/ # Auth unit & integration tests
106+
│ │ ├── app/ # App unit & integration tests
107+
│ │ ├── firestore/ # Firestore tests
108+
│ │ ├── messaging/ # Messaging tests
109+
│ │ ├── storage/ # Storage tests
110+
│ │ └── helpers.dart # Shared test utilities
111+
│ └── google_cloud_firestore/ # Standalone Firestore package
112+
└── scripts/
113+
├── coverage.sh # Run tests with coverage
114+
└── firestore-coverage.sh # Firestore package coverage
115+
```
116+
117+
## Development Workflow
118+
119+
### Running Tests
120+
121+
Tests are split into unit/emulator tests and production integration tests.
122+
123+
#### Unit and Emulator Tests
124+
125+
```bash
126+
# From packages/dart_firebase_admin
127+
128+
# Run all tests against emulators (requires Firebase CLI)
129+
firebase emulators:exec --project dart-firebase-admin --only auth,firestore,functions,tasks,storage \
130+
"dart run coverage:test_with_coverage -- --concurrency=1"
131+
132+
# Or use the convenience script from the repo root
133+
./scripts/coverage.sh
134+
135+
# Run a specific test file
136+
dart test test/auth/auth_test.dart
137+
```
138+
139+
#### Integration Tests with Emulator Suite
140+
141+
Start the emulators, then run with the relevant environment variables:
142+
143+
```bash
144+
firebase emulators:start --only firestore,auth
145+
146+
export FIRESTORE_EMULATOR_HOST=localhost:8080
147+
export FIREBASE_AUTH_EMULATOR_HOST=localhost:9099
148+
dart test test/firestore/firestore_integration_test.dart
149+
```
150+
151+
#### Production Integration Tests
152+
153+
Requires a real Firebase project and Google application default credentials. Authorise `gcloud` first:
154+
155+
```bash
156+
gcloud beta auth application-default login
157+
```
158+
159+
Then run with `RUN_PROD_TESTS=true`:
160+
161+
```bash
162+
RUN_PROD_TESTS=true dart test test/app/firebase_app_prod_test.dart --concurrency=1
163+
```
164+
165+
See [`README.md`](README.md) for Firebase project setup details. You can create a project in the [Firebase Console](https://console.firebase.google.com) if you don't have one already.
166+
167+
### Code Formatting and Analysis
168+
169+
```bash
170+
# Check formatting (CI will reject unformatted code)
171+
dart format --set-exit-if-changed .
172+
173+
# Apply formatting
174+
dart format .
175+
176+
# Run the analyzer (must pass with zero issues)
177+
dart analyze
178+
```
179+
180+
### License Headers
181+
182+
All source files must include a license header. The project uses [addlicense](https://github.com/google/addlicense) to manage this automatically.
183+
184+
**Install addlicense:**
185+
186+
Download the binary for your platform from the [v1.2.0 release](https://github.com/google/addlicense/releases/tag/v1.2.0) and place it on your `PATH`. For example, on macOS ARM64:
187+
188+
```bash
189+
curl -sL https://github.com/google/addlicense/releases/download/v1.2.0/addlicense_v1.2.0_macOS_arm64.tar.gz | tar xz
190+
sudo mv addlicense /usr/local/bin/
191+
```
192+
193+
**Add headers to new files (run from repo root):**
194+
195+
```bash
196+
addlicense -f header_template.txt \
197+
--ignore "**/*.yml" --ignore "**/*.yaml" --ignore "**/*.xml" \
198+
--ignore "**/*.g.dart" --ignore "**/*.sh" --ignore "**/*.html" \
199+
--ignore "**/*.js" --ignore "**/*.ts" --ignore "**/*.txt" \
200+
--ignore "**/.dart_tool/**" \
201+
--ignore "LICENSE" \
202+
.
203+
```
204+
205+
**Check headers (dry run, same as CI):**
206+
207+
```bash
208+
addlicense -f header_template.txt --check \
209+
--ignore "**/*.yml" --ignore "**/*.yaml" --ignore "**/*.xml" \
210+
--ignore "**/*.g.dart" --ignore "**/*.sh" --ignore "**/*.html" \
211+
--ignore "**/*.js" --ignore "**/*.ts" --ignore "**/*.txt" \
212+
--ignore "**/.dart_tool/**" \
213+
--ignore "LICENSE" \
214+
.
215+
```
216+
217+
CI will fail if any source file is missing its license header.
218+
219+
### Local Validation
220+
221+
Run the full check suite locally before pushing:
222+
223+
```bash
224+
dart format --set-exit-if-changed .
225+
dart analyze
226+
./scripts/coverage.sh
227+
```
228+
229+
## Code Standards
230+
231+
### Style
232+
233+
The project uses strict analysis settings (`strict-casts`, `strict-inference`, `strict-raw-types`). Key conventions enforced by `analysis_options.yaml`:
234+
235+
- **Use single quotes** for strings (`prefer_single_quotes`).
236+
- **Use `final` for local variables** where values are not reassigned.
237+
- **Prefer relative imports** within the package.
238+
- **Always declare return types** on functions and methods.
239+
240+
### Public API
241+
242+
- Each Firebase product has its own barrel file (e.g., `lib/auth.dart`, `lib/firestore.dart`). Only add exports there for types that users need directly.
243+
- The top-level `lib/dart_firebase_admin.dart` re-exports core types. Product-specific types belong in their respective barrel files.
244+
- Classes under `lib/src/` are implementation details and should not be exported from barrel files unless they are part of the public API.
245+
246+
### Documentation
247+
248+
- Add dartdoc (`///`) comments to all new public APIs.
249+
- Include code examples in doc comments where they help clarify usage.
250+
251+
### Error Handling
252+
253+
- Use typed exceptions (e.g., `FirebaseAuthException`, `FirebaseMessagingException`) with appropriate error codes for user-facing errors.
254+
- Match the behaviour of the Node.js Admin SDK where applicable.
255+
256+
## Testing Requirements
257+
258+
- **All new features and bug fixes must include tests.**
259+
- **Unit/emulator tests** go in the appropriate subdirectory under `test/`. Use the `helpers.dart` utilities and `mocktail` for mocking where needed.
260+
- **Integration tests** (files named `*_integration_test.dart`) run against the Firebase Emulator in CI.
261+
- **Production tests** (files named `*_prod_test.dart`) require real credentials and are not run in CI by default — gate them behind `RUN_PROD_TESTS`.
262+
- Maintain overall coverage above the **40% threshold** enforced by CI.
263+
264+
## CI/CD
265+
266+
The project uses a single **build.yml** GitHub Actions workflow:
267+
268+
| Job | Trigger | What it does |
269+
|-----|---------|--------------|
270+
| `check-license-header` | PRs & schedule | Validates license headers on all source files |
271+
| `lint` | PRs & schedule | Runs `dart format` and `dart analyze` |
272+
| `test` | PRs & schedule | Runs tests against emulators with coverage reporting |
273+
| `test-integration` | PRs (non-fork) & schedule | Runs production integration tests with Workload Identity Federation |
274+
| `build` | After all above pass | Validates `dart pub publish --dry-run` |
275+
276+
Tests run against both `stable` and `beta` Dart SDK channels. Coverage is reported as a PR comment and uploaded to Codecov. The minimum threshold is **40%**.
277+
278+
## License
279+
280+
By contributing, you agree that your contributions will be licensed under the [Apache License 2.0](LICENSE).

LICENSE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Apache License
23
Version 2.0, January 2004
34
http://www.apache.org/licenses/
@@ -186,7 +187,7 @@
186187
same "printed page" as the copyright notice for easier
187188
identification within third-party archives.
188189

189-
Copyright 2020 Invertase Limited
190+
Copyright [yyyy] [name of copyright owner]
190191

191192
Licensed under the Apache License, Version 2.0 (the "License");
192193
you may not use this file except in compliance with the License.

header_template.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2026 Firebase
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.

0 commit comments

Comments
 (0)