Skip to content
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

chore: add support to obj-c and java formatting #240

Merged
merged 4 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 55 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand All @@ -38,11 +39,57 @@ jobs:
- name: Typecheck files
run: yarn test:types

check-objc-formatting:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install clang-format
run: sudo apt-get install clang-format

- name: Check Objective-C formatting
run: ./scripts/format-objc.sh --check

check-java-formatting:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
java-package: 'jdk'

- name: Download google-java-format
run: |
GOOGLE_JAVA_FORMAT_VERSION=1.23.0
GOOGLE_JAVA_FORMAT_URL=https://github.com/google/google-java-format/releases/download/v${GOOGLE_JAVA_FORMAT_VERSION}/google-java-format-${GOOGLE_JAVA_FORMAT_VERSION}-all-deps.jar
mkdir -p $HOME/google-java-format
curl -L -o $HOME/google-java-format/google-java-format.jar $GOOGLE_JAVA_FORMAT_URL

- name: Create google-java-format wrapper script
run: |
cat << 'EOF' > /usr/local/bin/google-java-format
#!/bin/sh
exec java -jar "$HOME/google-java-format/google-java-format.jar" "$@"
EOF
chmod +x /usr/local/bin/google-java-format

- name: Check Java formatting
run: ./scripts/format-java.sh --check

test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand All @@ -52,9 +99,10 @@ jobs:

build-library:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand All @@ -64,11 +112,12 @@ jobs:

build-android:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
TURBO_CACHE_DIR: .turbo/android
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand Down Expand Up @@ -122,11 +171,12 @@ jobs:

build-ios:
runs-on: macos-14
timeout-minutes: 30
env:
TURBO_CACHE_DIR: .turbo/ios
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand Down
57 changes: 41 additions & 16 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ This project follows
- [git](https://git-scm.com) (used for source version control).
- An IDE such as [Android Studio](https://developer.android.com/studio) or [Visual Studio Code](https://code.visualstudio.com/).
- [addlicense](https://github.com/google/addlicense)
- [google-java-format Version 1.23.0](https://github.com/google/google-java-format) (used to format Java code).
- [clang-format](https://clang.llvm.org/docs/ClangFormat.html) (used to format Objective-C code).

## 2. Forking & cloning the repository

Expand All @@ -44,22 +46,6 @@ This project follows
fetch from the master repository, not your clone, when running `git fetch`
et al.)

## 3. Test your changes

- Make sure to test your changes before sending them for review. To do so, update and run the [Sample app](./example/) at `./example`.

### Code reviews

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 using pull requests.

Please peruse the
[Typescript style guide](https://google.github.io/styleguide/tsguide.html), [Java style guide](https://google.github.io/styleguide/javaguide.html), and [Objective-C style guide](https://google.github.io/styleguide/objcguide.html) before
working on anything non-trivial. These guidelines are intended to
keep the code consistent and avoid common pitfalls.

#### Create branch

1. `git fetch upstream`
Expand All @@ -84,3 +70,42 @@ keep the code consistent and avoid common pitfalls.
1. `git pull-request` (if you are using [Hub](http://github.com/github/hub/)) or
go to `https://github.com/googlemaps/react-native-navigation-sdk` and click the
"Compare & pull request" button

## 3. Test your changes

Make sure to test your changes before sending them for review. To do so, update and run the [Sample app](./example/) at `./example`.

## 4. Code Formatting

### Objective-C and Java Code Formatting

This project enforces code formatting for Objective-C and Java files to follow Google's style guidelines. The formatting is automatically checked before commits and during continuous integration (CI) using Lefthook and GitHub Actions.

#### Running Formatters Locally

Before committing your changes, you should run the formatters manually to ensure your code adheres to the required style:

**Objective-C:**
```bash
./scripts/format-objc.sh
```
This script will format all Objective-C files under the /ios and /example/ios directories according to Google's Objective-C style guide.

**Java:**
```bash
./scripts/format-java.sh
```
This script will format all Java files under the /android and /example/android directories according to Google's Java style guide.


## 5. Code reviews

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 using pull requests.

Please peruse the
[Typescript style guide](https://google.github.io/styleguide/tsguide.html), [Java style guide](https://google.github.io/styleguide/javaguide.html), and [Objective-C style guide](https://google.github.io/styleguide/objcguide.html) before
working on anything non-trivial. These guidelines are intended to
keep the code consistent and avoid common pitfalls.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public enum Command {
SET_MY_LOCATION_BUTTON_ENABLED(15, "setMyLocationButtonEnabled"),
SET_ROTATE_GESTURES_ENABLED(16, "setRotateGesturesEnabled"),
SET_SCROLL_GESTURES_ENABLED(17, "setScrollGesturesEnabled"),
SET_SCROLL_GESTURES_ENABLED_DURING_ROTATE_OR_ZOOM(18, "setScrollGesturesEnabledDuringRotateOrZoom"),
SET_SCROLL_GESTURES_ENABLED_DURING_ROTATE_OR_ZOOM(
18, "setScrollGesturesEnabledDuringRotateOrZoom"),
SET_TILT_GESTURES_ENABLED(19, "setTiltGesturesEnabled"),
SET_ZOOM_GESTURES_ENABLED(20, "setZoomGestures"),
SET_BUILDINGS_ENABLED(21, "setBuildingsEnabled"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
*/
package com.google.android.react.navsdk;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.CameraPerspective;
import com.google.android.libraries.navigation.AlternateRoutesStrategy;
import com.google.android.libraries.navigation.Navigator;
import com.google.android.libraries.navigation.ForceNightMode;
import com.google.android.gms.maps.GoogleMap.CameraPerspective;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.libraries.navigation.Navigator;

public class EnumTranslationUtil {
public static AlternateRoutesStrategy getAlternateRoutesStrategyFromJsValue(int jsValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@
*/
package com.google.android.react.navsdk;

import android.location.Location;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.GroundOverlay;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.Polygon;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.libraries.mapsplatform.turnbyturn.model.NavInfo;
import com.google.android.libraries.navigation.ArrivalEvent;
import com.google.android.libraries.navigation.Navigator;

public interface INavigationCallback {
void logDebugInfo(String info);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.google.android.react.navsdk;

import android.content.Context;

import com.google.android.libraries.navigation.Navigator;

/** Starts and stops the forwarding of turn-by-turn nav info from Nav SDK. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
import android.os.Message;
import android.os.Messenger;
import android.os.Process;

import androidx.annotation.Nullable;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.google.android.libraries.mapsplatform.turnbyturn.TurnByTurnManager;
import com.google.android.libraries.mapsplatform.turnbyturn.model.NavInfo;

Expand Down
Loading
Loading