diff --git a/.github/workflows/run_examples.yml b/.github/workflows/run_examples.yml index e0e76042f..54815761b 100644 --- a/.github/workflows/run_examples.yml +++ b/.github/workflows/run_examples.yml @@ -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 @@ -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" \ No newline at end of file + mvn --batch-mode --no-transfer-progress --show-version clean compile + mvn exec:java -Dexec.mainClass="com.clickhouse.examples.jdbc.Basic" -DchPassword=secret -DfailOnError=true diff --git a/examples/jdbc/src/main/java/com/clickhouse/examples/jdbc/Basic.java b/examples/jdbc/src/main/java/com/clickhouse/examples/jdbc/Basic.java index ab3ce047c..65ad4cfda 100644 --- a/examples/jdbc/src/main/java/com/clickhouse/examples/jdbc/Basic.java +++ b/examples/jdbc/src/main/java/com/clickhouse/examples/jdbc/Basic.java @@ -21,7 +21,7 @@ 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 @@ -29,19 +29,15 @@ public static void main(String[] args) { 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 {