Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hspiper 425/improve actions testing #233

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update dist folder
fix version parsing

current

removed vault check

update dist folder

# Conflicts:
#	dist/index.js.map

some refactor

initial

small refactor
valentincodes committed Jan 6, 2025

Verified

This commit was signed with the committer’s verified signature.
mcharriere Matías Charrière
commit 7b2644861ef218041b6ea2ac6a3c315a2fd36bb9
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ go*linux-amd64.tar.gz
.idea/
reports/
**/.DS_store
pnpm-lock.yaml
41,237 changes: 30,770 additions & 10,467 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

293 changes: 47 additions & 246 deletions dist/licenses.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions src/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Format for development versions (all parts required): 'devel:GH_OWNER:REPOSITORY:COMMITISH'
import fs from 'fs'
import { info } from '@actions/core'
import { downloadTool, extractZip } from '@actions/tool-cache'
import { chdir, cwd } from 'process'
import { join } from 'path'
import { exec } from '@actions/exec'
import { GITHUB_COM_SERVER_URL } from './github'

export async function buildPiperFromSource (version: string): Promise<string> {
const { owner, repository, commitISH } = parseDevelVersion(version)
const versionName = (() => {
if (!/^[0-9a-f]{7,40}$/.test(commitISH)) {
throw new Error('Can\'t resolve COMMITISH, use SHA or short SHA')
}
return commitISH.slice(0, 7)
})()
const path = `${process.cwd()}/${owner}-${repository}-${versionName}`
const piperPath = `${path}/piper`
if (fs.existsSync(piperPath)) {
return piperPath
}
// TODO
// check if cache is available
info(`Building Piper from ${version}`)
const url = `${GITHUB_COM_SERVER_URL}/${owner}/${repository}/archive/${commitISH}.zip`
info(`URL: ${url}`)
await extractZip(
await downloadTool(url, `${path}/source-code.zip`), `${path}`)
const wd = cwd()

const repositoryPath = join(path, fs.readdirSync(path).find((name: string) => {
return name.includes(repository)
}) ?? '')
chdir(repositoryPath)

const cgoEnabled = process.env.CGO_ENABLED
process.env.CGO_ENABLED = '0'
await exec(
'go build -o ../piper',
[
'-ldflags',
`-X github.com/SAP/jenkins-library/cmd.GitCommit=${commitISH}
-X github.com/SAP/jenkins-library/pkg/log.LibraryRepository=${GITHUB_COM_SERVER_URL}/${owner}/${repository}
-X github.com/SAP/jenkins-library/pkg/telemetry.LibraryRepository=${GITHUB_COM_SERVER_URL}/${owner}/${repository}`
]
)
process.env.CGO_ENABLED = cgoEnabled
chdir(wd)
fs.rmSync(repositoryPath, { recursive: true, force: true })
// TODO
// await download cache
return piperPath
}

export function parseDevelVersion (version: string): { env: string, owner: string, repository: string, commitISH: string } {
const versionComponents = version.split(':')
if (versionComponents.length !== 4 || versionComponents[0] !== 'devel') {
throw new Error('broken version')
}
const [env, owner, repository, commitISH] = versionComponents
return { env, owner, repository, commitISH }
}
14 changes: 5 additions & 9 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import {
STAGE_CONFIG,
getEnterpriseConfigUrl
} from './enterprise'
import type { ActionConfiguration } from './piper'
import { type ActionConfiguration } from './types'
import { internalActionVariables } from './piper'

export const CONFIG_DIR = '.pipeline'
@@ -21,25 +21,21 @@ export const ARTIFACT_NAME = 'Pipeline defaults'
export async function getDefaultConfig (server: string, apiURL: string, version: string, token: string, owner: string, repository: string, customDefaultsPaths: string): Promise<number> {
if (fs.existsSync(path.join(CONFIG_DIR, ENTERPRISE_DEFAULTS_FILENAME))) {
info('Defaults are present')
if (process.env.defaultsFlags !== undefined) {
debug(`Defaults flags: ${process.env.defaultsFlags}`)
} else {
debug('But no defaults flags available in the environment!')
}
return await Promise.resolve(0)
debug(process.env.defaultsFlags !== undefined ? `Defaults flags: ${process.env.defaultsFlags}` : 'But no defaults flags available in the environment!')
return 0
}

try {
await restoreDefaultConfig()
info('Defaults restored from artifact')
return await Promise.resolve(0)
return 0
} catch (err: unknown) {
// throws an error with message containing 'Unable to find' if artifact does not exist
if (err instanceof Error && !err.message.includes('Unable to find')) throw err
// continue with downloading defaults and upload as artifact
info('Downloading defaults')
await downloadDefaultConfig(server, apiURL, version, token, owner, repository, customDefaultsPaths)
return await Promise.resolve(0)
return 0
}
}

2 changes: 1 addition & 1 deletion src/docker.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { dirname } from 'path'
import { debug, info } from '@actions/core'
import { exec } from '@actions/exec'
import { v4 as uuidv4 } from 'uuid'
import type { ActionConfiguration } from './piper'
import { type ActionConfiguration } from './types'
import { createNetwork, parseDockerEnvVars, removeNetwork, startSidecar } from './sidecar'
import { internalActionVariables } from './piper'

19 changes: 9 additions & 10 deletions src/enterprise.ts
Original file line number Diff line number Diff line change
@@ -20,21 +20,20 @@ export function onGitHubEnterprise (): boolean {
}

export async function getEnterpriseConfigUrl (configType: string, apiURL: string, version: string, token: string, owner: string, repository: string): Promise<string> {
let assetname: string = ''
let filename: string = ''
if (configType !== DEFAULT_CONFIG && configType !== STAGE_CONFIG) {
return ''
}

if (configType === DEFAULT_CONFIG) {
assetname = ENTERPRISE_DEFAULTS_FILENAME_ON_RELEASE
filename = ENTERPRISE_DEFAULTS_FILENAME
} else if (configType === STAGE_CONFIG) {
assetname = ENTERPRISE_STAGE_CONFIG_FILENAME
let assetName: string = ENTERPRISE_DEFAULTS_FILENAME_ON_RELEASE
let filename: string = ENTERPRISE_DEFAULTS_FILENAME

if (configType === STAGE_CONFIG) {
assetName = ENTERPRISE_STAGE_CONFIG_FILENAME
filename = ENTERPRISE_STAGE_CONFIG_FILENAME
} else {
return ''
}

// get URL of defaults from the release (gh api, authenticated)
const [url] = await getReleaseAssetUrl(assetname, version, apiURL, token, owner, repository)
const [url] = await getReleaseAssetUrl(assetName, version, apiURL, token, owner, repository)
if (url !== '') return url
// fallback to get URL of defaults in the repository (unauthenticated)
return `${process.env.GITHUB_API_URL}/repos/${owner}/${repository}/contents/resources/${filename}`
39 changes: 17 additions & 22 deletions src/execute.ts
Original file line number Diff line number Diff line change
@@ -39,33 +39,28 @@ export async function executePiper (

const piperPath = internalActionVariables.piperBinPath
const containerID = internalActionVariables.dockerContainerID

if (containerID === '') {
return await exec(piperPath, [
stepName,
...flags
],
options)
.then(exitCode => {
return { output: piperOutput, error: piperError, exitCode }
})
.catch(err => {
throw new Error(`Piper execution error: ${err as string}: ${piperError}`)
})
} else {
return await exec('docker', [
'exec',
containerID,
`/piper/${path.basename(piperPath)}`,
stepName,
...flags
], options).then(exitCode => {
const args = [stepName, ...flags]
return await exec(piperPath, args, options)
.then(exitCode => { return { output: piperOutput, error: piperError, exitCode } })
.catch(err => { throw new Error(`Piper execution error: ${err as string}: ${piperError}`) })
}
// execute in docker container
const args = [
'exec',
containerID,
`/piper/${path.basename(piperPath)}`,
stepName,
...flags
]
return await exec('docker', args, options)
.then(exitCode => {
return {
output: piperOutput,
error: piperError,
exitCode
}
}).catch(err => {
throw new Error(`Piper execution error: ${err as string}: ${piperError}`)
})
}
.catch(err => { throw new Error(`Piper execution error: ${err as string}: ${piperError}`) })
}
2 changes: 1 addition & 1 deletion src/fetch.ts
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ export async function fetchRetry (url: string, method = 'GET', tries = 5, baseDe
await wait(delayTime)
}
}
return await Promise.reject(new Error(`Error fetching ${url}`))
throw new Error(`Error fetching ${url}`)
}

function isRetryable (code: number): boolean {
59 changes: 1 addition & 58 deletions src/github.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import * as fs from 'fs'
import { join } from 'path'
import { chdir, cwd } from 'process'
import { Octokit } from '@octokit/core'
import { type OctokitOptions } from '@octokit/core/dist-types/types'
import { type OctokitResponse } from '@octokit/types'
import { downloadTool, extractZip } from '@actions/tool-cache'
import { downloadTool } from '@actions/tool-cache'
import { debug, info } from '@actions/core'
import { exec } from '@actions/exec'
import { isEnterpriseStep } from './enterprise'
import { fetchRetry } from './fetch'

@@ -99,60 +96,6 @@ async function getPiperReleases (version: string, api: string, token: string, ow
return response
}

// Format for development versions (all parts required): 'devel:GH_OWNER:REPOSITORY:COMMITISH'
export async function buildPiperFromSource (version: string): Promise<string> {
const versionComponents = version.split(':')
if (versionComponents.length !== 4) {
throw new Error('broken version')
}
const
owner = versionComponents[1]
const repository = versionComponents[2]
const commitISH = versionComponents[3]
const versionName = (() => {
if (!/^[0-9a-f]{7,40}$/.test(commitISH)) {
throw new Error('Can\'t resolve COMMITISH, use SHA or short SHA')
}
return commitISH.slice(0, 7)
})()
const path = `${process.cwd()}/${owner}-${repository}-${versionName}`
const piperPath = `${path}/piper`
if (fs.existsSync(piperPath)) {
return piperPath
}
// TODO
// check if cache is available
info(`Building Piper from ${version}`)
const url = `${GITHUB_COM_SERVER_URL}/${owner}/${repository}/archive/${commitISH}.zip`
info(`URL: ${url}`)
await extractZip(
await downloadTool(url, `${path}/source-code.zip`), `${path}`)
const wd = cwd()

const repositoryPath = join(path, fs.readdirSync(path).find((name: string) => {
return name.includes(repository)
}) ?? '')
chdir(repositoryPath)

const cgoEnabled = process.env.CGO_ENABLED
process.env.CGO_ENABLED = '0'
await exec(
'go build -o ../piper',
[
'-ldflags',
`-X github.com/SAP/jenkins-library/cmd.GitCommit=${commitISH}
-X github.com/SAP/jenkins-library/pkg/log.LibraryRepository=${GITHUB_COM_SERVER_URL}/${owner}/${repository}
-X github.com/SAP/jenkins-library/pkg/telemetry.LibraryRepository=${GITHUB_COM_SERVER_URL}/${owner}/${repository}`
]
)
process.env.CGO_ENABLED = cgoEnabled
chdir(wd)
fs.rmSync(repositoryPath, { recursive: true, force: true })
// TODO
// await download cache
return piperPath
}

async function getPiperDownloadURL (piper: string, version?: string): Promise<string> {
const tagURL = `${GITHUB_COM_SERVER_URL}/SAP/jenkins-library/releases/${getTag(false, version)}`
const response = await fetchRetry(tagURL, 'HEAD').catch(async (err) => {
123 changes: 56 additions & 67 deletions src/piper.ts
Original file line number Diff line number Diff line change
@@ -4,15 +4,16 @@ import {
GITHUB_COM_SERVER_URL,
PIPER_OWNER,
PIPER_REPOSITORY,
buildPiperFromSource,
downloadPiperBinary
} from './github'
import { buildPiperFromSource } from './build'
import { chmodSync } from 'fs'
import { executePiper } from './execute'
import { getDefaultConfig, readContextConfig, createCheckIfStepActiveMaps } from './config'
import { loadPipelineEnv, exportPipelineEnv } from './pipelineEnv'
import { cleanupContainers, runContainers } from './docker'
import { isEnterpriseStep, onGitHubEnterprise } from './enterprise'
import { type ActionConfiguration } from './types'

// Global runtime variables that is accessible within a single action execution
export const internalActionVariables = {
@@ -23,9 +24,37 @@ export const internalActionVariables = {
}

export async function run (): Promise<void> {
// TODO: Where to put this check?
// try {
// const roleId = process.env.PIPER_VAULTAPPROLEID
// const secretId = process.env.PIPER_VAULTAPPSECRETID
//
// if (roleId === undefined || roleId === '') {
// setFailed('PIPER_VAULTAPPROLEID is not set. Please provide the Role ID to authenticate with Vault.')
// }
// if (secretId === undefined || secretId === '') {
// setFailed('PIPER_VAULTAPPSECRETID is not set. Please provide the Secret ID to authenticate with Vault.')
// }
// } catch (error: unknown) {
// setFailed((() => {
// if (error instanceof Error) {
// return error.message
// }
// return String(error)
// })())
// }

try {
const actionCfg = await getActionConfig({ required: false })
await preparePiperBinary(actionCfg)
const actionCfg: ActionConfiguration = await getActionConfig({ required: false })
const piperPath = await preparePiperBinary(actionCfg)

if (piperPath === undefined || piperPath === '') {
throw new Error('Piper binary path is empty. Please check your action inputs.')
}

internalActionVariables.piperBinPath = piperPath
debug('obtained piper binary at '.concat(piperPath))
chmodSync(piperPath, 0o775)

await loadPipelineEnv()
await executePiper('version')
@@ -62,85 +91,45 @@ export async function run (): Promise<void> {
}
}

async function preparePiperBinary (actionCfg: ActionConfiguration): Promise<void> {
let piperPath
if (isEnterpriseStep(actionCfg.stepName)) {
piperPath = await downloadPiperBinary(actionCfg.stepName, actionCfg.sapPiperVersion, actionCfg.gitHubEnterpriseApi, actionCfg.gitHubEnterpriseToken, actionCfg.sapPiperOwner, actionCfg.sapPiperRepo)
} else if (actionCfg.piperVersion.startsWith('devel:') && actionCfg.stepName !== '') {
piperPath = await buildPiperFromSource(actionCfg.piperVersion)
} else {
piperPath = await downloadPiperBinary(actionCfg.stepName, actionCfg.piperVersion, actionCfg.gitHubApi, actionCfg.gitHubToken, actionCfg.piperOwner, actionCfg.piperRepo)
async function preparePiperBinary (actionCfg: ActionConfiguration): Promise<string> {
if (actionCfg.piperVersion.startsWith('devel:')) {
if (isEnterpriseStep(actionCfg.stepName)) {
// TODO: build piper binary from source
throw new Error('Enterprise steps cannot be built from source')
}
// build piper binary from OS source
return await buildPiperFromSource(actionCfg.piperVersion)
}
if (piperPath === undefined || piperPath === '') {
throw new Error('Piper binary path is empty. Please check your action inputs.')
// download piper binary
if (isEnterpriseStep(actionCfg.stepName)) {
return await downloadPiperBinary(actionCfg.stepName, actionCfg.sapPiperVersion, actionCfg.gitHubEnterpriseApi, actionCfg.gitHubEnterpriseToken, actionCfg.sapPiperOwner, actionCfg.sapPiperRepo)
}

internalActionVariables.piperBinPath = piperPath
debug('obtained piper binary at '.concat(piperPath))
chmodSync(piperPath, 0o775)
return await downloadPiperBinary(actionCfg.stepName, actionCfg.piperVersion, actionCfg.gitHubApi, actionCfg.gitHubToken, actionCfg.piperOwner, actionCfg.piperRepo)
}

export interface ActionConfiguration {
stepName: string
flags: string
piperVersion: string
piperOwner: string
piperRepo: string
sapPiperVersion: string
sapPiperOwner: string
sapPiperRepo: string
gitHubServer: string
gitHubApi: string
gitHubToken: string
gitHubEnterpriseServer: string
gitHubEnterpriseApi: string
gitHubEnterpriseToken: string
dockerImage: string
dockerOptions: string
dockerEnvVars: string
sidecarImage: string
sidecarOptions: string
sidecarEnvVars: string
retrieveDefaultConfig: boolean
customDefaultsPaths: string
customStageConditionsPath: string
createCheckIfStepActiveMaps: boolean
exportPipelineEnvironment: boolean
function getEnvValue (param: string, defaultValue: string = ''): string {
// EnVs should be provided like this:
// PIPER_ACTION_DOWNLOAD_URL
return process.env[param] ?? defaultValue
}

async function getActionConfig (options: InputOptions): Promise<ActionConfiguration> {
const getValue = (param: string, defaultValue?: string): string => {
const getValue = (param: string, defaultValue: string = ''): string => {
let value: string = getInput(param, options)
if (value === '') {
// EnVs should be provided like this
// PIPER_ACTION_DOWNLOAD_URL
value = process.env[`PIPER_ACTION_${param.toUpperCase().replace(/-/g, '_')}`] ?? ''
if (value === '') {
if (defaultValue !== undefined) {
return defaultValue
}
return ''
}
value = getEnvValue(`PIPER_ACTION_${param.toUpperCase().replace(/-/g, '_')}`, defaultValue)
}
debug(`${param}: ${value}`)

if (value !== '') debug(`${param}: ${value}`)
return value
}
let enterpriseHost: string = ''
let enterpriseApi: string = ''
if (onGitHubEnterprise()) {
if (process.env.GITHUB_SERVER_URL !== undefined) {
enterpriseHost = process.env.GITHUB_SERVER_URL
}
if (process.env.GITHUB_API_URL !== undefined) {
enterpriseApi = process.env.GITHUB_API_URL
}
}

const enterpriseHost: string = onGitHubEnterprise() ? process.env.GITHUB_SERVER_URL ?? '' : ''
const enterpriseApi: string = onGitHubEnterprise() ? process.env.GITHUB_API_URL ?? '' : ''

let stepNameValue = getValue('step-name')
// TODO: remove command input
if (stepNameValue === undefined || stepNameValue === '') {
stepNameValue = getValue('command')
}
if (stepNameValue === '') stepNameValue = getValue('command')

return {
stepName: stepNameValue,
2 changes: 1 addition & 1 deletion src/sidecar.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import {
} from './docker'
import { v4 as uuidv4 } from 'uuid'
import { debug, info, warning } from '@actions/core'
import type { ActionConfiguration } from './piper'
import { type ActionConfiguration } from './types'
import { internalActionVariables } from './piper'

const NETWORK_PREFIX = 'sidecar-'
55 changes: 55 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Configuration for the GitHub Action.
*/
export interface ActionConfiguration {
/** The name of the step to execute. */
stepName: string
/** Additional flags for the step execution. */
flags: string
/** The version of Piper to use. */
piperVersion: string
/** The owner of the Piper repository. */
piperOwner: string
/** The name of the Piper repository. */
piperRepo: string
/** The version of SAP Piper to use. */
sapPiperVersion: string
/** The owner of the SAP Piper repository. */
sapPiperOwner: string
/** The name of the SAP Piper repository. */
sapPiperRepo: string
/** The GitHub server URL. */
gitHubServer: string
/** The GitHub API URL. */
gitHubApi: string
/** The GitHub token for authentication. */
gitHubToken: string
/** The GitHub Enterprise server URL. */
gitHubEnterpriseServer: string
/** The GitHub Enterprise API URL. */
gitHubEnterpriseApi: string
/** The GitHub Enterprise token for authentication. */
gitHubEnterpriseToken: string
/** The Docker image to use. */
dockerImage: string
/** Additional options for Docker. */
dockerOptions: string
/** Environment variables for Docker. */
dockerEnvVars: string
/** The sidecar Docker image to use. */
sidecarImage: string
/** Additional options for the sidecar container. */
sidecarOptions: string
/** Environment variables for the sidecar container. */
sidecarEnvVars: string
/** Whether to retrieve the default configuration. */
retrieveDefaultConfig: boolean
/** Custom paths for default configurations. */
customDefaultsPaths: string
/** Custom path for stage conditions. */
customStageConditionsPath: string
/** Whether to create maps for checking if a step is active. */
createCheckIfStepActiveMaps: boolean
/** Whether to export the pipeline environment. */
exportPipelineEnvironment: boolean
}
18 changes: 18 additions & 0 deletions test/build.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// src/build.test.ts
import { parseDevelVersion } from '../src/build'

describe('parseDevelVersion', () => {
it('should parse a valid version string', () => {
const version = 'devel:GH_OWNER:REPOSITORY:COMMITISH'
const { env, owner, repository, commitISH } = parseDevelVersion(version)
expect(env).toBe('devel')
expect(owner).toBe('GH_OWNER')
expect(repository).toBe('REPOSITORY')
expect(commitISH).toBe('COMMITISH')
})

it('should throw an error for an invalid version string', () => {
const version = 'invalid:version:string'
expect(() => parseDevelVersion(version)).toThrow('broken version')
})
})
2 changes: 1 addition & 1 deletion test/config.test.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import * as artifact from '@actions/artifact'
import * as config from '../src/config'
import * as execute from '../src/execute'
import * as github from '../src/github'
import type { ActionConfiguration } from '../src/piper'
import type { ActionConfiguration } from '../src/types'

jest.mock('@actions/exec')
jest.mock('@actions/tool-cache')
3 changes: 2 additions & 1 deletion test/docker.test.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@ import path from 'path'
import * as exec from '@actions/exec'
import * as core from '@actions/core'
import * as sidecar from '../src/sidecar'
import { type ActionConfiguration, internalActionVariables } from '../src/piper'
import { internalActionVariables } from '../src/piper'
import { type ActionConfiguration } from '../src/types'
import {
cleanupContainers,
getOrchestratorEnvVars,
3 changes: 2 additions & 1 deletion test/github.test.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@ import * as toolCache from '@actions/tool-cache'
import * as octokit from '@octokit/core'
import * as core from '@actions/core'

import { downloadPiperBinary, buildPiperFromSource } from '../src/github'
import { downloadPiperBinary } from '../src/github'
import { buildPiperFromSource } from '../src/build'

jest.mock('@actions/core')
jest.mock('@actions/exec')
5 changes: 3 additions & 2 deletions test/piper.test.ts
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import * as piper from '../src/piper'
import * as config from '../src/config'
import * as execute from '../src/execute'
import * as github from '../src/github'
import * as build from '../src/build'
import * as docker from '../src/docker'
import * as pipelineEnv from '../src/pipelineEnv'
import { GITHUB_COM_API_URL } from '../src/github'
@@ -41,7 +42,7 @@ describe('Piper', () => {

fs.chmodSync = jest.fn()
jest.spyOn(github, 'downloadPiperBinary').mockReturnValue(Promise.resolve('./piper'))
jest.spyOn(github, 'buildPiperFromSource').mockReturnValue(Promise.resolve('./piper'))
jest.spyOn(build, 'buildPiperFromSource').mockReturnValue(Promise.resolve('./build'))
jest.spyOn(execute, 'executePiper').mockImplementation()
jest.spyOn(config, 'getDefaultConfig').mockImplementation()
jest.spyOn(config, 'readContextConfig').mockImplementation()
@@ -104,7 +105,7 @@ describe('Piper', () => {

await piper.run()

expect(github.buildPiperFromSource).toHaveBeenCalledWith(inputs['piper-version'])
expect(build.buildPiperFromSource).toHaveBeenCalledWith(inputs['piper-version'])
expect(docker.cleanupContainers).toHaveBeenCalled()
})

3 changes: 2 additions & 1 deletion test/sidecar.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as exec from '@actions/exec'
import * as core from '@actions/core'
import { createNetwork, parseDockerEnvVars, removeNetwork, startSidecar } from '../src/sidecar'
import { type ActionConfiguration, internalActionVariables } from '../src/piper'
import { internalActionVariables } from '../src/piper'
import { type ActionConfiguration } from '../src/types'
import { getOrchestratorEnvVars, getProxyEnvVars, getVaultEnvVars } from '../src/docker'
import * as docker from '../src/docker'