Skip to content

Commit

Permalink
ci: add check for license header and add melos command to add & che…
Browse files Browse the repository at this point in the history
…ck license header (firebase#9704)

* Add `header_template.txt`

* Add instructions on running `addlicense`

* Run `addlicense -f header_template.txt .`

* Add `check-files-license-headers`

* Add comment

* Revert "Run `addlicense -f header_template.txt .`"

This reverts commit 3cfcc38.

* Add `melos run add-license-header`

* Adjust `CONTRIBUTING.md`

* Add `melos run check-license-header`

* Improve "check-files-license-headers" check

* Install Dart SDK instead of Flutter SDK

* disable `bootstrap`

* Add license header for missing files

* Ignore also text files

* ignore `.cmake`

* Add missing license header
  • Loading branch information
nilsreichardt authored Dec 2, 2022
1 parent 8e9f6b4 commit f3f8970
Show file tree
Hide file tree
Showing 259 changed files with 1,195 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/all_plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,25 @@ jobs:
run: melos run test --no-select
- name: 'Flutter Test - Web'
run: melos run test:web --no-select

check-files-license-headers:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.13.1'
# Go is used by addlicense command (addlicense is used in melos run
# check-license-header)
- run: go install github.com/google/addlicense@latest
- name: Install Dart
uses: dart-lang/setup-dart@v1.3
- name: Install Melos
uses: bluefireteam/melos-action@v2
with:
# Running `melos bootstrap` is not needed because we use Melos just
# for the `check-license-header` script.
run-bootstrap: false
- name: Check license header
run: melos run check-license-header
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,25 @@ You can do this online, and it only takes a minute.
If you've never submitted code before, you must add your (or your
organization's) name and contact info to the [AUTHORS](AUTHORS) file.

If you create a new file, do not forget to add the license header. You can use
[`addlicense`](https://github.com/google/addlicense) to add the license to all
necessary files.

To install `addlicense`, run:
```bash
go install github.com/google/addlicense@latest
```

Do not forget to add `$HOME/go/bin` to your `PATH`. If you are using Bash on
Linux or macOS, you need to add `export PATH="$HOME/go/bin:$PATH"` to your
`.bash_profile`.

To add the license header to all files, run from the root of the repository:
```bash
melos run add-license-header
```
This command uses `addlicense` with all necessary flags.

### The review process

Newly opened PRs first go through initial triage which results in one of:
Expand Down
3 changes: 3 additions & 0 deletions header_template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Copyright {{.Year}}, the Chromium project authors. Please see the AUTHORS file
for details. All rights reserved. Use of this source code is governed by a
BSD-style license that can be found in the LICENSE file.
65 changes: 65 additions & 0 deletions melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,68 @@ scripts:
# Additional cleanup lifecycle script, executed when `melos clean` is run.
postclean: >
melos exec -c 6 -- "flutter clean"
add-license-header:
# If you add here another --ignore flag, add it also to
# "check-license-header".
run: |
addlicense -f header_template.txt \
--ignore "**/*.yml" \
--ignore "**/*.yaml" \
--ignore "**/*.xml" \
--ignore "**/*.g.dart" \
--ignore "**/*.sh" \
--ignore "**/*.html" \
--ignore "**/*.js" \
--ignore "**/*.ts" \
--ignore "**/*.g.h" \
--ignore "**/*.g.m" \
--ignore "**/*.rb" \
--ignore "**/*.txt" \
--ignore "**/*.cmake" \
--ignore "**/Runner/AppDelegate.swift" \
--ignore "**/Runner/MainFlutterWindow.swift" \
--ignore "**/Runner/Runner-Bridging-Header.h" \
--ignore "**/Runner/AppDelegate.h" \
--ignore "**/Runner/AppDelegate.m" \
--ignore "**/Runner/main.m" \
--ignore "**/MainActivity.kt" \
--ignore "**/MainActivity.java" \
--ignore "**/FlutterMultiDexApplication.java" \
--ignore "**/GeneratedPluginRegistrant.swift" \
--ignore "**/Pods/**" \
.
description: Add a license header to all necessary files.

check-license-header:
# If you add here another --ignore flag, add it also to
# "add-license-header".
run: |
addlicense -f header_template.txt \
--check \
--ignore "**/*.yml" \
--ignore "**/*.yaml" \
--ignore "**/*.xml" \
--ignore "**/*.g.dart" \
--ignore "**/*.sh" \
--ignore "**/*.html" \
--ignore "**/*.js" \
--ignore "**/*.ts" \
--ignore "**/*.g.h" \
--ignore "**/*.g.m" \
--ignore "**/*.rb" \
--ignore "**/*.txt" \
--ignore "**/*.cmake" \
--ignore "**/Runner/AppDelegate.swift" \
--ignore "**/Runner/MainFlutterWindow.swift" \
--ignore "**/Runner/Runner-Bridging-Header.h" \
--ignore "**/Runner/AppDelegate.h" \
--ignore "**/Runner/AppDelegate.m" \
--ignore "**/Runner/main.m" \
--ignore "**/MainActivity.kt" \
--ignore "**/MainActivity.java" \
--ignore "**/FlutterMultiDexApplication.java" \
--ignore "**/GeneratedPluginRegistrant.swift" \
--ignore "**/Pods/**" \
.
description: Add a license header to all necessary files.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cloud_firestore_odm/cloud_firestore_odm.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:analyzer/dart/constant/value.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:analyzer/dart/constant/value.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:recase/recase.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:analyzer/dart/element/type.dart';

/// A mixin for obtaining the class name of collections/documents/snapshots/etc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import '../collection_generator.dart';
import '../named_query_data.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// An enum representing the different types of Android App Attest providers.
enum AndroidProvider {
// The debug provider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:firebase_app_check_platform_interface/src/android_provider.dart';

/// Converts [Provider] to [String]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();
4 changes: 4 additions & 0 deletions packages/firebase_ui_auth/example/lib/config.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// ignore_for_file: do_not_use_environment, constant_identifier_names

const GOOGLE_CLIENT_ID =
Expand Down
4 changes: 4 additions & 0 deletions packages/firebase_ui_auth/example/lib/decorations.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:firebase_ui_auth/firebase_ui_auth.dart';

Expand Down
4 changes: 4 additions & 0 deletions packages/firebase_ui_auth/example/lib/firebase_options.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
Expand Down
4 changes: 4 additions & 0 deletions packages/firebase_ui_auth/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:firebase_auth/firebase_auth.dart'
hide PhoneAuthProvider, EmailAuthProvider;
import 'package:firebase_core/firebase_core.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

//
// Generated file. Do not edit.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright 2022, the Chromium project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*/

//
// Generated file. Do not edit.
//
Expand Down
4 changes: 4 additions & 0 deletions packages/firebase_ui_auth/example/linux/main.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

#include "my_application.h"

int main(int argc, char** argv) {
Expand Down
4 changes: 4 additions & 0 deletions packages/firebase_ui_auth/example/linux/my_application.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

#include "my_application.h"

#include <flutter_linux/flutter_linux.h>
Expand Down
6 changes: 6 additions & 0 deletions packages/firebase_ui_auth/example/linux/my_application.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright 2022, the Chromium project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*/

#ifndef FLUTTER_MY_APPLICATION_H_
#define FLUTTER_MY_APPLICATION_H_

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/foundation.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:drive/drive.dart';
import 'package:firebase_auth/firebase_auth.dart'
hide EmailAuthProvider, PhoneAuthProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:async';

import 'package:flutter/material.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:firebase_auth/firebase_auth.dart'
hide EmailAuthProvider, PhoneAuthProvider;
import 'package:firebase_core/firebase_core.dart';
Expand Down
4 changes: 4 additions & 0 deletions packages/firebase_ui_auth/example/test_driver/utils.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Copyright 2022, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:convert';

import 'package:firebase_auth/firebase_auth.dart';
Expand Down
Loading

0 comments on commit f3f8970

Please sign in to comment.