Skip to content

Setting Up the Release Process #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 55 commits into from
Apr 17, 2017
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
428eedb
Initial code migration:
Apr 6, 2017
cfbbd6a
Reformatting code according to check-style plugin conventions
hiranya911 Apr 6, 2017
59842b8
Code reformatting: Fixing javadoc indentation
hiranya911 Apr 6, 2017
fef4ecf
More reformatting: Added google check style config
hiranya911 Apr 6, 2017
a606833
Code formatting continued
hiranya911 Apr 6, 2017
1d2ed82
Code formatting continued
hiranya911 Apr 6, 2017
8972b1b
Reformatting
hiranya911 Apr 6, 2017
e5509c3
Fixed all checkstyle violations; Build configured to fail on lint errors
Apr 6, 2017
0587d52
Updated checkstyle config
Apr 6, 2017
7f2f470
Working on re-enabling the integration tests
Apr 7, 2017
8ee5cfc
Temporarily removing IT test cases
Apr 7, 2017
dbc6ee6
Extending checkstyle coverage to test sourcesw
Apr 7, 2017
c66f35b
Cleaned up verbose test output
Apr 7, 2017
f7cbdc2
Adding 2 integration tests to verify the maven integration test support
Apr 7, 2017
7715b90
Moving test only trampolines to the test/ subtree; Adding a removed m…
Apr 10, 2017
c3591ed
Fixing integration tests
hiranya911 Apr 11, 2017
bc54329
Added event test
hiranya911 Apr 11, 2017
75df20f
Added the real time test
hiranya911 Apr 11, 2017
471d0a9
Adding data test back
hiranya911 Apr 11, 2017
f692bb6
Fixed the object serialization test
hiranya911 Apr 11, 2017
c368248
Adding a factory method to MapBuilder
hiranya911 Apr 11, 2017
a30ae95
Added transaction integration test
hiranya911 Apr 11, 2017
7714024
Added transaction test
hiranya911 Apr 11, 2017
2da7955
Added rules integration test
hiranya911 Apr 11, 2017
094d756
Updated rules test
hiranya911 Apr 11, 2017
f446c79
Merge branch 'hkj-initial-code-migration' into hkj-db-integration-tests
hiranya911 Apr 11, 2017
952c6b0
Cleaning up the test code; Removed unnecessary utils and constants
hiranya911 Apr 12, 2017
594bfbb
Added more factory methods for MapBuilder; Removed unused legacy depe…
hiranya911 Apr 12, 2017
5dc413f
Dropped the jackson test dependency
hiranya911 Apr 12, 2017
738c75e
Adding release profile
Apr 12, 2017
5e81a8b
Ignoring some maven specific temp files
Apr 12, 2017
922054d
Updated pom to use release + nexus plugin combo
Apr 12, 2017
337299f
Loading the version numbner from a Maven-filtered resource
Apr 12, 2017
aa88398
Adding the initial version of contribution guide
Apr 12, 2017
a0ef544
Merge branch 'hkj-db-integration-tests' into hkj-release-process
Apr 12, 2017
8b2ff85
Inferring the DB URL from project ID
Apr 12, 2017
2da5b03
Fixed test race condition
Apr 13, 2017
a24340c
Merge branch 'hkj-db-integration-tests' into hkj-release-process
Apr 13, 2017
7d39734
Fixing some race conditions in ITs
Apr 13, 2017
5f8e82a
Merge branch 'hkj-db-integration-tests' into hkj-release-process
Apr 13, 2017
4b0361c
Cleaning up EventHelper instances after use
hiranya911 Apr 13, 2017
e5eca5c
Merge branch 'hkj-db-integration-tests' into hkj-release-process
Apr 13, 2017
3d3be22
Adding back some logging code; Dropping fblocal URLs
Apr 13, 2017
eefc4ce
Dropping all references to fblocal
Apr 13, 2017
d13b1ec
Merge branch 'hkj-db-integration-tests' into hkj-release-process
Apr 13, 2017
e911387
Removing port numbers from test URLs
Apr 14, 2017
3c7f98f
Separated conjunctive assertions into separate ones for better error …
hiranya911 Apr 14, 2017
7efbd53
Merge branch 'hkj-db-integration-tests' into hkj-release-process
hiranya911 Apr 14, 2017
59d1689
Merge branch 'hkj-release-process' of github.com:firebase/firebase-ad…
Apr 14, 2017
0dc979c
Fixing merge conflict
Apr 14, 2017
b47dbf6
Allowing snapshot versions in database
Apr 14, 2017
78fdef7
Updated contributing guide
Apr 14, 2017
f5883d7
Updated titles and links
Apr 14, 2017
21e14d6
Fixing SCM URL
Apr 14, 2017
e0757cd
Downgrading guava version to 20.0 since 21.0 only works on Java 8 (ht…
Apr 17, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Contributing | Firebase Admin Python SDK

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python? :-P

(same thing in a few places; please search this file for "python" and fix)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops :)

Fixed.


Thank you for contributing to the Firebase community!

- [Have a usage question?](#question)
- [Think you found a bug?](#issue)
- [Have a feature request?](#feature)
- [Want to submit a pull request?](#submit)
- [Need to get set up locally?](#local-setup)


## <a name="question"></a>Have a usage question?

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:

- Go through the [guides](https://firebase.google.com/docs/admin/setup/)
- Read the full [API reference](https://firebase.google.com/docs/reference/admin/python/)

If the official documentation doesn't help, try asking a question on the
[Firebase Google Group](https://groups.google.com/forum/#!forum/firebase-talk/) or one of our
other [official support channels](https://firebase.google.com/support/).

**Please avoid double posting across multiple channels!**


## <a name="issue"></a>Think you found a bug?

Yeah, we're definitely not perfect!

Search through [old issues](https://github.com/firebase/firebase-admin-python/issues) before
submitting a new issue as your question may have already been answered.

If your issue appears to be a bug, and hasn't been reported,
[open a new issue](https://github.com/firebase/firebase-admin-python/issues/new). Please use the
provided bug report template and include a minimal repro.

If you are up to the challenge, [submit a pull request](#submit) with a fix!


## <a name="feature"></a>Have a feature request?

Great, we love hearing how we can improve our products! Share you idea through our
[feature request support channel](https://firebase.google.com/support/contact/bugs-features/).


## <a name="submit"></a>Want to submit a pull request?

Sweet, we'd love to accept your contribution!
[Open a new pull request](https://github.com/firebase/firebase-admin-python/pull/new/master) and fill
out the provided template.

**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.**

Make sure your changes pass our linter and the tests all pass on your local machine.
Most non-trivial changes should include some extra test coverage. If you aren't sure how to add
tests, feel free to submit regardless and ask us for some advice.

Finally, you will need to sign our
[Contributor License Agreement](https://cla.developers.google.com/about/google-individual)
before we can accept your pull request.


## <a name="local-setup"></a>Need to get set up locally?

### Initial Setup

Install Java 7 or higher. You can also use Java 8, but please note that the Firebase Admin SDK must
maintain full Java 7 compatibility. Therefore make sure that you do not use any Java 8 features
(e.g. lambdas) when writing code for the Admin Java SDK.

We use [Apache Maven](http://maven.apache.org/) for building, testing and releasing the Admin Java
SDK code. Follow the [installation guide](http://maven.apache.org/install.html), and install Maven
3.3 or higher.

### Running Linters

[Maven Checkstyle plugin](https://maven.apache.org/plugins/maven-checkstyle-plugin/) is configured
to run everytime the build is invoked. This plugin verifies source code format, and enforces a
number of other Java programming best practices. Any style violations will cause the build to break.

Configuration for the Checkstyle plugin can be found in the `checkstyle.xml` file at the root of the
repository. To execute only the linter without rest of the build pipeline, execute the following
command:

```
mvn validate
```

If you are using Eclipse for development, you can install the
[Eclipse Checkstyle plugin](http://eclipse-cs.sourceforge.net/#!/), and import the `checkstyle.xml`
file into the IDE. This enables you to have the linter constantly checking your code as you develop.

### Unit Testing

Tests are implemented using the [Junit4](http://junit.org/junit4/) framework, and are housed under
the `src/test` subdirectory. They get executed as part of the build, and test failures will cause
the build to break. To run the unit tests without the rest of the build pipeline, execute the
following command:

```
mvn test
```

### Integration Testing

Integration tests are also written using Junit4. They coexist with the unit tests in the `src/test`
subdirectory. Integration tests follow the naming convention `*IT.java` (e.g. `DataTestIT.java`),
which enables the Maven Surefire and Failsafe plugins to differentiate between the two types of
tests. Integration tests are executed against a real life Firebase project, and therefore
requires an Internet connection. Create a new project in the
[Firebase console](https://console.firebase.google.com/) if you do not already have one. Download
the service account private key from the "Settings" page of the project. Now run the following
command to invoke the integration test suite:

```
mvn verify -Dfirebase.it.certificate=path/to/your/serviceAccount.json

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "certificate" instead of "serviceAccount" or something? I'm not really sure if "certificate" is appropriate.

```

Make sure to specify the correct path to your downloaded service account key file as the
`firebase.it.certificate` system property. This command will invoke both unit and integration test
suites. To execute only the integration tests, run the command as follows:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel strongly, but why would you only want to run the integration tests? It seems more useful to run only the unit tests (since they're presumably faster and would work even without an internet connection). But I think I'd be inclined to just direct folks to run everything (and remove this section).


```
mvn verify -Dfirebase.it.certificate=path/to/your/serviceAccount.json -Dskip.surefire.tests=true
```



2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ target/
*.iml
.classpath
.project
.checkstyle
release.properties
91 changes: 91 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,76 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

<scm>
<connection>scm:git:https://github.com/firebase/firebase-admin-java.git</connection>
<developerConnection>scm:git:ssh//github.com/firebase/firebase-admin-java.git</developerConnection>
<url>http://github.com/simpligility/ossrh-demo/tree/master</url>
</scm>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
Expand Down Expand Up @@ -72,6 +141,28 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<tagNameFormat>v@{project.version}</tagNameFormat>
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
20 changes: 18 additions & 2 deletions src/main/java/com/google/firebase/database/FirebaseDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
import com.google.firebase.database.utilities.Utilities;
import com.google.firebase.database.utilities.Validation;

import com.google.firebase.internal.Preconditions;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
* The entry point for accessing a Firebase Database. You can get an instance by calling {@link
Expand All @@ -22,8 +26,8 @@
*/
public class FirebaseDatabase {

// This constant gets updated during the release process (see release-to-gh.sh script)
private static final String SDK_VERSION = "4.1.6";
private static final String ADMIN_SDK_PROPERTIES = "admin_sdk.properties";
private static final String SDK_VERSION = loadSdkVersion();

/**
* A static map of FirebaseApp and RepoInfo to FirebaseDatabase instance. To ensure thread-
Expand Down Expand Up @@ -324,4 +328,16 @@ private synchronized void ensureRepo() {
DatabaseConfig getConfig() {
return this.config;
}

private static String loadSdkVersion() {
try (InputStream in = FirebaseDatabase.class.getClassLoader()
.getResourceAsStream(ADMIN_SDK_PROPERTIES)) {
Preconditions.checkNotNull(in, "Failed to load: " + ADMIN_SDK_PROPERTIES);
Properties properties = new Properties();
properties.load(in);
return properties.getProperty("sdk.version");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/admin_sdk.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sdk.version=${project.version}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ public void userAgentHasCorrectParts() {
public void sdkVersionIsWellFormed() {
// Version number gets filled in during the release process.
// Having a test case makes sure there are no mishaps.
final String snapshot = "-SNAPSHOT";
String sdkVersion = FirebaseDatabase.getSdkVersion();
if (sdkVersion.endsWith(snapshot)) {
sdkVersion = sdkVersion.substring(0, sdkVersion.length() - snapshot.length());
}
String[] segments = sdkVersion.split("\\.");
Assert.assertEquals(3, segments.length);
for (String segment : segments) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ public class IntegrationTestUtils {

private static JSONObject IT_SERVICE_ACCOUNT;

public static String getDatabaseUrl() {
String url = System.getProperty("firebase.it.url");
return Preconditions.checkNotEmpty(
url, "Database URL not set. Set the firebase.it.url " + "system property and try again.");
}

private static synchronized JSONObject ensureServiceAccount() {
if (IT_SERVICE_ACCOUNT == null) {
String certificatePath = System.getProperty("firebase.it.certificate");
Expand All @@ -62,6 +56,10 @@ public static String getProjectId() {
return ensureServiceAccount().get("project_id").toString();
}

public static String getDatabaseUrl() {
return "https://" + getProjectId() + ".firebaseio.com";
}

public static FirebaseApp initDefaultApp() {
FirebaseOptions options =
new FirebaseOptions.Builder()
Expand Down