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

Initial Commit #2

Merged
merged 1 commit into from
Dec 12, 2023
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
36 changes: 36 additions & 0 deletions .github/hooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
HOOKS_DIR=".git/hooks/pre-push.d"

for hook in "$HOOKS_DIR"/*; do
"$hook"
EXIT_CODE=$?

if [ $EXIT_CODE != 0 ]; then
echo "Pre-push hook failed: $hook"
exit $EXIT_CODE
fi
done

# Check for changes made by the hooks
if ! git diff-index --quiet HEAD --; then
# Stage any changes
git add -u

# Amend the newly made commit with these changes
git commit --amend --no-edit
fi

exit 0
18 changes: 18 additions & 0 deletions .github/hooks/pre-push.d/formatting.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
echo "Running ktfmtFormat before push..."
./gradlew ktfmtFormat || exit 1

echo "Code formatted successfully."
18 changes: 18 additions & 0 deletions .github/hooks/pre-push.d/licensing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
echo "Running applyLicense before push..."
./gradlew applyLicense || exit 1

echo "License headers successfully."
36 changes: 36 additions & 0 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Perform a Gradle `build` which includes `assemble`, `check`, `test`
# of the projects, and uploads the generated artifacts.

name: Generate release artifacts

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: gradle
- name: Perform a Gradle build
run: ./gradlew generativeai:publishAllPublicationsToMavenRepository
- name: Upload generated artifacts
uses: actions/upload-artifact@v2
with:
name: google-ai-android
path: generativeai/m2
retention-days: 5
19 changes: 19 additions & 0 deletions .github/workflows/check-code-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check code format

on: pull_request

jobs:
check-format:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: gradle
- name: Run ktfmt
run: |
./gradlew ktfmtCheck --no-daemon
19 changes: 19 additions & 0 deletions .github/workflows/check-licensing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check licensing

on: pull_request

jobs:
check-licensing:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: gradle
- name: Run license validator
run: |
./gradlew validateLicense --no-daemon
57 changes: 57 additions & 0 deletions .github/workflows/check_for_api_changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Check for api changes

on: pull_request

jobs:
check-for-api-changes:
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/[email protected]
with:
ref: ${{ github.base_ref }}

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: gradle

- name: Update public.api
run: |
./gradlew updateApi --no-daemon

- name: Save public.api from master
run: mv generativeai/public.api ~/public.api

- name: Checkout branch
uses: actions/[email protected]

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: gradle

- name: Copy saved api to branch
run: mv ~/public.api generativeai/public.api

- name: Run api warning task
run: |
./gradlew warnAboutApiChanges --no-daemon

- name: Add PR Comment
if: ${{ hashFiles('api_changes.md') != '' }}
uses: marocchino/[email protected]
with:
header: api_changes
path: build/api_changes.md

- name: Remove old PR Comment
if: ${{ hashFiles('api_changes.md') == '' }}
uses: marocchino/[email protected]
with:
header: api_changes
delete: true
36 changes: 36 additions & 0 deletions .github/workflows/generate_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Perform a Gradle `build` which includes `assemble`, `check`, `test`
# of the projects, and uploads the generated artifacts.

name: Generate docs

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "gen-docs"
gen-docs:
# The type of runner that the job will run on
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: gradle
- name: Run dokka
run: ./gradlew generativeai:dokkaHtml
- name: Upload generated docs
uses: actions/upload-artifact@v2
with:
name: google-ai-android
path: generativeai/build/dokka/html
retention-days: 5
19 changes: 19 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Unit tests

on: pull_request

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/[email protected]
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: gradle
- name: Run tests
run: |
./gradlew test --no-daemon
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Log/OS Files
*.log

# Android Studio generated files and folders
captures/
.externalNativeBuild/
.cxx/
*.apk
output.json

# IntelliJ
*.iml
.idea/
misc.xml
deploymentTargetDropDown.xml
render.experimental.xml

# Keystore files
*.jks
*.keystore

# Google Services (e.g. APIs or Firebase)
google-services.json

# Android Profiling
*.hprof
28 changes: 28 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# How to Contribute

We'd love to accept your patches and contributions to this project. There are
just a few small guidelines you need to follow.

## Contributor License Agreement

Contributions to this project must be accompanied by a Contributor License
Agreement. You (or your employer) retain the copyright to your contribution;
this simply gives us permission to use and redistribute your contributions as
part of the project. Head over to <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've already submitted one
(even if it was for a different project), you probably don't need to do it
again.

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

## Community Guidelines

This project follows
[Google's Open Source Community Guidelines](https://opensource.google.com/conduct/).
65 changes: 65 additions & 0 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Developing

## Setting up the repo

### Git Hooks

This repo uses git hooks for certain behaviors such as formatting before a push. To install the git
hooks, run the following command at the root of your repo directory:

```bash
./INSTALL_HOOKS.sh
```

## Building and Releasing

To locally publish the m2 repo:

`./gradlew generativeai:publishToMavenLocal`

To generate a releasable m2 repo:

`./gradlew generativeai:publishAllPublicationsToMavenRepository`

The m2 repo will be in `generativeai/m2`.

To generate Dokka:

`./gradlew generativeai:dokkaHtml`

The docs will be in `generativeai/build/dokka/html`.

## Making changes

When making changes that are intended to invoke a release, it's important to make sure a proper
changelog entry accompanies your change. We use a custom [plugin](./plugins/README.md), alongside an
executable bash script called `change` to better facilitate this process.

Changes are organized in the `.changes` directory at the root of the repo, and each change pending
a release will be represented as a single file with a seemingly random string of words as a file
name. This file will contain two vital pieces of information;

- What the change is about (a user displayable message to use in the subsequent release notes)
- The api impact of the change (will this require a major, minor, or patch bump?)

We have tooling that will automatically determine the impact of your changes, so all you need to do
is run the following command from the root of the repo whenever you want to make a change that will
invoke a release:

```bash
change "hello world!"
```

Alternatively, if you want to invoke a release without adding anything to the release notes come
release time- you can run `change` without specifying a message:

```bash
change
```

Both of these commands should generate a new file under the `.changes` directory with your message
and impact.


To learn more, read the section on our changelog plugin in our [plugin readme](./plugins/README.md).

Loading
Loading