diff --git a/.github/generate-test-steps.js b/.github/generate-test-steps.js index 6d53c697..76332039 100644 --- a/.github/generate-test-steps.js +++ b/.github/generate-test-steps.js @@ -1,12 +1,16 @@ const { readdirSync, readFileSync, existsSync, statSync } = require('node:fs'); -const defaultSteps = { +const defaults = { javascript: { - preTest: ["npm install"], - test: ["npm test"], + tests: { + pre: ["npm install"], + command: ["npm test"] + }, }, kotlin: { - test: ["./gradlew connectedCheck"], + tests: { + command: ["./gradlew connectedCheck"], + } } } @@ -33,30 +37,32 @@ for (const language of readdirSync('.')) { const config = JSON.parse(readFileSync(directory + '/.tbd-example.json', 'utf8')); - var preTestCommands = defaultSteps[language].preTest + const entry = { + name: config.name || example, + directory: directory, + tests: {}, + misc: config.misc || {}, + }; + + var preTestCommands = defaults[language].tests ? defaults[language].tests.pre : null; if (config.tests && config.tests.pre) { preTestCommands = config.tests.pre; } if (preTestCommands) { - preTestCommands = formatCommands(preTestCommands); + entry.tests.pre = formatCommands(preTestCommands); } - var testCommands = defaultSteps[language].test + var testCommands = defaults[language].tests ? defaults[language].tests.command : null; if (config.tests && config.tests.command) { testCommands = [config.tests.command]; } else if (config.tests && config.tests.commands) { testCommands = config.tests.commands; } if (testCommands) { - testCommands = formatCommands(testCommands); + entry.tests.command = formatCommands(testCommands); } - examples.push({ - name: config.name || example, - directory: directory, - preTestCommands: preTestCommands, - testCommands: testCommands - }); + examples.push(entry); } if (examples.length > 0) { diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ac736c47..e82c899d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,13 +27,13 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version: '20.4.0' + node-version: ${{ matrix.example.misc.node-version || '20.4.0' }} - name: test setup - run: ${{ matrix.example.preTestCommands }} + run: ${{ matrix.example.tests.pre }} working-directory: ${{ matrix.example.directory }} - if: matrix.example.preTestCommands != null + if: matrix.example.tests.pre != null - name: test - run: ${{ matrix.example.testCommands }} + run: ${{ matrix.example.tests.command }} working-directory: ${{ matrix.example.directory }} kotlin: @@ -69,12 +69,12 @@ jobs: - name: Setup Android SDK uses: android-actions/setup-android@00854ea68c109d98c75d956347303bf7c45b0277 # v3.2.1 - name: test setup - run: ${{ matrix.example.preTestCommands }} + run: ${{ matrix.example.tests.pre }} working-directory: ${{ matrix.example.directory }} - if: matrix.example.preTestCommands != null + if: matrix.example.test.pre != null - name: test in android emulator uses: reactivecircus/android-emulator-runner@77986be26589807b8ebab3fde7bbf5c60dabec32 # v2.31.0 with: api-level: 29 - script: ${{ matrix.example.testCommands }} + script: ${{ matrix.example.tests.command }} working-directory: ${{ matrix.example.directory }} diff --git a/javascript/fan-club-credential/.tbd-example.json b/javascript/fan-club-credential/.tbd-example.json new file mode 100644 index 00000000..5aeb4848 --- /dev/null +++ b/javascript/fan-club-credential/.tbd-example.json @@ -0,0 +1,9 @@ +{ + "name": "Fan Club Credential", + "tests": { + "command": "node index.js" + }, + "misc": { + "node-version": "v22.2.0" + } +} diff --git a/javascript/fan-club-credential/index.js b/javascript/fan-club-credential/index.js index 7a38eadb..79a01f5d 100644 --- a/javascript/fan-club-credential/index.js +++ b/javascript/fan-club-credential/index.js @@ -93,6 +93,7 @@ try { const presentationResult = PresentationExchange.createPresentationFromCredentials({ vcJwts: [signedVcJwt], presentationDefinition: presentationDefinition }); console.log('\nPresentation Result: ' + JSON.stringify(presentationResult)); + /** * Storing a self signed VC in a DWN */ @@ -104,11 +105,10 @@ const userAgent = await Web5UserAgent.create(); if (await userAgent.firstLaunch()) { // The vault has not been initialized yet. await userAgent.initialize({ password: 'insecure-static-phrase' }); -} else { - // The vault is already initialized, so just unlock/start it. - await userAgent.start({ password: 'insecure-static-phrase' }); } +await userAgent.start({ password: 'insecure-static-phrase' }); + // Import Alice's DID as an agent-managed Identity. const identity = await userAgent.identity.import({ portableIdentity: {