Skip to content

Commit

Permalink
docs: create samples for quickstart guide (#1536)
Browse files Browse the repository at this point in the history
* docs: create samples for quickstart guide

* docs: add createConnection sample

* docs: add sample for DML

* docs: add sample for mutations

* feat: add dml batch sample

* feat: add more samples

* feat: add more samples

* feat: add data boost sample

* chore: fix style

* chore: add run commands

* fix: shorten method length

* test: add sample test runner

* fix: duplicate name

* chore: fix tag prefix

* chore: add more commands

* feat: add sample for emulator

* feat: add tagging sample

* chore: use fixed port binding for now

* chore: remove changes to JdbcDriver
  • Loading branch information
olavloite committed Apr 10, 2024
1 parent 6f85f5c commit 194c820
Show file tree
Hide file tree
Showing 7 changed files with 2,382 additions and 9 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/sample-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2024 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.
# Github action job to test core java library features on
# downstream client libraries before they are released.
on:
pull_request:
name: samples
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 8
- name: Run sample tests
run: mvn --quiet --batch-mode test
working-directory: samples/snippets
15 changes: 15 additions & 0 deletions samples/snippets/java.header
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
^/\*$
^ \* Copyright \d\d\d\d,? Google (Inc\.|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$
^ \*$
^ \*[ ]+https?://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\.$
^ \*/$
10 changes: 10 additions & 0 deletions samples/snippets/license-checks.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="RegexpHeader">
<property name="fileExtensions" value="java"/>
<property name="headerFile" value="${checkstyle.header.file}"/>
</module>
</module>
92 changes: 83 additions & 9 deletions samples/snippets/pom.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>spanner-jdbc-snippets</artifactId>
<packaging>jar</packaging>
<name>Google Google Cloud Spanner JDBC Snippets</name>
<url>https://github.com/googleapis/java-spanner-jdbc</url>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Removing or replacing it should not affect the execution of the samples in any way.
-->
<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.2.0</version>
<groupId>com.google.cloud</groupId>
<artifactId>sdk-platform-java-config</artifactId>
<version>3.27.0</version>
<relativePath/>
</parent>

<properties>
Expand Down Expand Up @@ -42,6 +38,84 @@
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-spanner-jdbc</artifactId>
</dependency>
<!-- [END spanner-jdbc_install_with_bom] -->

<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-spanner</artifactId>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.19.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- [END spanner-jdbc_install_with_bom] -->

<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/jdbc-snippets</outputDirectory>
<resources>
<resource>
<directory>resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/jdbc-snippets/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<finalName>jdbc-snippets/jdbc-samples</finalName>
<archive>
<index>false</index>
<manifest>
<mainClass>com.example.spanner.jdbc.JdbcSample</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 194c820

Please sign in to comment.