linghengqian commented on code in PR #21109: URL: https://github.com/apache/shardingsphere/pull/21109#discussion_r982497555
########## .github/workflows/native.yml: ########## @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +name: GraalVM Native Image Daily Continuous Integration + +on: + schedule: + - cron: '0 0 * * *' + +env: + HUB: ghcr.io/apache/shardingsphere + PROXY: ghcr.io/apache/shardingsphere-proxy-native + +jobs: + build: + if: github.repository == 'apache/shardingsphere' + timeout-minutes: 90 + permissions: + contents: read + packages: write + name: GraalVM Native Image on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + fail-fast: false + steps: + - uses: actions/checkout@v2 + - uses: graalvm/setup-graalvm@v1 + with: + version: '22.2.0' + java-version: '17' + components: 'native-image' + github-token: ${{ secrets.GITHUB_TOKEN }} + cache: 'maven' Review Comment: I think using the built-in caching option of graalvm/setup-graalvm@v1 is a good choice, as it seems reasonable behavior to separate its caching from the normal JVM. ########## shardingsphere-distribution/shardingsphere-proxy-distribution/pom.xml: ########## @@ -219,5 +226,199 @@ </plugins> </build> </profile> + <profile> + <id>native</id> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>${maven-compiler-plugin.version}</version> + <configuration> + <source>17</source> + <target>17</target> + <compilerArgument>--enable-preview</compilerArgument> + </configuration> + </plugin> + <plugin> + <groupId>org.graalvm.buildtools</groupId> + <artifactId>native-maven-plugin</artifactId> + <version>${native.maven.plugin.version}</version> + <extensions>true</extensions> + <executions> + <execution> + <id>build-native</id> + <goals> + <goal>compile-no-fork</goal> + </goals> + <phase>package</phase> + </execution> + <execution> + <id>test-native</id> + <goals> + <goal>test</goal> + </goals> + <phase>test</phase> + </execution> + </executions> + <configuration> + <imageName>${native.image.name}</imageName> + <mainClass>org.apache.shardingsphere.proxy.Bootstrap</mainClass> + <fallback>false</fallback> + <verbose>true</verbose> + <buildArgs> + <arg>--report-unsupported-elements-at-runtime</arg> + </buildArgs> + <jvmArgs> + <arg>--enable-preview</arg> + </jvmArgs> + <metadataRepository> + <enabled>true</enabled> + </metadataRepository> + </configuration> Review Comment: I have intentionally removed all configuration for GraalVM Native Image Agent because it seems rather cumbersome on Native Build Tools 0.9.14's Maven Plugin and also involves headaches for unit testing. . . I will open a new issue to track this issue after this PR is merged. ########## .github/workflows/native.yml: ########## @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +name: GraalVM Native Image Daily Continuous Integration + +on: + schedule: + - cron: '0 0 * * *' Review Comment: I just picked one between '0 0 * * *' and '0 19 */1 * *'. ########## shardingsphere-distribution/shardingsphere-proxy-distribution/pom.xml: ########## @@ -219,5 +226,199 @@ </plugins> </build> </profile> + <profile> + <id>native</id> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>${maven-compiler-plugin.version}</version> + <configuration> + <source>17</source> + <target>17</target> + <compilerArgument>--enable-preview</compilerArgument> Review Comment: I think turning on `--enable-preview` by default is a great choice, if someone wants to use GraalVM Native Image to test JDK19's Virtual Thread, they don't need to change much. ########## docs/document/content/user-manual/shardingsphere-proxy/startup/graalvm-native-image.cn.md: ########## @@ -0,0 +1,124 @@ ++++ +title = "构建 GraalVM Native Image(Alpha)" +weight = 2 ++++ + +## 背景信息 + +本节主要介绍如何通过 `GraalVM` 的 `native-image` 组件构建 ShardingSphere-Proxy 的 `Native Image` 和对应的 `Docker Image` +。 + +## 注意事项 + +- ShardingSphere Proxy 尚未准备好与 GraalVM Native Image 集成。 + 其在 https://github.com/apache/shardingsphere/actions/ 存在每日构建的任务用于测试构建。 Review Comment: Since I haven't pushed the actual Docker image yet, I plan to add ghcr.io information in another PR. ########## .github/workflows/native.yml: ########## @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +name: GraalVM Native Image Daily Continuous Integration + +on: + schedule: + - cron: '0 0 * * *' + +env: + HUB: ghcr.io/apache/shardingsphere + PROXY: ghcr.io/apache/shardingsphere-proxy-native + +jobs: + build: + if: github.repository == 'apache/shardingsphere' + timeout-minutes: 90 + permissions: + contents: read + packages: write + name: GraalVM Native Image on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] Review Comment: Just not sure if anyone thinks other OS's are needed, so there's an array object here. ########## .github/workflows/native.yml: ########## @@ -0,0 +1,56 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +name: GraalVM Native Image Daily Continuous Integration + +on: + schedule: + - cron: '0 0 * * *' + +env: + HUB: ghcr.io/apache/shardingsphere + PROXY: ghcr.io/apache/shardingsphere-proxy-native + +jobs: + build: + if: github.repository == 'apache/shardingsphere' + timeout-minutes: 90 Review Comment: Actually it didn't take so long, I was just trying to align the behavior of other GHA jobs ########## shardingsphere-distribution/shardingsphere-proxy-distribution/pom.xml: ########## @@ -219,5 +226,199 @@ </plugins> </build> </profile> + <profile> + <id>native</id> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>${maven-compiler-plugin.version}</version> + <configuration> + <source>17</source> + <target>17</target> + <compilerArgument>--enable-preview</compilerArgument> + </configuration> + </plugin> + <plugin> + <groupId>org.graalvm.buildtools</groupId> + <artifactId>native-maven-plugin</artifactId> + <version>${native.maven.plugin.version}</version> + <extensions>true</extensions> + <executions> + <execution> + <id>build-native</id> + <goals> + <goal>compile-no-fork</goal> + </goals> + <phase>package</phase> + </execution> + <execution> + <id>test-native</id> + <goals> + <goal>test</goal> + </goals> + <phase>test</phase> + </execution> + </executions> + <configuration> + <imageName>${native.image.name}</imageName> + <mainClass>org.apache.shardingsphere.proxy.Bootstrap</mainClass> + <fallback>false</fallback> + <verbose>true</verbose> + <buildArgs> + <arg>--report-unsupported-elements-at-runtime</arg> Review Comment: Delaying the time of reporting errors from the build stage to the first time they are accessed at runtime is helpful for the advancement of subsequent work, because IntelliJ IDEA Ultimate allows debugging in GraalVM Native Image, and the black box of Github Actions is too large . ########## docs/document/content/user-manual/shardingsphere-proxy/startup/graalvm-native-image.cn.md: ########## @@ -0,0 +1,124 @@ ++++ +title = "构建 GraalVM Native Image(Alpha)" +weight = 2 ++++ + +## 背景信息 + +本节主要介绍如何通过 `GraalVM` 的 `native-image` 组件构建 ShardingSphere-Proxy 的 `Native Image` 和对应的 `Docker Image` +。 + +## 注意事项 + +- ShardingSphere Proxy 尚未准备好与 GraalVM Native Image 集成。 + 其在 https://github.com/apache/shardingsphere/actions/ 存在每日构建的任务用于测试构建。 + +- 若你发现构建过程存在缺失的 GraalVM Reachability Metadata, + 应当在 https://github.com/oracle/graalvm-reachability-metadata 打开新的 issue , + 并提交包含 ShardingSphere 自身或依赖的第三方库缺失的 GraalVM Reachability Metadata 的 PR。 + +- ShardingSphere 的 master 分支尚未准备好处理 Native Image 中的单元测试, + 需要等待 Junit 5 Platform 的集成,你总是需要在构建 GraalVM Native Image 的过程中, + 加上特定于 `GraalVM Native Build Tools` 的 `-DskipNativeTests` 或 `-DskipTests` 参数跳过 Native Image 中的单元测试。 Review Comment: I will introduce Junit 5 in another issue, the related changes after combining with GraalVM Native Build Tools are too weird. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
