Skip to content

Commit 6cbce88

Browse files
authored
Merge pull request #2403 from ClickHouse/ci_run_examples
Update run_examples.yml
2 parents 051e7e8 + c3c27bb commit 6cbce88

File tree

2 files changed

+30
-23
lines changed

2 files changed

+30
-23
lines changed

.github/workflows/run_examples.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
name: Examples
1+
name: Run Examples
22

33
on:
44
workflow_dispatch:
5-
inputs:
6-
version:
7-
description: "Release version"
8-
required: true
9-
5+
106
concurrency:
117
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.number || github.sha }}
128
cancel-in-progress: true
@@ -32,21 +28,36 @@ jobs:
3228
8
3329
21
3430
cache: "maven"
31+
- name: Save Repo Artifacts
32+
id: save-repo-artifacts
33+
uses: actions/cache/save@v4
34+
with:
35+
path: ~/.m2/repository/com/clickhouse
36+
key: ${{ github.run_id }}-ch-artifacts
3537
- name: Build and install libraries
3638
run: mvn --batch-mode --no-transfer-progress --show-version --strict-checksums --threads 2 -Dmaven.wagon.rto=30000 -Dj8 -DskipITs install
3739
- name: Compile examples
3840
run: |
3941
cd examples/jdbc
4042
mvn clean compile
43+
echo "Run Id ${{ github.run_id }}"
4144
run-examples:
4245
runs-on: ubuntu-latest
4346
timeout-minutes: 15
4447
name: Run Examples
48+
needs: compile
4549
steps:
46-
- name: Run Docker
50+
- name: Check out repository
51+
uses: actions/checkout@v4
52+
- name: Restore Repo Artifacts
53+
id: restore-repo-artifacts
54+
uses: actions/cache/restore@v4
55+
with:
56+
path: ~/.m2/repository/com/clickhouse
57+
key: ${{ github.run_id }}-ch-artifacts
58+
- name: Run Examples
4759
run: |
48-
docker run -d --name demo-service-db -e CLICKHOUSE_USER=default -e CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1 -e CLICKHOUSE_PASSWORD=secret\
49-
-p 8123:8123 clickhouse/clickhouse-server
60+
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
5061
cd examples/jdbc
51-
mvn
52-
mvn exec:java -Dexec.mainClass="com.clickhouse.examples.jdbc.Basic"
62+
mvn --batch-mode --no-transfer-progress --show-version clean compile
63+
mvn exec:java -Dexec.mainClass="com.clickhouse.examples.jdbc.Basic" -DchPassword=secret -DfailOnError=true

examples/jdbc/src/main/java/com/clickhouse/examples/jdbc/Basic.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,23 @@ public class Basic {
2121
private static final Logger log = LoggerFactory.getLogger(Basic.class);
2222
static final String TABLE_NAME = "jdbc_example_basic";
2323

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

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

32-
try {
33-
createTable(url, properties);
34-
insertDateWithPreparedStatement(url, properties);
35-
printInsertedData(url, properties);
32+
createTable(url, properties);
33+
insertDateWithPreparedStatement(url, properties);
34+
printInsertedData(url, properties);
3635

37-
//Customizing client settings
38-
setClientSettings(properties);
36+
//Customizing client settings
37+
setClientSettings(properties);
3938

40-
//Using HikariCP with ClickHouseDataSource
41-
usedPooledConnection(url, properties);
42-
} catch (SQLException e) {
43-
log.error("Error", e);
44-
}
39+
//Using HikariCP with ClickHouseDataSource
40+
usedPooledConnection(url, properties);
4541
}
4642

4743
static void createTable(String url, Properties properties) throws SQLException {

0 commit comments

Comments
 (0)