Skip to content

Commit c1c3073

Browse files
committed
chore: add container workflow
1 parent c3b6945 commit c1c3073

File tree

2 files changed

+120
-1
lines changed

2 files changed

+120
-1
lines changed

.github/workflows/build.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
outputs:
3939
version: ${{ steps.gradle-build.outputs.version }}
4040
artifact_name: ${{ steps.gradle-build.outputs.uberjar_name }}
41+
artifact_path: ${{ steps.gradle-build.outputs.uberjar_path }}
4142

4243
runs-on: ${{ matrix.os }}
4344
strategy:
@@ -151,4 +152,38 @@ jobs:
151152
${{ github.workspace }}/release-artifacts/**
152153
fail_on_unmatched_files: true
153154
env:
154-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156+
157+
container-build:
158+
name: Run Java app on OpenJDK
159+
runs-on: ubuntu-latest
160+
161+
strategy:
162+
fail-fast: true
163+
matrix:
164+
jdk: [ "17" ]
165+
166+
container:
167+
# openjdk:17-jdk-alpine
168+
image: openjdk:${{ matrix.jdk }}-slim-buster
169+
170+
steps:
171+
- name: Check out the source code
172+
uses: actions/checkout@v2
173+
174+
- name: Run Java App on OpenJDK ${{ matrix.jdk }} container image
175+
if: always()
176+
run: |
177+
java --show-version src/main/java/JavaApp.java
178+
env:
179+
RUNNER_CONTEXT: ${{ toJson(runner) }}
180+
181+
- name: Github Action Contexts
182+
run: |
183+
echo "$JOB_CONTEXT"
184+
echo "$STEPS_CONTEXT"
185+
echo "$RUNNER_CONTEXT"
186+
env:
187+
JOB_CONTEXT: ${{ toJson(job) }}
188+
STEPS_CONTEXT: ${{ toJson(steps) }}
189+
RUNNER_CONTEXT: ${{ toJson(runner) }}

src/main/java/JavaApp.java

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import static java.lang.System.out;
2+
3+
import java.io.File;
4+
import java.net.InetAddress;
5+
import java.nio.charset.Charset;
6+
import java.nio.charset.StandardCharsets;
7+
import java.security.KeyStore;
8+
import java.time.ZoneId;
9+
import java.util.Arrays;
10+
import java.util.HexFormat;
11+
import java.util.Locale;
12+
import javax.net.ssl.TrustManagerFactory;
13+
import javax.net.ssl.X509TrustManager;
14+
15+
public class JavaApp {
16+
17+
public static void main(String[] args) throws Exception {
18+
19+
final var lineSep = System.lineSeparator();
20+
21+
out.printf("%n✧✧✧✧✧ Processes ✧✧✧✧✧%n");
22+
var ps = ProcessHandle.allProcesses()
23+
.sorted(ProcessHandle::compareTo)
24+
.toList();
25+
ps.forEach(p -> {
26+
var pInfo = p.pid() + " : " + p.info();
27+
out.println(pInfo);
28+
});
29+
30+
out.printf("%n✧✧✧✧✧ Trust stores ✧✧✧✧✧%n");
31+
var tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
32+
tmf.init((KeyStore) null);
33+
var issuers = Arrays.stream(tmf.getTrustManagers()).flatMap(tm -> {
34+
var x509Tm = (X509TrustManager) tm;
35+
return Arrays.stream(x509Tm.getAcceptedIssuers());
36+
}).toList();
37+
issuers.forEach(cert -> out.println(cert.getIssuerX500Principal()));
38+
39+
out.printf("%n✧✧✧✧✧ Dns Resolution ✧✧✧✧✧%n");
40+
var dns = Arrays.stream(InetAddress.getAllByName("google.com")).toList();
41+
dns.forEach(out::println);
42+
43+
out.printf("%n✧✧✧✧✧ TimeZones ✧✧✧✧✧%n");
44+
var tz = ZoneId.getAvailableZoneIds();
45+
tz.forEach(out::println);
46+
47+
out.printf("%n✧✧✧✧✧ Charsets ✧✧✧✧✧%n");
48+
var cs = Charset.availableCharsets();
49+
cs.forEach((name, charSet) -> out.println(name + " : " + charSet));
50+
51+
out.printf("%n✧✧✧✧✧ System Locales ✧✧✧✧✧%n");
52+
var locales = Locale.getAvailableLocales();
53+
for (Locale locale : locales) {
54+
out.println(locale);
55+
}
56+
57+
out.printf("%n✧✧✧✧✧ Env Variables ✧✧✧✧✧%n");
58+
var env = System.getenv();
59+
env.forEach((k, v) -> out.println(k + " : " + v));
60+
61+
out.printf("%n✧✧✧✧✧ System Properties ✧✧✧✧✧%n");
62+
var props = System.getProperties();
63+
props.forEach((k, v) -> out.println(k + " : " + v));
64+
65+
var lineSepHex = HexFormat.of().formatHex(lineSep.getBytes(StandardCharsets.UTF_8));
66+
out.printf("%n✧✧✧✧✧ LineSeparator = %s%n", lineSepHex);
67+
out.printf("%n✧✧✧✧✧ File PathSeparator = %s%n", File.pathSeparator);
68+
69+
var stats = """
70+
+------------------------+
71+
| Processes : %5d |
72+
| Dns Addresses : %5d |
73+
| Trust Stores : %5d |
74+
| TimeZones : %5d |
75+
| CharSets : %5d |
76+
| Locales : %5d |
77+
| Env Vars : %5d |
78+
| Sys Props : %5d |
79+
+------------------------+
80+
""".formatted(ps.size(), dns.size(), issuers.size(), tz.size(), cs.size(),locales.length, env.size(),props.size());
81+
82+
out.println(stats);
83+
}
84+
}

0 commit comments

Comments
 (0)