fix failing lint and test errors

This commit is contained in:
ddivad195
2024-01-30 16:13:51 +00:00
committed by Edwin Sirko
parent 50e278b239
commit 6233cad2a5
11 changed files with 17 additions and 50 deletions
+3 -2
View File
@@ -2,9 +2,10 @@
_This action_ packages _your action_ as OCI artifacts and publishes it to the [GitHub Container registry](ghcr.io).
This allows your action to be consumed as an _immutable_ package even if a [semver](https://semver.org/) is specified in the consumer's workflow file.
This allows your action to be consumed as an _immutable_ package even if a [SemVer](https://semver.org/) is specified in the consumer's workflow file.
Your action workflow must be triggered on `release` as in the following example. The release's title must follow [semantic versioning](https://semver.org/). Then consumers of your action will then be able to specify the version, e.g., `- uses: your-name/your-action@v1.2.3` or even `- uses: your-name/your-action@v1`.
Your action workflow must be triggered on `release` as in the following example. The release's title must follow [semantic versioning](https://semver.org/).
Then consumers of your action will then be able to specify the version, e.g., `- uses: your-name/your-action@v1.2.3` or even `- uses: your-name/your-action@v1`.
## Usage
-1
View File
@@ -1,6 +1,5 @@
import * as fsHelper from '../src/fs-helper'
import * as fs from 'fs'
import * as path from 'path'
import * as os from 'os'
import { execSync } from 'child_process'
+3 -4
View File
@@ -12,7 +12,6 @@ let axiosHeadMock: jest.SpyInstance
const token = 'test-token'
const registry = new URL('https://ghcr.io')
const repository = 'test-org/test-repo'
const releaseId = 'test-release-id'
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 zipFile: fsHelper.FileMetadata = {
@@ -119,7 +118,7 @@ describe('publishOCIArtifact', () => {
if ((url as string).includes('manifest')) {
return {
status: 201,
headers: { 'Docker-Content-Digest': '1234567678' }
headers: { 'docker-content-digest': '1234567678' }
}
}
@@ -175,7 +174,7 @@ describe('publishOCIArtifact', () => {
if ((url as string).includes('manifest')) {
return {
status: 201,
headers: { 'Docker-Content-Digest': '1234567678' }
headers: { 'docker-content-digest': '1234567678' }
}
}
@@ -244,7 +243,7 @@ describe('publishOCIArtifact', () => {
if ((url as string).includes('manifest')) {
return {
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'
// Mock the GitHub Actions core library
let getInputMock: jest.SpyInstance
let setFailedMock: jest.SpyInstance
let setOutputMock: jest.SpyInstance
@@ -37,7 +36,6 @@ describe('run', () => {
jest.clearAllMocks()
// Core mocks
getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
@@ -113,7 +111,7 @@ describe('run', () => {
const invalidEvents = ['workflow_dispatch, pull_request, schedule']
for (const event of invalidEvents) {
github.context.eventName = event
await main.run('')
await main.run()
expect(setFailedMock).toHaveBeenCalledWith(
'This action can only be triggered by release events or tag push events.'
)
@@ -357,7 +355,7 @@ describe('run', () => {
publishOCIArtifactMock.mockImplementation(() => {
return {
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
@@ -39,7 +39,7 @@ runs:
- name: Generate Provenance Attestation
uses: github-early-access/generate-build-provenance@main
id: build-provenance
if: contains(github.server_url, 'github.com') || contains(github.server_url, 'ghe.com')
if: endsWith(github.server_url, 'github.com') || endsWith(github.server_url, 'ghe.com')
with:
subject-name: ${{github.repository}}_${{github.ref}}
subject-digest: ${{steps.publish.outputs.package-manifest-sha}}
+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
// Errors if the repo appears to not contain any action files, such as an action.yml file
function stageActionFiles(actionDir, targetDir) {
var actionYmlFound = false;
let actionYmlFound = false;
fs_extra_1.default.copySync(actionDir, targetDir, {
filter: (src, dest) => {
filter: (src) => {
const basename = path.basename(src);
if (basename === 'action.yml' || basename === 'action.yaml') {
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.
function parseSourceSemanticVersion() {
const event = github.context.eventName;
var semverTag = '';
let semverTag = '';
// Grab the raw tag
if (event === 'release')
semverTag = github.context.payload.release.tag_name;
-27
View File
@@ -1,27 +0,0 @@
#!/bin/bash
VERSION=$1
MESSAGE=$2
if [ -z "$VERSION" ]
then
echo "No version supplied"
exit 1
fi
if [ -z "$MESSAGE" ]
then
echo "No message supplied"
exit 1
fi
echo "Generating new version $VERSION with message $MESSAGE"
#sed -i '' -E 's/ddivad195\/publish-action-package\/package-and-publish.*$/ddivad195\/publish-action-package\/package-and-publish@'$VERSION'/g' action.yml
npm run bundle
git add .
git commit -m "$VERSION: $MESSAGE"
git push
git tag $VERSION
git push origin $VERSION
gh release create --repo ddivad195/publish-action-package --title $VERSION --notes $VERSION $VERSION
-3
View File
@@ -1,6 +1,3 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
export async function getRepositoryMetadata(
repository: 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
// Errors if the repo appears to not contain any action files, such as an action.yml file
export function stageActionFiles(actionDir: string, targetDir: string) {
var actionYmlFound = false
export function stageActionFiles(actionDir: string, targetDir: string): void {
let actionYmlFound = false
fsExtra.copySync(actionDir, targetDir, {
filter: (src: string, dest: string) => {
filter: (src: string) => {
const basename = path.basename(src)
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.
function parseSourceSemanticVersion(): semver.SemVer {
const event = github.context.eventName
var semverTag = ''
let semverTag = ''
// Grab the raw tag
if (event === 'release') semverTag = github.context.payload.release.tag_name