Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/actions/check-gradle-module/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,16 @@ runs:
- name: 🧪 Run Gradle Checks
id: checks
shell: bash
env:
MODULE: ${{ inputs.module }}
PARTITION: ${{ inputs.partition }}
run: |
echo "::group::Run Module Validation"
bash ./.github/scripts/run-gradle-module-checks.sh '${{ inputs.module }}' '${{ inputs.partition }}'
check_command=(bash ./.github/scripts/run-gradle-module-checks.sh "$MODULE" "$PARTITION")
if [[ "$MODULE" == game-design-service ]]; then
check_command=(timeout --kill-after=10s 30m "${check_command[@]}")
fi
"${check_command[@]}"
echo "::endgroup::"

- name: 📦 Build Runtime JAR
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,9 @@ jobs:
permissions:
contents: read
id-token: write
timeout-minutes: ${{ matrix.module == 'game-design-service' && 30 || 20 }}
# The composite keeps Game Design checks capped at 30 minutes. Reserve
# time for setup and required proof after a successful check.
timeout-minutes: ${{ matrix.module == 'game-design-service' && 35 || 20 }}
strategy:
fail-fast: false
matrix:
Expand Down
14 changes: 12 additions & 2 deletions dev-tools/tests/ci-lightweight-scope-contract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ for job_id, (output, module) in groups.items():
job = ci["jobs"][job_id]
name_module = module or "${{ matrix.module }}"
require_equal(job, ("name",), "Build and Test (" + name_module + " / ${{ matrix.partition }})", job_id)
timeout = "60" if module in ("account-service", "world-management-service") else "90" if module == "game-session-service" else "${{ matrix.module == 'game-design-service' && 30 || 20 }}"
timeout = "60" if module in ("account-service", "world-management-service") else "90" if module == "game-session-service" else "${{ matrix.module == 'game-design-service' && 35 || 20 }}"
require_equal(job, ("timeout-minutes",), timeout, job_id)
require_equal(job, ("needs",), ["changes"], job_id)
require_equal(job, ("strategy", "fail-fast"), "false", job_id)
Expand All @@ -625,11 +625,21 @@ for job_id, (output, module) in groups.items():
module_checks_step = find_step(
module_ci, "build-and-test", "Run Gradle Checks", "ci workflow"
)
require_equal(
module_checks_step,
("env",),
{"MODULE": "${{ matrix.module }}", "PARTITION": "${{ matrix.partition }}"},
"ci workflow",
)
require_equal(
module_checks_step,
("run",),
"echo \"::group::Run Module Validation\"\n"
"bash ./.github/scripts/run-gradle-module-checks.sh '${{ matrix.module }}' '${{ matrix.partition }}'\n"
"check_command=(bash ./.github/scripts/run-gradle-module-checks.sh \"$MODULE\" \"$PARTITION\")\n"
"if [[ \"$MODULE\" == game-design-service ]]; then\n"
" check_command=(timeout --kill-after=10s 30m \"${check_command[@]}\")\n"
"fi\n"
"\"${check_command[@]}\"\n"
"echo \"::endgroup::\"\n",
"ci workflow",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private Session() throws Exception {
Files.createDirectory(
temporaryDirectory.resolve("actual-final-pki-" + UUID.randomUUID()));
pki =
LoopbackMtlsTestPki.create(
LoopbackMtlsTestPki.createWithDirectSignedLeafRead(
pkiDirectory,
"Actual final composition test CA",
new LoopbackMtlsTestPki.IdentitySpec("account", ACCOUNT, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ private LoopbackMtlsTestPki() {}

public static Pki create(Path directory, String caCommonName, IdentitySpec... identities)
throws Exception {
return create(directory, caCommonName, false, identities);
}

/** Reads each freshly signed test leaf directly from its certificate output. */
public static Pki createWithDirectSignedLeafRead(
Path directory, String caCommonName, IdentitySpec... identities) throws Exception {
return create(directory, caCommonName, true, identities);
}

private static Pki create(
Path directory,
String caCommonName,
boolean readSignedLeafDirectly,
IdentitySpec... identities)
throws Exception {
Path caStore = directory.resolve("test-ca.p12");
keytool(
"-genkeypair",
Expand Down Expand Up @@ -69,8 +84,10 @@ public static Pki create(Path directory, String caCommonName, IdentitySpec... id
X509Certificate caCertificate = readCertificate(caFile);
var issued = new java.util.LinkedHashMap<String, Identity>();
for (IdentitySpec identity : identities) {
if (issued.putIfAbsent(identity.alias(), issueIdentity(directory, caStore, caFile, identity))
!= null) {
Identity material =
issueIdentity(
directory, caStore, caFile, caCertificate, identity, readSignedLeafDirectly);
if (issued.putIfAbsent(identity.alias(), material) != null) {
throw new IllegalArgumentException("duplicate test certificate alias: " + identity.alias());
}
}
Expand Down Expand Up @@ -159,7 +176,13 @@ public CommonGrpcClientProperties clientProperties(Path directory, Identity iden
}

private static Identity issueIdentity(
Path directory, Path caStore, Path caFile, IdentitySpec identity) throws Exception {
Path directory,
Path caStore,
Path caFile,
X509Certificate caCertificate,
IdentitySpec identity,
boolean readSignedLeafDirectly)
throws Exception {
String alias = identity.alias();
String san = "URI:" + identity.workloadUri() + ",DNS:localhost,IP:127.0.0.1";
Path store = directory.resolve(alias + ".p12");
Expand Down Expand Up @@ -230,39 +253,53 @@ private static Identity issueIdentity(
"EKU=" + (identity.server() ? "serverAuth" : "clientAuth"),
"-ext",
"SAN=" + san);
keytool(
"-importcert",
"-alias",
"test-ca",
"-keystore",
store.toString(),
"-storetype",
"PKCS12",
"-storepass",
STORE_PASSWORD,
"-file",
caFile.toString(),
"-noprompt");
keytool(
"-importcert",
"-alias",
alias,
"-keystore",
store.toString(),
"-storetype",
"PKCS12",
"-storepass",
STORE_PASSWORD,
"-file",
certificate.toString(),
"-noprompt");
if (!readSignedLeafDirectly) {
keytool(
"-importcert",
"-alias",
"test-ca",
"-keystore",
store.toString(),
"-storetype",
"PKCS12",
"-storepass",
STORE_PASSWORD,
"-file",
caFile.toString(),
"-noprompt");
keytool(
"-importcert",
"-alias",
alias,
"-keystore",
store.toString(),
"-storetype",
"PKCS12",
"-storepass",
STORE_PASSWORD,
"-file",
certificate.toString(),
"-noprompt");
}
KeyStore keyStore = KeyStore.getInstance("PKCS12");
try (var input = Files.newInputStream(store)) {
keyStore.load(input, STORE_PASSWORD.toCharArray());
}
return new Identity(
(PrivateKey) keyStore.getKey(alias, STORE_PASSWORD.toCharArray()),
(X509Certificate) keyStore.getCertificate(alias));
PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, STORE_PASSWORD.toCharArray());
X509Certificate storedCertificate = (X509Certificate) keyStore.getCertificate(alias);
if (!readSignedLeafDirectly) {
return new Identity(privateKey, storedCertificate);
}

X509Certificate signedLeaf = readCertificate(certificate);
if (privateKey == null
|| storedCertificate == null
|| !signedLeaf.getPublicKey().equals(storedCertificate.getPublicKey())) {
throw new GeneralSecurityException(
"Signed test leaf does not match generated keypair: " + alias);
}
signedLeaf.verify(caCertificate.getPublicKey());
return new Identity(privateKey, signedLeaf);
}

private static void keytool(String... arguments) throws Exception {
Expand Down
Loading