diff --git a/.github/workflows/zk-ticket-validation.yml b/.github/workflows/zk-ticket-validation.yml index 44a530c..0e361e5 100644 --- a/.github/workflows/zk-ticket-validation.yml +++ b/.github/workflows/zk-ticket-validation.yml @@ -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 diff --git a/scripts/validate_artifacts.mjs b/scripts/validate_artifacts.mjs new file mode 100644 index 0000000..d5bf1cc --- /dev/null +++ b/scripts/validate_artifacts.mjs @@ -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();