Skip to content

Commit c6a8e1c

Browse files
committed
Update e2e tests
- Fix native configs for win in sample app. - Integrate spring-native with samples app. - Tweak e2e workflow to upload artifacts and some other generic changes. - Relates #401
1 parent 6d39c2b commit c6a8e1c

File tree

7 files changed

+727
-18
lines changed

7 files changed

+727
-18
lines changed

.github/workflows/e2e.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- nickname: linux
2020
os: ubuntu-latest
2121
graal: 22.0.0.2
22-
name: CI Native ${{ matrix.nickname }}
22+
name: E2E ${{ matrix.nickname }}
2323
steps:
2424
- uses: actions/checkout@v2
2525
- uses: actions/setup-java@v2
@@ -39,6 +39,14 @@ jobs:
3939
node-version: '14'
4040
- run: |
4141
./mvnw clean package -Pnative
42+
- uses: actions/upload-artifact@v2
43+
with:
44+
name: spring-shell-samples-${{ matrix.nickname }}
45+
retention-days: 1
46+
path: |
47+
spring-shell-samples/target/*.jar
48+
spring-shell-samples/target/spring-shell-samples
49+
spring-shell-samples/target/spring-shell-samples.exe
4250
- name: compile e2e module
4351
working-directory: e2e/spring-shell-e2e
4452
run: |

e2e/spring-shell-e2e-tests/src/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export const cliPath = path.resolve(cliPathRelative);
1313
export const jarPath = path.resolve(jarPathRelative);
1414
export const nativeDesc = 'native';
1515
export const jarDesc = 'jar';
16-
export const jarCommand = 'java';
16+
export const jarCommand = isWindows ? 'java.exe' : 'java';
1717
export const nativeCommand = cliPath;
1818
export const jarOptions = ['-jar', jarPath];
19-
export const waitForExpectDefaultTimeout = 10000;
20-
export const waitForExpectDefaultInterval = 100;
21-
export const testTimeout = 20000;
19+
export const waitForExpectDefaultTimeout = 30000;
20+
export const waitForExpectDefaultInterval = 2000;
21+
export const testTimeout = 100000;

spring-shell-samples/pom.xml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
<description>Examples of using Spring Shell 2</description>
1616

17+
<properties>
18+
<spring-native.version>0.11.1</spring-native.version>
19+
</properties>
20+
1721
<build>
1822
<plugins>
1923
<plugin>
@@ -37,17 +41,20 @@
3741
</dependency>
3842
<dependency>
3943
<groupId>org.springframework.shell</groupId>
40-
<artifactId>spring-shell-starter</artifactId>
44+
<artifactId>spring-shell-starter-jna</artifactId>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.springframework.experimental</groupId>
48+
<artifactId>spring-aot</artifactId>
49+
<version>${spring-native.version}</version>
50+
<optional>true</optional>
4151
</dependency>
4252
</dependencies>
4353

4454
<profiles>
4555
<profile>
4656
<id>native</id>
4757
<!-- needs GRAALVM_HOME to point to graal tools -->
48-
<properties>
49-
<spring-native.version>0.11.1</spring-native.version>
50-
</properties>
5158
<dependencies>
5259
<dependency>
5360
<groupId>org.springframework.experimental</groupId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.shell.samples.config;
17+
18+
import com.sun.jna.CallbackReference;
19+
import com.sun.jna.Native;
20+
import com.sun.jna.NativeLong;
21+
import com.sun.jna.Pointer;
22+
import com.sun.jna.Structure;
23+
import com.sun.jna.ptr.IntByReference;
24+
import com.sun.jna.ptr.PointerByReference;
25+
26+
import org.springframework.nativex.hint.FieldHint;
27+
import org.springframework.nativex.hint.JdkProxyHint;
28+
import org.springframework.nativex.hint.MethodHint;
29+
import org.springframework.nativex.hint.NativeHint;
30+
import org.springframework.nativex.hint.ResourceHint;
31+
import org.springframework.nativex.hint.TypeAccess;
32+
import org.springframework.nativex.hint.TypeHint;
33+
import org.springframework.nativex.type.NativeConfiguration;
34+
35+
@NativeHint(
36+
resources = {
37+
@ResourceHint(
38+
patterns = {
39+
"completion/.*",
40+
"template/.*.st",
41+
"org/springframework/shell/component/.*.stg",
42+
"com/sun/jna/win32-x86-64/jnidispatch.dll"
43+
}
44+
),
45+
},
46+
types = {
47+
@TypeHint(
48+
types = {
49+
CallbackReference.class, Native.class, NativeLong.class, PointerByReference.class, IntByReference.class
50+
},
51+
typeNames = { "com.sun.jna.Klass" },
52+
access = {
53+
TypeAccess.PUBLIC_CLASSES, TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.PUBLIC_FIELDS,
54+
TypeAccess.PUBLIC_METHODS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
55+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
56+
}
57+
),
58+
@TypeHint(
59+
types = Structure.class,
60+
fields = {
61+
@FieldHint( name = "memory", allowWrite = true),
62+
@FieldHint( name = "typeInfo")
63+
},
64+
methods = {
65+
@MethodHint( name = "newInstance", parameterTypes = { Class.class, Pointer.class }),
66+
@MethodHint( name = "newInstance", parameterTypes = { Class.class, long.class }),
67+
@MethodHint( name = "newInstance", parameterTypes = { Class.class })
68+
},
69+
access = {
70+
TypeAccess.PUBLIC_CLASSES, TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.PUBLIC_FIELDS,
71+
TypeAccess.PUBLIC_METHODS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
72+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
73+
}
74+
),
75+
@TypeHint(
76+
typeNames = "com.sun.jna.Structure$FFIType",
77+
access = {
78+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
79+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
80+
}
81+
),
82+
@TypeHint(
83+
typeNames = "com.sun.jna.Structure$FFIType$size_t",
84+
access = {
85+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
86+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
87+
}
88+
),
89+
@TypeHint(
90+
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$CHAR_INFO",
91+
access = {
92+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
93+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
94+
}
95+
),
96+
@TypeHint(
97+
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$CONSOLE_CURSOR_INFO",
98+
access = {
99+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
100+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
101+
}
102+
),
103+
@TypeHint(
104+
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$CONSOLE_SCREEN_BUFFER_INFO",
105+
access = {
106+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
107+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
108+
}
109+
),
110+
@TypeHint(
111+
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$COORD",
112+
access = {
113+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
114+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
115+
}
116+
),
117+
@TypeHint(
118+
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$INPUT_RECORD",
119+
access = {
120+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
121+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
122+
}
123+
),
124+
@TypeHint(
125+
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$INPUT_RECORD$EventUnion",
126+
access = {
127+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
128+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
129+
}
130+
),
131+
@TypeHint(
132+
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$KEY_EVENT_RECORD",
133+
access = {
134+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
135+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
136+
}
137+
),
138+
@TypeHint(
139+
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$MOUSE_EVENT_RECORD",
140+
access = {
141+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
142+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
143+
}
144+
),
145+
@TypeHint(
146+
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$WINDOW_BUFFER_SIZE_RECORD",
147+
access = {
148+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
149+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
150+
}
151+
),
152+
@TypeHint(
153+
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$MENU_EVENT_RECORD",
154+
access = {
155+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
156+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
157+
}
158+
),
159+
@TypeHint(
160+
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$FOCUS_EVENT_RECORD",
161+
access = {
162+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
163+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
164+
}
165+
),
166+
@TypeHint(
167+
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$SMALL_RECT",
168+
access = {
169+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
170+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
171+
}
172+
),
173+
@TypeHint(
174+
typeNames = "org.jline.terminal.impl.jna.win.Kernel32$UnionChar",
175+
access = {
176+
TypeAccess.PUBLIC_CONSTRUCTORS, TypeAccess.DECLARED_CLASSES, TypeAccess.DECLARED_CONSTRUCTORS,
177+
TypeAccess.DECLARED_FIELDS, TypeAccess.DECLARED_METHODS
178+
}
179+
)
180+
},
181+
jdkProxies = {
182+
@JdkProxyHint( typeNames = { "com.sun.jna.Library" }),
183+
@JdkProxyHint( typeNames = { "com.sun.jna.Callback" }),
184+
@JdkProxyHint( typeNames = { "org.jline.terminal.impl.jna.win.Kernel32" }),
185+
@JdkProxyHint( typeNames = { "org.jline.terminal.impl.jna.linux.CLibrary" })
186+
}
187+
)
188+
public class SpringShellNativeConfiguration implements NativeConfiguration {
189+
}

0 commit comments

Comments
 (0)