reinstate main tests

This commit is contained in:
Conor Sloan
2024-08-23 10:00:06 +01:00
parent da1f4d6352
commit e53d6ca2a2
5 changed files with 735 additions and 673 deletions
+667 -634
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="116" height="20" role="img" aria-label="Coverage: 58.55%"><title>Coverage: 58.55%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="116" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="53" height="20" fill="#e05d44"/><rect width="116" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="885" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">58.55%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">58.55%</text></g></svg> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="116" height="20" role="img" aria-label="Coverage: 77.28%"><title>Coverage: 77.28%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="116" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="53" height="20" fill="#e05d44"/><rect width="116" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="885" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">77.28%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">77.28%</text></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Generated Vendored
+35 -27
View File
@@ -106690,13 +106690,21 @@ async function uploadOCIImageManifest(token, registry, repository, manifest, blo
return uploadLayer(layer, blob, registry, repository, b64Token); return uploadLayer(layer, blob, registry, repository, b64Token);
}); });
await Promise.all(layerUploads); await Promise.all(layerUploads);
return await uploadManifest(JSON.stringify(manifest), manifest.mediaType, registry, repository, tag || manifestSHA, b64Token); const publishedDigest = await uploadManifest(JSON.stringify(manifest), manifest.mediaType, registry, repository, tag || manifestSHA, b64Token);
if (publishedDigest !== manifestSHA) {
throw new Error(`Digest mismatch. Expected ${manifestSHA}, got ${publishedDigest}.`);
}
return manifestSHA;
} }
async function uploadOCIIndexManifest(token, registry, repository, manifest, tag) { async function uploadOCIIndexManifest(token, registry, repository, manifest, tag) {
const b64Token = Buffer.from(token).toString('base64'); const b64Token = Buffer.from(token).toString('base64');
const manifestSHA = ociContainer.sha256Digest(manifest); const manifestSHA = ociContainer.sha256Digest(manifest);
core.info(`Uploading index manifest ${manifestSHA} with tag ${tag} to ${repository}.`); core.info(`Uploading index manifest ${manifestSHA} with tag ${tag} to ${repository}.`);
return await uploadManifest(JSON.stringify(manifest), manifest.mediaType, registry, repository, tag, b64Token); const publishedDigest = await uploadManifest(JSON.stringify(manifest), manifest.mediaType, registry, repository, tag, b64Token);
if (publishedDigest !== manifestSHA) {
throw new Error(`Digest mismatch. Expected ${manifestSHA}, got ${publishedDigest}.`);
}
return manifestSHA;
} }
async function uploadLayer(layer, data, registryURL, repository, b64Token) { async function uploadLayer(layer, data, registryURL, repository, b64Token) {
const checkExistsResponse = await fetchWithDebug(checkBlobEndpoint(registryURL, repository, layer.digest), { const checkExistsResponse = await fetchWithDebug(checkBlobEndpoint(registryURL, repository, layer.digest), {
@@ -107008,22 +107016,22 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.emptyConfigSha = exports.emptyConfigSize = exports.ociEmptyMediaType = void 0; exports.emptyConfigSha = exports.emptyConfigSize = exports.ociEmptyMediaType = exports.actionPackageReferrerTagAnnotationValue = exports.actionPackageAttestationAnnotationValue = exports.actionPackageAnnotationValue = exports.sigstoreBundleMediaType = exports.actionsPackageZipLayerMediaType = exports.actionsPackageTarLayerMediaType = exports.actionsPackageMediaType = exports.imageManifestMediaType = exports.imageIndexMediaType = void 0;
exports.createActionPackageManifest = createActionPackageManifest; exports.createActionPackageManifest = createActionPackageManifest;
exports.createSigstoreAttestationManifest = createSigstoreAttestationManifest; exports.createSigstoreAttestationManifest = createSigstoreAttestationManifest;
exports.createReferrerTagManifest = createReferrerTagManifest; exports.createReferrerTagManifest = createReferrerTagManifest;
exports.sha256Digest = sha256Digest; exports.sha256Digest = sha256Digest;
exports.sizeInBytes = sizeInBytes; exports.sizeInBytes = sizeInBytes;
const crypto = __importStar(__nccwpck_require__(6113)); const crypto = __importStar(__nccwpck_require__(6113));
const imageIndexMediaType = 'application/vnd.oci.image.index.v1+json'; exports.imageIndexMediaType = 'application/vnd.oci.image.index.v1+json';
const imageManifestMediaType = 'application/vnd.oci.image.manifest.v1+json'; exports.imageManifestMediaType = 'application/vnd.oci.image.manifest.v1+json';
const actionsPackageMediaType = 'application/vnd.github.actions.package.v1+json'; exports.actionsPackageMediaType = 'application/vnd.github.actions.package.v1+json';
const actionsPackageTarLayerMediaType = 'application/vnd.github.actions.package.layer.v1.tar+gzip'; exports.actionsPackageTarLayerMediaType = 'application/vnd.github.actions.package.layer.v1.tar+gzip';
const actionsPackageZipLayerMediaType = 'application/vnd.github.actions.package.layer.v1.zip'; exports.actionsPackageZipLayerMediaType = 'application/vnd.github.actions.package.layer.v1.zip';
const sigstoreBundleMediaType = 'application/vnd.dev.sigstore.bundle.v0.3+json'; exports.sigstoreBundleMediaType = 'application/vnd.dev.sigstore.bundle.v0.3+json';
const actionPackageAnnotationValue = 'actions_oci_pkg'; exports.actionPackageAnnotationValue = 'actions_oci_pkg';
const actionPackageAttestationAnnotationValue = 'actions_oci_pkg_attestation'; exports.actionPackageAttestationAnnotationValue = 'actions_oci_pkg_attestation';
const actionPackageReferrerTagAnnotationValue = 'actions_oci_pkg_referrer_tag'; exports.actionPackageReferrerTagAnnotationValue = 'actions_oci_pkg_referrer_tag';
exports.ociEmptyMediaType = 'application/vnd.oci.empty.v1+json'; exports.ociEmptyMediaType = 'application/vnd.oci.empty.v1+json';
exports.emptyConfigSize = 2; exports.emptyConfigSize = 2;
exports.emptyConfigSha = 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a'; exports.emptyConfigSha = 'sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a';
@@ -107035,15 +107043,15 @@ function createActionPackageManifest(tarFile, zipFile, repository, repoId, owner
const zipLayer = createZipLayer(zipFile, sanitizedRepo, version); const zipLayer = createZipLayer(zipFile, sanitizedRepo, version);
const manifest = { const manifest = {
schemaVersion: 2, schemaVersion: 2,
mediaType: imageManifestMediaType, mediaType: exports.imageManifestMediaType,
artifactType: actionsPackageMediaType, artifactType: exports.actionsPackageMediaType,
config: configLayer, config: configLayer,
layers: [configLayer, tarLayer, zipLayer], layers: [configLayer, tarLayer, zipLayer],
annotations: { annotations: {
'org.opencontainers.image.created': created.toISOString(), 'org.opencontainers.image.created': created.toISOString(),
'action.tar.gz.digest': tarFile.sha256, 'action.tar.gz.digest': tarFile.sha256,
'action.zip.digest': zipFile.sha256, 'action.zip.digest': zipFile.sha256,
'com.github.package.type': actionPackageAnnotationValue, 'com.github.package.type': exports.actionPackageAnnotationValue,
'com.github.package.version': version, 'com.github.package.version': version,
'com.github.source.repo.id': repoId, 'com.github.source.repo.id': repoId,
'com.github.source.repo.owner.id': ownerId, 'com.github.source.repo.owner.id': ownerId,
@@ -107055,26 +107063,26 @@ function createActionPackageManifest(tarFile, zipFile, repository, repoId, owner
function createSigstoreAttestationManifest(bundleSize, bundleDigest, subjectSize, subjectDigest, created = new Date()) { function createSigstoreAttestationManifest(bundleSize, bundleDigest, subjectSize, subjectDigest, created = new Date()) {
const configLayer = createConfigLayer(); const configLayer = createConfigLayer();
const sigstoreAttestationLayer = { const sigstoreAttestationLayer = {
mediaType: sigstoreBundleMediaType, mediaType: exports.sigstoreBundleMediaType,
size: bundleSize, size: bundleSize,
digest: bundleDigest digest: bundleDigest
}; };
const subject = { const subject = {
mediaType: imageManifestMediaType, mediaType: exports.imageManifestMediaType,
size: subjectSize, size: subjectSize,
digest: subjectDigest digest: subjectDigest
}; };
const manifest = { const manifest = {
schemaVersion: 2, schemaVersion: 2,
mediaType: imageManifestMediaType, mediaType: exports.imageManifestMediaType,
artifactType: sigstoreBundleMediaType, artifactType: exports.sigstoreBundleMediaType,
config: configLayer, config: configLayer,
layers: [sigstoreAttestationLayer], layers: [sigstoreAttestationLayer],
subject, subject,
annotations: { annotations: {
'dev.sigstore.bundle.content': 'dsse-envelope', 'dev.sigstore.bundle.content': 'dsse-envelope',
'dev.sigstore.bundle.predicateType': 'https://slsa.dev/provenance/v1', 'dev.sigstore.bundle.predicateType': 'https://slsa.dev/provenance/v1',
'com.github.package.type': actionPackageAttestationAnnotationValue, 'com.github.package.type': exports.actionPackageAttestationAnnotationValue,
'org.opencontainers.image.created': created.toISOString() 'org.opencontainers.image.created': created.toISOString()
} }
}; };
@@ -107083,15 +107091,15 @@ function createSigstoreAttestationManifest(bundleSize, bundleDigest, subjectSize
function createReferrerTagManifest(attestationDigest, attestationSize, attestationCreated, created = new Date()) { function createReferrerTagManifest(attestationDigest, attestationSize, attestationCreated, created = new Date()) {
const manifest = { const manifest = {
schemaVersion: 2, schemaVersion: 2,
mediaType: imageIndexMediaType, mediaType: exports.imageIndexMediaType,
manifests: [ manifests: [
{ {
mediaType: imageManifestMediaType, mediaType: exports.imageManifestMediaType,
artifactType: sigstoreBundleMediaType, artifactType: exports.sigstoreBundleMediaType,
size: attestationSize, size: attestationSize,
digest: attestationDigest, digest: attestationDigest,
annotations: { annotations: {
'com.github.package.type': actionPackageAttestationAnnotationValue, 'com.github.package.type': exports.actionPackageAttestationAnnotationValue,
'org.opencontainers.image.created': attestationCreated.toISOString(), 'org.opencontainers.image.created': attestationCreated.toISOString(),
'dev.sigstore.bundle.content': 'dsse-envelope', 'dev.sigstore.bundle.content': 'dsse-envelope',
'dev.sigstore.bundle.predicateType': 'https://slsa.dev/provenance/v1' 'dev.sigstore.bundle.predicateType': 'https://slsa.dev/provenance/v1'
@@ -107099,7 +107107,7 @@ function createReferrerTagManifest(attestationDigest, attestationSize, attestati
} }
], ],
annotations: { annotations: {
'com.github.package.type': actionPackageReferrerTagAnnotationValue, 'com.github.package.type': exports.actionPackageReferrerTagAnnotationValue,
'org.opencontainers.image.created': created.toISOString() 'org.opencontainers.image.created': created.toISOString()
} }
}; };
@@ -107129,7 +107137,7 @@ function createConfigLayer() {
} }
function createZipLayer(zipFile, repository, version) { function createZipLayer(zipFile, repository, version) {
const zipLayer = { const zipLayer = {
mediaType: actionsPackageZipLayerMediaType, mediaType: exports.actionsPackageZipLayerMediaType,
size: zipFile.size, size: zipFile.size,
digest: zipFile.sha256, digest: zipFile.sha256,
annotations: { annotations: {
@@ -107140,7 +107148,7 @@ function createZipLayer(zipFile, repository, version) {
} }
function createTarLayer(tarFile, repository, version) { function createTarLayer(tarFile, repository, version) {
const tarLayer = { const tarLayer = {
mediaType: actionsPackageTarLayerMediaType, mediaType: exports.actionsPackageTarLayerMediaType,
size: tarFile.size, size: tarFile.size,
digest: tarFile.sha256, digest: tarFile.sha256,
annotations: { annotations: {
+18 -2
View File
@@ -30,7 +30,7 @@ export async function uploadOCIImageManifest(
await Promise.all(layerUploads) await Promise.all(layerUploads)
return await uploadManifest( const publishedDigest = await uploadManifest(
JSON.stringify(manifest), JSON.stringify(manifest),
manifest.mediaType, manifest.mediaType,
registry, registry,
@@ -38,6 +38,14 @@ export async function uploadOCIImageManifest(
tag || manifestSHA, tag || manifestSHA,
b64Token b64Token
) )
if (publishedDigest !== manifestSHA) {
throw new Error(
`Digest mismatch. Expected ${manifestSHA}, got ${publishedDigest}.`
)
}
return manifestSHA
} }
export async function uploadOCIIndexManifest( export async function uploadOCIIndexManifest(
@@ -54,7 +62,7 @@ export async function uploadOCIIndexManifest(
`Uploading index manifest ${manifestSHA} with tag ${tag} to ${repository}.` `Uploading index manifest ${manifestSHA} with tag ${tag} to ${repository}.`
) )
return await uploadManifest( const publishedDigest = await uploadManifest(
JSON.stringify(manifest), JSON.stringify(manifest),
manifest.mediaType, manifest.mediaType,
registry, registry,
@@ -62,6 +70,14 @@ export async function uploadOCIIndexManifest(
tag, tag,
b64Token b64Token
) )
if (publishedDigest !== manifestSHA) {
throw new Error(
`Digest mismatch. Expected ${manifestSHA}, got ${publishedDigest}.`
)
}
return manifestSHA
} }
async function uploadLayer( async function uploadLayer(
+14 -9
View File
@@ -1,18 +1,23 @@
import { FileMetadata } from './fs-helper' import { FileMetadata } from './fs-helper'
import * as crypto from 'crypto' import * as crypto from 'crypto'
const imageIndexMediaType = 'application/vnd.oci.image.index.v1+json' export const imageIndexMediaType = 'application/vnd.oci.image.index.v1+json'
const imageManifestMediaType = 'application/vnd.oci.image.manifest.v1+json' export const imageManifestMediaType =
const actionsPackageMediaType = 'application/vnd.github.actions.package.v1+json' 'application/vnd.oci.image.manifest.v1+json'
const actionsPackageTarLayerMediaType = export const actionsPackageMediaType =
'application/vnd.github.actions.package.v1+json'
export const actionsPackageTarLayerMediaType =
'application/vnd.github.actions.package.layer.v1.tar+gzip' 'application/vnd.github.actions.package.layer.v1.tar+gzip'
const actionsPackageZipLayerMediaType = export const actionsPackageZipLayerMediaType =
'application/vnd.github.actions.package.layer.v1.zip' 'application/vnd.github.actions.package.layer.v1.zip'
const sigstoreBundleMediaType = 'application/vnd.dev.sigstore.bundle.v0.3+json' export const sigstoreBundleMediaType =
'application/vnd.dev.sigstore.bundle.v0.3+json'
const actionPackageAnnotationValue = 'actions_oci_pkg' export const actionPackageAnnotationValue = 'actions_oci_pkg'
const actionPackageAttestationAnnotationValue = 'actions_oci_pkg_attestation' export const actionPackageAttestationAnnotationValue =
const actionPackageReferrerTagAnnotationValue = 'actions_oci_pkg_referrer_tag' 'actions_oci_pkg_attestation'
export const actionPackageReferrerTagAnnotationValue =
'actions_oci_pkg_referrer_tag'
export const ociEmptyMediaType = 'application/vnd.oci.empty.v1+json' export const ociEmptyMediaType = 'application/vnd.oci.empty.v1+json'
export const emptyConfigSize = 2 export const emptyConfigSize = 2