Skip to content

Commit

Permalink
Merge pull request #62 from momentohq/docs-examples
Browse files Browse the repository at this point in the history
chore: add examples for documentation
  • Loading branch information
nand4011 authored Jan 16, 2024
2 parents 8dcf383 + c12a664 commit 120ac59
Show file tree
Hide file tree
Showing 15 changed files with 798 additions and 15 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,35 @@ jobs:
with:
api-level: ${{ matrix.api-level }}
script: ./gradlew connectedCheck

examples:
runs-on: ubuntu-latest
env:
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}

steps:
- name: Checkout project
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'corretto'

- name: Run doc examples
id: validation
run: |
cd examples
./gradlew docExamples readmeExample cheatSheetExample basic
- name: Send CI failure mail
if: ${{ steps.validation.outcome == 'failure' }}
uses: momentohq/standards-and-practices/github-actions/error-email-action@gh-actions-v1
with:
username: ${{secrets.MOMENTO_ROBOT_GMAIL_USERNAME}}
password: ${{secrets.MOMENTO_ROBOT_GMAIL_PASSWORD}}

- name: Flag Job Failure
if: ${{ steps.validation.outcome == 'failure' }}
run: exit 1
4 changes: 2 additions & 2 deletions .github/workflows/on-push-to-main-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
- name: Generate README
uses: momentohq/standards-and-practices/github-actions/generate-and-commit-oss-readme@gh-actions-v2
with:
project_status: incubating
project_stability: alpha
project_status: official
project_stability: beta
project_type: sdk
sdk_language: Kotlin
dev_docs_slug: kotlin
Expand Down
16 changes: 3 additions & 13 deletions README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,23 @@

## Packages

The Kotlin SDK is available on the Sonatype Central snapshots repo:
The Kotlin SDK is available on Maven Central:

### Gradle

```kotlin
repositories {
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}

dependencies {
implementation("software.momento.kotlin:sdk:0.1.0-SNAPSHOT")
implementation("software.momento.kotlin:sdk:0.1.3")
}
```

### Maven

```xml
<repository>
<id>sonatype-snapshots</id>
<name>Sonatype Snapshots</name>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
</repository>

<dependency>
<groupId>software.momento.kotlin</groupId>
<artifactId>sdk</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>0.1.3</version>
</dependency>
```

Expand Down
42 changes: 42 additions & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
15 changes: 15 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Kotlin Client SDK

<br>

## Running the Examples

- You do not need gradle to be installed
- JDK 11 or above is required to run the example
- To get started with Momento you will need a Momento API key. You can get one from the
[Momento Console](https://console.gomomento.com).

### Basic
```bash
MOMENTO_API_KEY=<YOUR API KEY> ./gradlew basic
```
43 changes: 43 additions & 0 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
plugins {
kotlin("jvm") version "1.9.22"
}

group = "software.momento.kotlin"
version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
}

dependencies {
implementation("software.momento.kotlin:sdk:0.1.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
}

kotlin {
jvmToolchain(8)
}

tasks.register<JavaExec>("basic") {
description = "Run the basic example"
classpath = sourceSets["main"].runtimeClasspath
mainClass = "software.momento.example.BasicExampleKt"
}

tasks.register<JavaExec>("docExamples") {
description = "Run the doc examples"
classpath = sourceSets["main"].runtimeClasspath
mainClass = "software.momento.example.doc_examples.DocExamplesKt"
}

tasks.register<JavaExec>("readmeExample") {
description = "Run the readme example"
classpath = sourceSets["main"].runtimeClasspath
mainClass = "software.momento.example.doc_examples.ReadmeExampleKt"
}

tasks.register<JavaExec>("cheatSheetExample") {
description = "Run the cheat sheet example"
classpath = sourceSets["main"].runtimeClasspath
mainClass = "software.momento.example.doc_examples.CheatSheetKt"
}
1 change: 1 addition & 0 deletions examples/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.code.style=official
Binary file added examples/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions examples/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 120ac59

Please sign in to comment.