diff --git a/.node-version b/.node-version index 1cc433a..9d5712a 100644 --- a/.node-version +++ b/.node-version @@ -1 +1,2 @@ 20.6.0 + diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index b9ce429..6785cdb 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -183,4 +183,27 @@ describe('main', () => { expect(outputs['predicate-type']).toBe('https://slsa.dev/provenance/v1') }) }) + + describe('when an error occurs during processing', () => { + beforeEach(() => { + process.env = { + ...originalEnv, + GITHUB_SERVER_URL: 'https://github.com', + GITHUB_REPOSITORY: 'owner/repo' + } + }) + + it('fails the workflow run', async () => { + jest.spyOn(core, 'getInput').mockImplementation((name) => { + if (name === 'subject-images') { + throw new Error('Test error') + } + return '' + }) + + await main.run() + + expect(setFailedMock).toHaveBeenCalledWith('Test error') + }) + }) }) diff --git a/src/main.ts b/src/main.ts index 184cafe..0cd3d75 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,6 +14,8 @@ export async function run(): Promise { for (const image of images) { core.info(`Processing image: ${image}`) // Add logic to process each image for attestation + // Assuming processImageForAttestation is a function that processes the image + await processImageForAttestation(image) } } @@ -28,3 +30,13 @@ export async function run(): Promise { core.setFailed(error.message) } } + +/** + * Processes an image for attestation. + * @param {string} image - The image to process. + * @returns {Promise} Resolves when the image is processed. + */ +async function processImageForAttestation(image: string): Promise { + // Add the actual logic to process the image for attestation + core.info(`Image ${image} processed for attestation`) +}