From 9abd3726cba711b0d40ec0cc7b6e44e776c0c40b Mon Sep 17 00:00:00 2001 From: phillip olesen Date: Wed, 13 May 2026 17:05:31 +0200 Subject: [PATCH] chore: ensure aligned daml version script Signed-off-by: phillip olesen --- .github/workflows/build.yml | 3 + package.json | 1 + scripts/src/verify-daml-release-version.ts | 98 ++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 scripts/src/verify-daml-release-version.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e33806c40..ba35bd047 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -195,6 +195,9 @@ jobs: - name: check open-rpc specs titles run: yarn script:openrpc:titles + - name: check daml release version alignment + run: yarn script:verify:daml-release-version + - name: prettier code run: yarn run prettier . --check diff --git a/package.json b/package.json index 058020791..acab2f396 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "script:fetch:canton": "tsx ./scripts/src/fetch-canton.ts", "script:fetch:splice": "tsx ./scripts/src/fetch-splice.ts", "script:fetch:localnet": "tsx ./scripts/src/fetch-localnet.ts", + "script:verify:daml-release-version": "tsx ./scripts/src/verify-daml-release-version.ts", "script:openrpc:titles": "tsx ./scripts/src/schema-title-validation.ts", "script:validate:package": "tsx ./scripts/src/package-and-verify-wallet-sdk.ts", "script:test:examples": "yarn node --trace-uncaught --enable-source-maps --import tsx ./scripts/src/test-example-scripts.ts", diff --git a/scripts/src/verify-daml-release-version.ts b/scripts/src/verify-daml-release-version.ts new file mode 100644 index 000000000..2c52a00f1 --- /dev/null +++ b/scripts/src/verify-daml-release-version.ts @@ -0,0 +1,98 @@ +// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import * as fs from 'fs' +import * as path from 'path' +import * as yaml from 'js-yaml' +import * as process from 'process' +import { + DAML_RELEASE_VERSION, + error, + getAllFilesWithExtension, + info, + repoRoot, + success, + warn, +} from './lib/utils.js' + +const DAMLJS_PATH = path.join(repoRoot, 'damljs') + +type DamlYaml = { + 'sdk-version'?: string +} + +function main() { + console.log( + info( + `Checking daml.yaml sdk-version values against DAML_RELEASE_VERSION=${DAML_RELEASE_VERSION}` + ) + ) + + const damlYamlFiles = getAllFilesWithExtension(DAMLJS_PATH, '.yaml').filter( + (filePath) => path.basename(filePath) === 'daml.yaml' + ) + + if (damlYamlFiles.length === 0) { + console.warn(warn(`No daml.yaml files found under ${DAMLJS_PATH}.`)) + return + } + + let mismatchCount = 0 + + for (const filePath of damlYamlFiles) { + const relativePath = path.relative(repoRoot, filePath) + + try { + const contents = fs.readFileSync(filePath, 'utf8') + const parsed = yaml.load(contents) as DamlYaml | null + const sdkVersion = parsed?.['sdk-version'] + + if (sdkVersion === undefined) { + console.log( + info( + `${relativePath}: sdk-version key is missing; skipping check for this file` + ) + ) + continue + } + + if (`${sdkVersion}` !== DAML_RELEASE_VERSION) { + console.error( + error( + `${relativePath}: sdk-version=${sdkVersion} does not match DAML_RELEASE_VERSION=${DAML_RELEASE_VERSION}` + ) + ) + mismatchCount++ + continue + } + + console.log( + success( + `${relativePath}: sdk-version=${sdkVersion} matches DAML_RELEASE_VERSION` + ) + ) + } catch (e) { + console.error( + error( + `${relativePath}: failed to parse daml.yaml (${e instanceof Error ? e.message : String(e)})` + ) + ) + mismatchCount++ + } + } + + if (mismatchCount > 0) { + console.log( + error( + `${mismatchCount} daml.yaml file(s) have sdk-version values that do not match DAML_RELEASE_VERSION=${DAML_RELEASE_VERSION}` + ) + ) + process.exit(1) + } + + console.log( + success('All daml.yaml files are aligned with DAML_RELEASE_VERSION.') + ) +} + +main()