fix failing lint and test errors

This commit is contained in:
ddivad195
2024-01-30 16:13:51 +00:00
parent 06bd4f4498
commit 8d2cafe1d2
8 changed files with 13 additions and 20 deletions
-1
View File
@@ -1,6 +1,5 @@
import * as fsHelper from '../src/fs-helper' import * as fsHelper from '../src/fs-helper'
import * as fs from 'fs' import * as fs from 'fs'
import * as path from 'path'
import * as os from 'os' import * as os from 'os'
import { execSync } from 'child_process' import { execSync } from 'child_process'
+3 -4
View File
@@ -12,7 +12,6 @@ let axiosHeadMock: jest.SpyInstance
const token = 'test-token' const token = 'test-token'
const registry = new URL('https://ghcr.io') const registry = new URL('https://ghcr.io')
const repository = 'test-org/test-repo' const repository = 'test-org/test-repo'
const releaseId = 'test-release-id'
const semver = '1.2.3' const semver = '1.2.3'
const genericSha = '1234567890' // We should look at using different shas here to catch bug, but that make location validation harder const genericSha = '1234567890' // We should look at using different shas here to catch bug, but that make location validation harder
const zipFile: fsHelper.FileMetadata = { const zipFile: fsHelper.FileMetadata = {
@@ -119,7 +118,7 @@ describe('publishOCIArtifact', () => {
if ((url as string).includes('manifest')) { if ((url as string).includes('manifest')) {
return { return {
status: 201, status: 201,
headers: { 'Docker-Content-Digest': '1234567678' } headers: { 'docker-content-digest': '1234567678' }
} }
} }
@@ -175,7 +174,7 @@ describe('publishOCIArtifact', () => {
if ((url as string).includes('manifest')) { if ((url as string).includes('manifest')) {
return { return {
status: 201, status: 201,
headers: { 'Docker-Content-Digest': '1234567678' } headers: { 'docker-content-digest': '1234567678' }
} }
} }
@@ -244,7 +243,7 @@ describe('publishOCIArtifact', () => {
if ((url as string).includes('manifest')) { if ((url as string).includes('manifest')) {
return { return {
status: 201, status: 201,
headers: { 'Docker-Content-Digest': '1234567678' } headers: { 'docker-content-digest': '1234567678' }
} }
} }
+2 -4
View File
@@ -15,7 +15,6 @@ import * as ghcr from '../src/ghcr-client'
import * as api from '../src/api-client' import * as api from '../src/api-client'
// Mock the GitHub Actions core library // Mock the GitHub Actions core library
let getInputMock: jest.SpyInstance
let setFailedMock: jest.SpyInstance let setFailedMock: jest.SpyInstance
let setOutputMock: jest.SpyInstance let setOutputMock: jest.SpyInstance
@@ -37,7 +36,6 @@ describe('run', () => {
jest.clearAllMocks() jest.clearAllMocks()
// Core mocks // Core mocks
getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation() setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation() setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
@@ -113,7 +111,7 @@ describe('run', () => {
const invalidEvents = ['workflow_dispatch, pull_request, schedule'] const invalidEvents = ['workflow_dispatch, pull_request, schedule']
for (const event of invalidEvents) { for (const event of invalidEvents) {
github.context.eventName = event github.context.eventName = event
await main.run('') await main.run()
expect(setFailedMock).toHaveBeenCalledWith( expect(setFailedMock).toHaveBeenCalledWith(
'This action can only be triggered by release events or tag push events.' 'This action can only be triggered by release events or tag push events.'
) )
@@ -357,7 +355,7 @@ describe('run', () => {
publishOCIArtifactMock.mockImplementation(() => { publishOCIArtifactMock.mockImplementation(() => {
return { return {
packageURL: 'https://ghcr.io/v2/test-org/test-repo:1.2.3', packageURL: 'https://ghcr.io/v2/test-org/test-repo:1.2.3',
manifestDigest: 'my-test-digest' manifestDigest: 'sha256:my-test-digest'
} }
}) })
+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: 93.81%"><title>Coverage: 93.81%</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="#4c1"/><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">93.81%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">93.81%</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: 94.25%"><title>Coverage: 94.25%</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="#4c1"/><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">94.25%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">94.25%</text></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Generated Vendored
+3 -3
View File
@@ -74543,9 +74543,9 @@ exports.readFileContents = readFileContents;
// Copy actions files from sourceDir to targetDir, excluding files and folders not relevant to the action // Copy actions files from sourceDir to targetDir, excluding files and folders not relevant to the action
// Errors if the repo appears to not contain any action files, such as an action.yml file // Errors if the repo appears to not contain any action files, such as an action.yml file
function stageActionFiles(actionDir, targetDir) { function stageActionFiles(actionDir, targetDir) {
var actionYmlFound = false; let actionYmlFound = false;
fs_extra_1.default.copySync(actionDir, targetDir, { fs_extra_1.default.copySync(actionDir, targetDir, {
filter: (src, dest) => { filter: (src) => {
const basename = path.basename(src); const basename = path.basename(src);
if (basename === 'action.yml' || basename === 'action.yaml') { if (basename === 'action.yml' || basename === 'action.yaml') {
actionYmlFound = true; actionYmlFound = true;
@@ -74849,7 +74849,7 @@ exports.run = run;
// In each case, the source event should produce a Semantic Version compliant tag representing the code to be packaged. // In each case, the source event should produce a Semantic Version compliant tag representing the code to be packaged.
function parseSourceSemanticVersion() { function parseSourceSemanticVersion() {
const event = github.context.eventName; const event = github.context.eventName;
var semverTag = ''; let semverTag = '';
// Grab the raw tag // Grab the raw tag
if (event === 'release') if (event === 'release')
semverTag = github.context.payload.release.tag_name; semverTag = github.context.payload.release.tag_name;
-3
View File
@@ -1,6 +1,3 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
export async function getRepositoryMetadata( export async function getRepositoryMetadata(
repository: string, repository: string,
token: string token: string
+3 -3
View File
@@ -97,11 +97,11 @@ export function readFileContents(filePath: string): Buffer {
// Copy actions files from sourceDir to targetDir, excluding files and folders not relevant to the action // Copy actions files from sourceDir to targetDir, excluding files and folders not relevant to the action
// Errors if the repo appears to not contain any action files, such as an action.yml file // Errors if the repo appears to not contain any action files, such as an action.yml file
export function stageActionFiles(actionDir: string, targetDir: string) { export function stageActionFiles(actionDir: string, targetDir: string): void {
var actionYmlFound = false let actionYmlFound = false
fsExtra.copySync(actionDir, targetDir, { fsExtra.copySync(actionDir, targetDir, {
filter: (src: string, dest: string) => { filter: (src: string) => {
const basename = path.basename(src) const basename = path.basename(src)
if (basename === 'action.yml' || basename === 'action.yaml') { if (basename === 'action.yml' || basename === 'action.yaml') {
+1 -1
View File
@@ -96,7 +96,7 @@ export async function run(): Promise<void> {
// In each case, the source event should produce a Semantic Version compliant tag representing the code to be packaged. // In each case, the source event should produce a Semantic Version compliant tag representing the code to be packaged.
function parseSourceSemanticVersion(): semver.SemVer { function parseSourceSemanticVersion(): semver.SemVer {
const event = github.context.eventName const event = github.context.eventName
var semverTag = '' let semverTag = ''
// Grab the raw tag // Grab the raw tag
if (event === 'release') semverTag = github.context.payload.release.tag_name if (event === 'release') semverTag = github.context.payload.release.tag_name