Skip to content

Update run_examples.yml #2403

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

Merged
merged 7 commits into from
Jun 2, 2025
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
33 changes: 22 additions & 11 deletions .github/workflows/run_examples.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
name: Examples
name: Run Examples

on:
workflow_dispatch:
inputs:
version:
description: "Release version"
required: true


concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.number || github.sha }}
cancel-in-progress: true
Expand All @@ -32,21 +28,36 @@ jobs:
8
21
cache: "maven"
- name: Save Repo Artifacts
id: save-repo-artifacts
uses: actions/cache/save@v4
with:
path: ~/.m2/repository/com/clickhouse
key: ${{ github.run_id }}-ch-artifacts
- name: Build and install libraries
run: mvn --batch-mode --no-transfer-progress --show-version --strict-checksums --threads 2 -Dmaven.wagon.rto=30000 -Dj8 -DskipITs install
- name: Compile examples
run: |
cd examples/jdbc
mvn clean compile
echo "Run Id ${{ github.run_id }}"
run-examples:
runs-on: ubuntu-latest
timeout-minutes: 15
name: Run Examples
needs: compile
steps:
- name: Run Docker
- name: Check out repository
uses: actions/checkout@v4
- name: Restore Repo Artifacts
id: restore-repo-artifacts
uses: actions/cache/restore@v4
with:
path: ~/.m2/repository/com/clickhouse
key: ${{ github.run_id }}-ch-artifacts
- name: Run Examples
run: |
docker run -d --name demo-service-db -e CLICKHOUSE_USER=default -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=secret\
-p 8123:8123 clickhouse/clickhouse-server
docker run -d --name demo-service-db -e CLICKHOUSE_USER=default -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=secret -p 8123:8123 clickhouse/clickhouse-server:24.8
cd examples/jdbc
mvn
mvn exec:java -Dexec.mainClass="com.clickhouse.examples.jdbc.Basic"
mvn --batch-mode --no-transfer-progress --show-version clean compile
mvn exec:java -Dexec.mainClass="com.clickhouse.examples.jdbc.Basic" -DchPassword=secret -DfailOnError=true
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,23 @@ public class Basic {
private static final Logger log = LoggerFactory.getLogger(Basic.class);
static final String TABLE_NAME = "jdbc_example_basic";

public static void main(String[] args) {
public static void main(String[] args) throws Exception {
String url = System.getProperty("chUrl", "jdbc:ch://localhost:8123");

// Set user and password if needed
Properties properties = new Properties();
properties.setProperty("user", System.getProperty("chUser", "default"));
properties.setProperty("password", System.getProperty("chPassword", ""));

try {
createTable(url, properties);
insertDateWithPreparedStatement(url, properties);
printInsertedData(url, properties);
createTable(url, properties);
insertDateWithPreparedStatement(url, properties);
printInsertedData(url, properties);

//Customizing client settings
setClientSettings(properties);
//Customizing client settings
setClientSettings(properties);

//Using HikariCP with ClickHouseDataSource
usedPooledConnection(url, properties);
} catch (SQLException e) {
log.error("Error", e);
}
//Using HikariCP with ClickHouseDataSource
usedPooledConnection(url, properties);
}

static void createTable(String url, Properties properties) throws SQLException {
Expand Down
Loading