Skip to content

Commit adf2a74

Browse files
amaksimoalemaksi
andauthored
Prepare samples repo for connector sync (#224)
## Summary Prepare the samples repo structure to enable automated syncing of examples from connector repos. ## Changes ### Java pgjdbc - Rename package from `org.example` to `software.amazon.dsql.examples` (matching connector) - Switch from Maven to Gradle build system (matching connector) - Add gradle wrapper for standalone builds - Update workflow to use `./gradlew test` instead of `mvn test` ### Python asyncpg (NEW) - Add new `python/asyncpg/` folder with examples from connector - Add integration test workflow for asyncpg ## Files Changed | Type | Description | |------|-------------| | Renamed | Java files moved to new package path | | Deleted | `pom.xml` (replaced by Gradle) | | Added | Gradle wrapper files | | Added | `python/asyncpg/` folder with examples | | Added | `python-asyncpg-integ-tests.yml` workflow | | Modified | `java-pgjdbc-integ-tests.yml` to use Gradle | ## Testing - Java compiles successfully with Gradle - Python files pass syntax check - Integration tests will run in CI ## Motivation This aligns the samples repo structure with the connector repos to enable automated syncing of examples. The `ExampleWithNoConnector` files remain samples-only and will not be overwritten by sync. Co-authored-by: Aleksandar Maksimovic <alemaksi@amazon.com>
1 parent 02dc4d3 commit adf2a74

30 files changed

Lines changed: 981 additions & 133 deletions

.github/workflows/java-pgjdbc-integ-tests.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
java-version: '17'
4141
distribution: 'corretto'
4242
architecture: x64
43-
cache: maven
43+
cache: gradle
4444

4545
- name: Configure AWS Credentials
4646
uses: aws-actions/configure-aws-credentials@v4
@@ -54,8 +54,4 @@ jobs:
5454
CLUSTER_ENDPOINT: ${{ secrets.JAVA_PGJDBC_CLUSTER_ENDPOINT }}
5555
CLUSTER_USER: admin
5656
REGION: ${{ secrets.JAVA_PGJDBC_CLUSTER_REGION }}
57-
run: |
58-
mvn validate
59-
mvn initialize
60-
mvn compile
61-
mvn test
57+
run: ./gradlew test
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Python asyncpg integration tests
2+
3+
permissions: {}
4+
5+
on:
6+
push:
7+
branches: [ main ]
8+
paths:
9+
- 'python/asyncpg/**'
10+
- '.github/workflows/python-asyncpg-integ-tests.yml'
11+
pull_request:
12+
branches: [ main ]
13+
paths:
14+
- 'python/asyncpg/**'
15+
- '.github/workflows/python-asyncpg-integ-tests.yml'
16+
# Give us a button to allow running the workflow on demand for testing.
17+
workflow_dispatch:
18+
inputs:
19+
tags:
20+
description: 'Manual Workflow Run'
21+
required: false
22+
type: string
23+
24+
jobs:
25+
python-asyncpg-integ-test:
26+
runs-on: ubuntu-latest
27+
permissions:
28+
id-token: write # required by aws-actions/configure-aws-credentials
29+
concurrency:
30+
# Ensure only 1 job uses the workflow cluster at a time.
31+
group: ${{ github.workflow }}
32+
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Set up Python
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: '3.10'
41+
42+
- name: Cache pip packages
43+
uses: actions/cache@v4
44+
with:
45+
path: ~/.cache/pip
46+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
47+
restore-keys: |
48+
${{ runner.os }}-pip-
49+
50+
- name: Configure AWS Credentials
51+
uses: aws-actions/configure-aws-credentials@v4
52+
with:
53+
role-to-assume: ${{ secrets.PYTHON_IAM_ROLE }}
54+
aws-region: us-east-1
55+
56+
- name: Configure and run integration for asyncpg - admin
57+
working-directory: ./python/asyncpg
58+
env:
59+
CLUSTER_USER: "admin"
60+
CLUSTER_ENDPOINT: ${{ secrets.PYTHON_PSYCOPG3_CLUSTER_ENDPOINT }}
61+
run: |
62+
python3 -m venv .venv
63+
source .venv/bin/activate
64+
pip install --upgrade pip
65+
pip install --force-reinstall -r requirements.txt
66+
python3 -c "import boto3; print(boto3.__version__)"
67+
pip list
68+
echo "$GITHUB_WORKSPACE" >> $GITHUB_PATH
69+
wget https://www.amazontrust.com/repository/AmazonRootCA1.pem -O root.pem
70+
pytest

java/pgjdbc/README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ connections should be used where possible to ensure data security during transmi
5656
```bash
5757
java -version
5858

59-
* Build Tool (Maven or Gradle)
60-
- _Maven_: Ensure Maven is installed if that is your preferred option. You can download it from the [official website](https://maven.apache.org/download.cgi).
61-
- _Gradle_: Ensure Gradle is installed if that is your preferred option. You can download it from the [official website](https://gradle.org/install/).
59+
* Gradle: This example uses the Gradle wrapper included in the repository, so no separate installation is required.
6260
* AWS SDK: Ensure that you setup the latest version of the AWS Java SDK [official website](https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/setup.html)
6361
* You must have an Aurora DSQL cluster. For information about creating an Aurora DSQL cluster, see the
6462
[Getting started with Aurora DSQL](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/getting-started.html)
@@ -95,18 +93,15 @@ export CLUSTER_ENDPOINT="<your endpoint>"
9593

9694
Run the example:
9795

98-
- _Maven_:
99-
100-
```bash
101-
mvn compile
102-
mvn test
103-
```
96+
```bash
97+
./gradlew run
98+
```
10499

105-
- _Gradle_:
100+
Run the tests:
106101

107-
```bash
108-
gradle run
109-
```
102+
```bash
103+
./gradlew test
104+
```
110105

111106

112107
The example contains comments explaining the code and the operations being performed.
@@ -122,4 +117,4 @@ The example contains comments explaining the code and the operations being perfo
122117

123118
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
124119

125-
SPDX-License-Identifier: MIT-0
120+
SPDX-License-Identifier: Apache-2.0

java/pgjdbc/build.gradle.kts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
25

36
plugins {
@@ -6,18 +9,22 @@ plugins {
69
}
710

811
application {
9-
mainClass = "org.example.Example"
12+
mainClass = "software.amazon.dsql.examples.ExamplePreferred"
1013
}
1114

12-
group = "org.example"
15+
group = "software.amazon.dsql.examples"
1316
version = "1.0-SNAPSHOT"
1417

1518
repositories {
1619
mavenCentral()
1720
}
1821

1922
dependencies {
23+
implementation("com.zaxxer:HikariCP:5.1.0")
2024
implementation("software.amazon.dsql:aurora-dsql-jdbc-connector:1.2.0")
25+
// AWS SDK dependencies for SDK-only example (ExampleWithNoConnector)
26+
implementation("software.amazon.awssdk:dsql:2.31.32")
27+
implementation("org.postgresql:postgresql:42.7.7")
2128

2229
testImplementation(platform("org.junit:junit-bom:5.10.0"))
2330
testImplementation("org.junit.jupiter:junit-jupiter")
@@ -41,4 +48,4 @@ tasks.withType<Test> {
4148

4249
tasks.withType<JavaExec> {
4350
this.enableAssertions = true
44-
}
51+
}
44.4 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)