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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ env:
jobs:
microkernel:
uses: ./.github/workflows/core-protocol.yml
with:
split_rust_targets: true
web:
name: Web checks and production build
runs-on: ubuntu-24.04
Expand Down
39 changes: 28 additions & 11 deletions .github/workflows/core-protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ name: Microkernel implementation checks
on:
workflow_dispatch:
workflow_call:
# ci.yml owns automatic push/PR runs so this expensive suite runs only once.
inputs:
split_rust_targets:
description: Run unit and integration targets on separate PostgreSQL services.
type: boolean
default: false
# Manual qualification keeps a single runner and the full Cargo target set.
permissions:
contents: read
defaults:
Expand All @@ -13,11 +18,17 @@ concurrency:
cancel-in-progress: true
jobs:
protocol:
name: ${{ matrix.targets == 'integration' && 'Rust integration targets' || 'protocol' }}
strategy:
fail-fast: false
matrix:
targets: ${{ fromJSON(inputs.split_rust_targets && '["unit","integration"]' || '["all"]') }}
runs-on: ubuntu-24.04
# Budget for cold builds, serial real PostgreSQL tests, and the following
# payment, Go, and RPC checks while keeping the complete job bounded.
timeout-minutes: 150
env:
RUST_TARGET_GROUP: ${{ matrix.targets }}
GOWORK: "off"
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432/postgres
CARGO_BUILD_JOBS: "2"
Expand Down Expand Up @@ -76,7 +87,7 @@ jobs:
- name: Preserve source before checks
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: microkernel-source-${{ github.sha }}-${{ github.run_id }}
name: microkernel-source-${{ github.sha }}-${{ github.run_id }}${{ matrix.targets == 'integration' && '-integration' || '' }}
path: |
${{ runner.temp }}/core-source.tar.gz
${{ runner.temp }}/core-source-sha.txt
Expand Down Expand Up @@ -196,7 +207,7 @@ jobs:
if: ${{ !cancelled() && steps.rust_test_compile.outcome == 'success' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: commerce-acceptance-driver-${{ github.sha }}-${{ github.run_id }}
name: commerce-acceptance-driver-${{ github.sha }}-${{ github.run_id }}${{ matrix.targets == 'integration' && '-integration' || '' }}
path: ${{ runner.temp }}/commerce-acceptance-driver
if-no-files-found: error
compression-level: 0
Expand Down Expand Up @@ -232,9 +243,15 @@ jobs:
LMM_PAYMENT_BOOTSTRAP_SHA256="$(sha256sum "$LMM_PAYMENT_BOOTSTRAP_BIN" | cut -d ' ' -f1)"
export LMM_PAYMENT_CORE_BIN LMM_PAYMENT_CORE_SHA256 LMM_PAYMENT_GO_BIN LMM_PAYMENT_GO_SHA256 LMM_PAYMENT_BOOTSTRAP_BIN LMM_PAYMENT_BOOTSTRAP_SHA256
# Emit panic diagnostics immediately, including when the job times out.
cargo test --locked --all-targets --no-fail-fast -- --skip synthetic_live_proof_crosses_core_go_processes_and_posts_once --nocapture 2>&1 | tee "$RUNNER_TEMP/core-tests.log"
case "$RUST_TARGET_GROUP" in
all) targets=(--all-targets) ;;
unit) targets=(--lib --bins --examples --benches) ;;
integration) targets=(--test '*') ;;
*) echo "Unknown Rust target group: $RUST_TARGET_GROUP" >&2; exit 1 ;;
esac
cargo test --locked "${targets[@]}" --no-fail-fast -- --skip synthetic_live_proof_crosses_core_go_processes_and_posts_once --nocapture 2>&1 | tee "$RUNNER_TEMP/core-tests.log"
- name: Repeat rejected event acknowledgement regression
if: ${{ !cancelled() && steps.rust_test_compile.outcome == 'success' }}
if: ${{ !cancelled() && matrix.targets != 'integration' && steps.rust_test_compile.outcome == 'success' }}
working-directory: services/core
run: |
for attempt in {1..10}; do
Expand All @@ -245,7 +262,7 @@ jobs:
if: ${{ !cancelled() }}
run: python3 -B scripts/ci-payment-live.py --output "$(realpath -m "$RUNNER_TEMP/payment-live")" 2>&1 | tee "$RUNNER_TEMP/payment-live-build.log"
- name: Go contract and race tests
if: ${{ !cancelled() }}
if: ${{ !cancelled() && matrix.targets != 'integration' }}
working-directory: services/extensions
run: |
bash ../../scripts/check-go-format.sh .
Expand All @@ -254,7 +271,7 @@ jobs:
go test -race ./... -count=1 -json | tee "$RUNNER_TEMP/extension-tests.jsonl"
CGO_ENABLED=0 go build -mod=readonly -trimpath -o "$RUNNER_TEMP/lmm-extensions" ./cmd/extensions
- name: Store and support real PostgreSQL acceptance
if: ${{ !cancelled() }}
if: ${{ !cancelled() && matrix.targets != 'integration' }}
env:
LMM_STORE_TEST_DSN: postgres://postgres:postgres@127.0.0.1:5432/lmm_store_test?sslmode=disable
run: |
Expand All @@ -265,13 +282,13 @@ jobs:
go vet -mod=readonly ./...
go test -mod=readonly -race -count=1 -json ./... | tee "$RUNNER_TEMP/store-postgres.jsonl"
- name: Durable cross-language event process recovery
if: ${{ !cancelled() }}
if: ${{ !cancelled() && matrix.targets != 'integration' }}
run: |
(cd services/core && cargo build --locked --example protocol-events-fixture)
(cd contracts/proto/tests/go && go vet -mod=readonly ./... && go build -mod=readonly -o "$RUNNER_TEMP/mk06-go-fixture" .)
MK06_GO_FIXTURE="$RUNNER_TEMP/mk06-go-fixture" python3 contracts/proto/tests/process_recovery.py 2>&1 | tee "$RUNNER_TEMP/events-process.log"
- name: Native protobuf round trips and failure recovery
if: ${{ !cancelled() }}
if: ${{ !cancelled() && matrix.targets != 'integration' }}
run: |
# Absolute, symlink-free, and absent: the fixture creates a private empty 0700 root.
evidence="$(realpath -m -- "$RUNNER_TEMP/core-rpc-docker-evidence")"
Expand All @@ -281,7 +298,7 @@ jobs:
fi
python3 -B scripts/test-core-rpc-docker.py --output-root "$evidence" --build-timeout-seconds 2400 2>&1 | tee "$RUNNER_TEMP/core-rpc-docker.log"
- name: Stage readable core RPC evidence
if: ${{ always() }}
if: ${{ always() && matrix.targets != 'integration' }}
run: |
# Secret files are chowned to container uid 65532 and mode 0400.
# upload-artifact fails the whole zip if any selected file is unreadable.
Expand Down Expand Up @@ -313,7 +330,7 @@ jobs:
if: ${{ always() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: microkernel-checks-${{ github.sha }}-${{ github.run_id }}
name: microkernel-checks-${{ github.sha }}-${{ github.run_id }}${{ matrix.targets == 'integration' && '-integration' || '' }}
path: |
${{ runner.temp }}/core-source-sha.txt
${{ runner.temp }}/core-format.log
Expand Down
38 changes: 32 additions & 6 deletions .github/workflows/linux-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ jobs:
git rev-parse HEAD | tee out/evidence/revision.txt
nfpm --version | tee out/evidence/nfpm-version.txt
node --test scripts/workflow-topology.test.mjs
python3 -B packaging/linux/test_extore_receipts.py
python3 -B packaging/linux/test_native.py -v 2>&1 | tee out/evidence/native-tests.log
go run github.com/rhysd/actionlint/cmd/actionlint@v1.7.12 -color .github/workflows/linux-packages.yml
- name: Build the three product binaries for this architecture
Expand All @@ -99,6 +100,7 @@ jobs:
docker buildx build --platform "linux/$ARCH" -f deployment/docker/extensions.Dockerfile \
--target binaries-musl --output type=local,dest=out/extensions-musl .
- name: Build verified source archives and native packages
id: packages
run: |
revision=$(git rev-parse HEAD)
SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD)
Expand All @@ -109,6 +111,7 @@ jobs:
done
python3 scripts/build-distribution.py build --component extensions \
--version 0.1.0-preview --revision "$revision" --platform "linux-musl-$ARCH" --input out/extensions-musl
package_paths=()
for component in core extensions cli; do
package="lmm-$component"
if [[ "$component" == cli ]]; then package=lmm; fi
Expand All @@ -118,12 +121,19 @@ jobs:
archive="out/distributions/${package}-0.1.0-preview-${platform}.tar.gz"
digest=$(sha256sum "$archive" | cut -d ' ' -f 1)
for release in 1 2; do
python3 packaging/linux/build.py --archive "$archive" --sha256 "$digest" \
--revision "$revision" --component "$component" --format "$format" --release "$release"
built=$(python3 packaging/linux/build.py --archive "$archive" --sha256 "$digest" \
--revision "$revision" --component "$component" --format "$format" --release "$release")
package_paths+=("$built" "$built.sha256" "$built.buildinfo.json")
done
done
done
(cd out/linux-packages && sha256sum --check ./*.sha256)
for path in "${package_paths[@]}"; do test -s "$path"; done
{
echo 'paths<<END_PACKAGES'
printf '%s\n' "${package_paths[@]}"
echo 'END_PACKAGES'
} >> "$GITHUB_OUTPUT"
- name: Install, upgrade, run and remove in disposable distribution containers
run: |
set -o pipefail
Expand Down Expand Up @@ -159,23 +169,39 @@ jobs:
-f packages/extore/tests/native_plugin_alpine.Dockerfile --target fixture \
--build-arg "EXTORE_RUST_TARGET=$RUST_TARGET" -t lmm-extore-alpine-fixture packages/extore
docker image inspect lmm-extore-alpine-fixture --format '{{.Id}}' > out/evidence/extore-fixture-image.txt
umask 077
staging=$(mktemp -d "$RUNNER_TEMP/extore-receipts.XXXXXXXX")
report=extore-native-alpine.json
touch "$staging/$report" "$staging/$report.package.json"
timeout 300 docker run --rm --network none --add-host localhost.localdomain:127.0.0.1 \
--cap-add NET_ADMIN --cpus 1 --memory 768m --pids-limit 256 \
--security-opt no-new-privileges:true -e LMM_PACKAGING_ISOLATED=1 \
-v "$PWD/out/linux-packages:/packages:ro" -v "$PWD/out/native-probe:/probe:ro" \
-v "$PWD/out/evidence:/evidence" \
-v "$staging/$report:/receipts/$report" \
-v "$staging/$report.package.json:/receipts/$report.package.json" \
-v "$PWD/packaging/linux/extore-plugin-smoke.py:/package-probe.py:ro" \
--entrypoint python3 lmm-extore-alpine-fixture /package-probe.py \
--arch "$ARCH" --revision "$(git rev-parse HEAD)" \
--parent-netns "$(readlink /proc/self/ns/net)" \
--report /evidence/extore-native-alpine.json 2>&1 | tee out/evidence/extore-native-alpine.log
--report "/receipts/$report" > "$staging/fixture.log" 2>&1
for receipt in "$staging/$report" "$staging/$report.package.json"; do
test -s "$receipt"
test -O "$receipt"
done
mv -- "$staging/$report" "$staging/$report.package.json" out/evidence/
- name: Preserve preview packages and scoped evidence, never publish
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: native-linux-${{ matrix.arch }}-${{ github.sha }}
path: |
out/linux-packages/
out/evidence/
${{ steps.packages.outputs.paths }}
out/evidence/revision.txt
out/evidence/nfpm-version.txt
out/evidence/install-matrix.txt
out/evidence/image-digests.txt
out/evidence/extore-fixture-image.txt
out/evidence/extore-native-alpine.json
out/evidence/extore-native-alpine.json.package.json
if-no-files-found: error
retention-days: 7
2 changes: 2 additions & 0 deletions .github/workflows/mk-01-identity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ jobs:
identity:
# All merged modules use the same preserved executors and private fixtures.
uses: ./.github/workflows/core-protocol.yml
with:
split_rust_targets: true
55 changes: 46 additions & 9 deletions packaging/linux/extore-plugin-smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,34 @@
import urllib.request


def probe_receipt(report, host_sha256, plugin_sha256):
"""Export only reviewed acceptance facts from the private probe report."""
def confirmed(actual, expected):
for key, value in expected.items():
if type(actual.get(key)) is not type(value) or actual[key] != value:
raise ValueError(f"unconfirmed native acceptance field: {key}")
return {key: actual[key] for key in expected}

receipt = confirmed(report, {
"status": "passed", "consumer_exit_code": 0,
"host_library_sha256": host_sha256, "plugin_library_sha256": plugin_sha256,
"actual_rust_health": True, "isolated_network_namespace": True,
"tls_certificate_verification": True, "authorized_catalog": True,
"cross_shop_http_detail_denied": True, "revoked_token_denied": True,
"catalog_calls_did_not_issue_cards": True, "actual_sqlite_grant_usage_recorded": True,
})
receipt["consumer"] = confirmed(report["consumer"], {
"status": "passed", "host_abi": 1, "interface": "extore.commerce",
"real_extore_https_sqlite": True, "native_digest_path_binding": True,
"native_repeated_open_call_release_close": True, "store_sync_persisted": True,
"http_catalog_fallback_calls": 0, "secret_values_logged": False,
"production_accounts_created": False,
"store_repository": "transactional memory test repository",
"core_authority": "existing Store test double; independent CoreSession acceptance not run",
})
return receipt


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--arch", choices=("amd64", "arm64"), required=True)
Expand Down Expand Up @@ -104,7 +132,12 @@ def main():
time.sleep(0.1)
if not ready:
raise RuntimeError("installed extensions did not start without native configuration")
if os.readlink(f"/proc/{process.pid}/exe") != "/usr/bin/lmm-extensions":
# Procfs checks credentials; container root cannot inspect another UID.
identity = subprocess.run(
["readlink", "-n", f"/proc/{process.pid}/exe"],
check=True, stdout=subprocess.PIPE, timeout=5, user=account.pw_uid,
group=account.pw_gid, extra_groups=[])
if identity.stdout != b"/usr/bin/lmm-extensions":
raise RuntimeError("default process is not the installed program")
finally:
process.terminate()
Expand All @@ -127,15 +160,19 @@ def main():
"service_uid": account.pw_uid, "service_gid": account.pw_gid,
"default_process_stopped": True,
}
with tempfile.TemporaryDirectory(prefix="extore-private-probe-") as directory:
private_report = Path(directory) / "probe.json"
command = [sys.executable, "/work/tests/native_plugin_probe.py",
"--inside-netns", "--parent-netns", args.parent_netns,
"--binary", "/opt/extore/extore-server",
"--host-library", host, "--plugin-library", plugin,
"--report", str(private_report), "--consumer", str(args.consumer),
"-test.run", "^TestNativePluginCatalogStore$", "-test.v"]
subprocess.run(command, check=True)
accepted = probe_receipt(json.loads(private_report.read_text()),
info["files"][host]["sha256"], info["files"][plugin]["sha256"])
args.report.write_text(json.dumps(accepted, indent=2) + "\n")
Path(str(args.report) + ".package.json").write_text(json.dumps(receipt, indent=2) + "\n")
command = [sys.executable, "/work/tests/native_plugin_probe.py",
"--inside-netns", "--parent-netns", args.parent_netns,
"--binary", "/opt/extore/extore-server",
"--host-library", "/usr/lib/lmm/extensions/extore/libextore_plugin_host.so",
"--plugin-library", "/usr/lib/lmm/extensions/extore/libextore_commerce_plugin.so",
"--report", str(args.report), "--consumer", str(args.consumer),
"-test.run", "^TestNativePluginCatalogStore$", "-test.v"]
subprocess.run(command, check=True)


if __name__ == "__main__":
Expand Down
47 changes: 47 additions & 0 deletions packaging/linux/test_extore_receipts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"""Check the upload boundary with synthetic private probe output."""
import runpy
import unittest
from pathlib import Path


probe_receipt = runpy.run_path(str(Path(__file__).with_name("extore-plugin-smoke.py")))["probe_receipt"]


class ProbeReceiptTests(unittest.TestCase):
def setUp(self):
self.host, self.plugin = "a" * 64, "b" * 64
self.consumer = {
"status": "passed", "host_abi": 1, "interface": "extore.commerce",
"real_extore_https_sqlite": True, "native_digest_path_binding": True,
"native_repeated_open_call_release_close": True, "store_sync_persisted": True,
"http_catalog_fallback_calls": 0, "secret_values_logged": False,
"production_accounts_created": False,
"store_repository": "transactional memory test repository",
"core_authority": "existing Store test double; independent CoreSession acceptance not run",
}
self.report = {
"status": "passed", "consumer_exit_code": 0, "consumer": self.consumer,
"host_library_sha256": self.host, "plugin_library_sha256": self.plugin,
"actual_rust_health": True, "isolated_network_namespace": True,
"tls_certificate_verification": True, "authorized_catalog": True,
"cross_shop_http_detail_denied": True, "revoked_token_denied": True,
"catalog_calls_did_not_issue_cards": True, "actual_sqlite_grant_usage_recorded": True,
}

def test_only_reviewed_fields_cross_the_boundary(self):
private = dict(self.report, stdout="private fixture output",
consumer=dict(self.consumer, credentials={"test": "private"}))
self.assertEqual(probe_receipt(private, self.host, self.plugin), self.report)

def test_incomplete_failed_or_mistyped_facts_cannot_be_exported(self):
missing = self.report.copy()
del missing["consumer_exit_code"]
for raw in [missing, dict(self.report, status="failed"), dict(self.report, consumer_exit_code=False),
dict(self.report, host_library_sha256=self.plugin),
dict(self.report, consumer=dict(self.consumer, core_authority="unreviewed text"))]:
with self.subTest(raw=raw), self.assertRaises(ValueError):
probe_receipt(raw, self.host, self.plugin)


if __name__ == "__main__":
unittest.main()
Loading