Add shared cluster credentials and readiness CI
ObjectStore CI / build (push) Successful in 10m22s

This commit is contained in:
admin committed 2026-11-16 03:41:32 +01:00
1 parent b724a21a0d
commit d73fa2c435
45 files changed
+2733 -226

No files matched your search

+17 -7
View File
@@ -6,20 +6,30 @@ A small, synchronous S3-compatible client built with the JDK alone. It uses path
Requires JDK 21 or newer. Building from source needs no Maven or Gradle, and the client has no third-party runtime dependencies.
For Maven or Gradle consumers, release 0.0.8 is published as
`cloud.lunarsky:objectstore-client:0.0.8` at
`https://repo.lunarsky.cloud/`. See the [installation examples](https://docs.lunarsky.cloud/objectstore/v0.0.8/client/install).
This file and the generated Javadocs describe the current source. The hosted
[installation examples](https://docs.lunarsky.cloud/objectstore/v0.0.8/client/install)
and Maven package `cloud.lunarsky:objectstore-client:0.0.8` at
`https://repo.lunarsky.cloud/` are an older release. Build this checkout for the
current client; building locally does not publish a release.
```sh
bash client/scripts/test.sh
bash client/scripts/build.sh
python3 client/scripts/test-packaging.py
```
Run these commands from the ObjectStore repository root. The second command writes `client/dist/objectstore-client.jar` and `client/dist/javadoc/`.
Run these commands from the ObjectStore repository root. The build writes `client/dist/objectstore-client.jar` and `client/dist/javadoc/`, replacing stale classes and documentation. The JAR includes the MIT license and an `Implementation-Version` matching the service's `Version.java`. The optional packaging test requires Python 3 and builds twice in a temporary directory.
To assemble a versioned Maven directory from a matching source tag, run
`bash client/scripts/build-maven-repo.sh VERSION`. It writes the JAR, POM,
sources, Javadocs, metadata, and checksums under `client/dist/maven-repo/`.
To assemble a local Maven repository, run:
```sh
bash client/scripts/build-maven-repo.sh
```
It derives the version from this checkout and writes the JAR, POM, sources,
Javadocs, metadata, and checksums under `client/dist/maven-repo/`. An optional
version argument must match the source; the script refuses to label current code
as another release. To build an older release, check out its source tag first.
The [AWT image manager](examples/README.md) is a small drag-and-drop app for trying uploads, listing, previews, downloads, and deletes against an existing bucket.
+15 -15
View File
@@ -1,26 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail
version="${1:?usage: build-maven-repo.sh VERSION}"
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][A-Za-z0-9]+)*$ ]]; then
echo "Invalid version: $version" >&2
exit 1
fi
cd "$(dirname "$0")/.."
bash scripts/build.sh
version="$(bash scripts/version.sh "$@")"
bash scripts/build.sh "$version"
artifact_root="dist/maven-repo/cloud/lunarsky/objectstore-client"
version_dir="$artifact_root/$version"
mkdir -p "$version_dir"
mkdir -p "$artifact_root"
staging="$(mktemp -d "$artifact_root/.packaging-XXXXXX")"
trap 'rm -rf "$staging"' EXIT
base="objectstore-client-$version"
cp dist/objectstore-client.jar "$version_dir/$base.jar"
jar --create --file "$version_dir/$base-sources.jar" \
cp dist/objectstore-client.jar "$staging/$base.jar"
jar --create --file "$staging/$base-sources.jar" --manifest dist/MANIFEST.MF \
-C src/main/java . -C dist/classes META-INF/LICENSE
jar --create --file "$version_dir/$base-javadoc.jar" \
jar --create --file "$staging/$base-javadoc.jar" --manifest dist/MANIFEST.MF \
-C dist/javadoc . -C dist/classes META-INF/LICENSE
cat > "$version_dir/$base.pom" <<EOF
cat > "$staging/$base.pom" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -48,7 +45,10 @@ cat > "$version_dir/$base.pom" <<EOF
</project>
EOF
mapfile -t versions < <(find "$artifact_root" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort -V)
rm -rf "$version_dir"
mv "$staging" "$version_dir"
mapfile -t versions < <(find "$artifact_root" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' |
grep -E '^[0-9]+\.[0-9]+\.[0-9]+([.-][A-Za-z0-9]+)*$' | sort -V)
latest="${versions[${#versions[@]}-1]}"
{
printf '%s\n' '<?xml version="1.0" encoding="UTF-8"?>' '<metadata>'
@@ -58,8 +58,8 @@ latest="${versions[${#versions[@]}-1]}"
printf ' </versions>\n <lastUpdated>%s</lastUpdated>\n </versioning>\n</metadata>\n' "$(date -u +%Y%m%d%H%M%S)"
} > "$artifact_root/maven-metadata.xml"
for file in "$version_dir"/* "$artifact_root/maven-metadata.xml"; do
[[ "$file" == *.md5 || "$file" == *.sha1 || "$file" == *.sha256 ]] && continue
for file in "$version_dir/$base.jar" "$version_dir/$base-sources.jar" \
"$version_dir/$base-javadoc.jar" "$version_dir/$base.pom" "$artifact_root/maven-metadata.xml"; do
md5sum "$file" | cut -d ' ' -f 1 > "$file.md5"
sha1sum "$file" | cut -d ' ' -f 1 > "$file.sha1"
sha256sum "$file" | cut -d ' ' -f 1 > "$file.sha256"
+16 -8
View File
@@ -1,13 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
rm -rf dist/classes
mkdir -p dist/classes
version="$(bash scripts/version.sh "$@")"
build_dir="$(mktemp -d)"
trap 'rm -rf "$build_dir"' EXIT
mkdir -p "$build_dir/classes/META-INF"
find src/main/java -name '*.java' -print0 |
xargs -0 javac --release 21 -d dist/classes
mkdir -p dist/classes/META-INF
cp ../LICENSE dist/classes/META-INF/LICENSE
jar --create --file dist/objectstore-client.jar -C dist/classes .
javadoc --release 21 -quiet -Xdoclint:reference,syntax,html -d dist/javadoc \
xargs -0 javac --release 21 -d "$build_dir/classes"
cp ../LICENSE "$build_dir/classes/META-INF/LICENSE"
printf 'Manifest-Version: 1.0\nImplementation-Title: ObjectStore Java client\nImplementation-Version: %s\n\n' \
"$version" > "$build_dir/MANIFEST.MF"
jar --create --file "$build_dir/objectstore-client.jar" --manifest "$build_dir/MANIFEST.MF" \
-C "$build_dir/classes" .
javadoc --release 21 -quiet -Xdoclint:reference,syntax,html -d "$build_dir/javadoc" \
$(find src/main/java -name '*.java' -print)
echo "Built dist/objectstore-client.jar"
mkdir -p dist
rm -rf dist/classes dist/javadoc
mv "$build_dir/classes" "$build_dir/javadoc" "$build_dir/MANIFEST.MF" \
"$build_dir/objectstore-client.jar" dist/
echo "Built dist/objectstore-client.jar ($version)"
+101
View File
@@ -0,0 +1,101 @@
#!/usr/bin/env python3
import hashlib
import re
import shutil
import subprocess
import tempfile
import xml.etree.ElementTree as ET
import zipfile
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
def run(root, *command, success=True):
result = subprocess.run(command, cwd=root, capture_output=True, text=True, timeout=120)
if (result.returncode == 0) != success:
raise AssertionError(f"Unexpected exit {result.returncode}: {command}\n"
f"{result.stdout}\n{result.stderr}")
return result
def check_archives(root, version):
dist = root / "client/dist"
artifact = dist / "maven-repo/cloud/lunarsky/objectstore-client"
version_dir = artifact / version
base = f"objectstore-client-{version}"
license_text = (root / "LICENSE").read_bytes()
for suffix in ("", "-sources", "-javadoc"):
with zipfile.ZipFile(version_dir / f"{base}{suffix}.jar") as archive:
manifest = archive.read("META-INF/MANIFEST.MF").decode()
assert f"Implementation-Version: {version}\r\n" in manifest
assert archive.read("META-INF/LICENSE") == license_text
assert not any("Stale" in name for name in archive.namelist())
namespace = {"m": "http://maven.apache.org/POM/4.0.0"}
pom = ET.parse(version_dir / f"{base}.pom")
assert pom.findtext("m:version", namespaces=namespace) == version
metadata = ET.parse(artifact / "maven-metadata.xml")
assert metadata.findtext("versioning/latest") == version
assert metadata.findtext("versioning/release") == version
assert [item.text for item in metadata.findall("versioning/versions/version")] == [version]
assert not (dist / "classes/Stale.class").exists()
assert not (dist / "javadoc/Stale.html").exists()
assert len(list(version_dir.iterdir())) == 16
for primary in list(version_dir.glob("*.jar")) + list(version_dir.glob("*.pom")) + [
artifact / "maven-metadata.xml"]:
for algorithm in ("md5", "sha1", "sha256"):
digest = hashlib.new(algorithm, primary.read_bytes()).hexdigest()
assert Path(str(primary) + "." + algorithm).read_text().strip() == digest
return version_dir
def verify_runtime_version(root, version):
probe = root / "VersionCheck.java"
probe.write_text("""import cloud.lunarsky.objectstore.client.ObjectStorageClient;
class VersionCheck {
public static void main(String[] args) {
String version = ObjectStorageClient.class.getPackage().getImplementationVersion();
if (!args[0].equals(version)) throw new AssertionError(version);
}
}
""")
jar = "client/dist/objectstore-client.jar"
run(root, "javac", "--release", "21", "-cp", jar, str(probe))
run(root, "java", "-cp", f"{jar}:{root}", "VersionCheck", version)
def exercise(root):
source_version = (root / "src/cloud/lunarsky/store/Version.java").read_text()
version = re.search(r'String VALUE = "([^"]+)"', source_version)[1]
for script in ("build.sh", "build-maven-repo.sh"):
result = run(root, "bash", f"client/scripts/{script}", "999.999.999", success=False)
assert "does not match source version" in result.stderr
assert not (root / "client/dist").exists()
for file in ("classes/Stale.class", "javadoc/Stale.html"):
target = root / "client/dist" / file
target.parent.mkdir(parents=True, exist_ok=True)
target.write_text("stale")
run(root, "bash", "client/scripts/build-maven-repo.sh")
version_dir = check_archives(root, version)
(version_dir / "old.jar.sha1.sha1").write_text("stale checksum")
run(root, "bash", "client/scripts/build-maven-repo.sh", version)
check_archives(root, version)
verify_runtime_version(root, version)
print(f"Java {version} packaging tests passed: source version, manifests, licenses, clean rebuild, checksums")
def main():
with tempfile.TemporaryDirectory(prefix="objectstore-packaging-") as directory:
root = Path(directory)
for folder in ("client/src/main/java", "client/scripts"):
shutil.copytree(ROOT / folder, root / folder)
target = root / "src/cloud/lunarsky/store"
target.mkdir(parents=True)
shutil.copy(ROOT / "src/cloud/lunarsky/store/Version.java", target)
shutil.copy(ROOT / "LICENSE", root)
exercise(root)
if __name__ == "__main__":
main()
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail
if (( $# > 1 )); then
echo "usage: version.sh [VERSION]" >&2
exit 1
fi
version_file="$(dirname "$0")/../../src/cloud/lunarsky/store/Version.java"
version="$(sed -nE 's/^[[:space:]]*static final String VALUE = "([^"]+)";[[:space:]]*$/\1/p' "$version_file")"
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][A-Za-z0-9]+)*$ ]]; then
echo "Cannot determine the source version from Version.java" >&2
exit 1
fi
if [[ -n "${1:-}" && "$1" != "$version" ]]; then
echo "Requested version $1 does not match source version $version; build from the matching source tag" >&2
exit 1
fi
printf '%s\n' "$version"