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