Skip to content
Open
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
27 changes: 27 additions & 0 deletions .github/workflows/zk-ticket-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,30 @@ jobs:
- name: Run SDK Jest
working-directory: sdk
run: npm test

zk-system-validation:
needs: resolve-issue-key
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: |
cd sdk && npm ci
cd ../

- name: Run ZK Wave 2 Validation
shell: bash
run: bash validate_zk_wave2.sh

- name: Artifact Hash Validation
shell: bash
run: |
echo "Validating artifact hashes..."
node scripts/validate_artifacts.mjs
44 changes: 44 additions & 0 deletions scripts/validate_artifacts.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import fs from 'fs';
import path from 'path';
import crypto from 'crypto';

const ARTIFACTS_DIR = 'artifacts';
const MANIFEST_PATH = 'artifacts/manifest.json';

function validateHashes() {
console.log('Starting artifact hash validation...');

if (!fs.existsSync(MANIFEST_PATH)) {
console.warn('Manifest not found, skipping deep validation.');
return;
}

const manifest = JSON.parse(fs.readFileSync(MANIFEST_PATH, 'utf8'));
let errors = 0;

for (const [file, expectedHash] of Object.entries(manifest.hashes)) {
const filePath = path.join(ARTIFACTS_DIR, file);
if (!fs.existsSync(filePath)) {
console.error(`Missing artifact: ${file}`);
errors++;
continue;
}

const content = fs.readFileSync(filePath);
const actualHash = crypto.createHash('sha256').update(content).digest('hex');

if (actualHash !== expectedHash) {
console.error(`Hash mismatch for ${file}: expected ${expectedHash}, got ${actualHash}`);
errors++;
} else {
console.log(`OK: ${file}`);
}
}

if (errors > 0) {
process.exit(1);
}
console.log('All artifacts validated successfully.');
}

validateHashes();