Skip to content

Commit

Permalink
Fail builds on non-zero exit codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Mar 11, 2022
1 parent ab9fee9 commit 6456dc6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dependencies.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import {GRAALVM_PLATFORM} from './constants'
import {exec} from '@actions/exec'
import {exec} from './utils'

const APT_GET_INSTALL_BASE = 'sudo apt-get -y --no-upgrade install'
const COMPONENT_TO_DEPS = new Map<string, Map<string, string>>([
Expand Down
2 changes: 1 addition & 1 deletion src/features.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'
import {IS_LINUX} from './constants'
import {exec} from '@actions/exec'
import {exec} from './utils'
import {join} from 'path'

const MUSL_NAME = 'x86_64-linux-musl-native'
Expand Down
2 changes: 1 addition & 1 deletion src/gu.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {GRAALVM_PLATFORM} from './constants'
import {exec} from '@actions/exec'
import {exec} from './utils'
import {join} from 'path'

const BASE_FLAGS = ['--non-interactive', 'install', '--no-progress']
Expand Down
16 changes: 16 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as c from './constants'
import * as core from '@actions/core'
import * as httpClient from '@actions/http-client'
import * as tc from '@actions/tool-cache'
import {ExecOptions, exec as e} from '@actions/exec'
import {readFileSync, readdirSync} from 'fs'
import {Octokit} from '@octokit/core'
import {createHash} from 'crypto'
Expand All @@ -16,6 +17,21 @@ const GitHub = Octokit.defaults({
}
})

export async function exec(
commandLine: string,
args?: string[],
options?: ExecOptions | undefined
): Promise<void> {
const exitCode = await e(commandLine, args, options)
if (exitCode !== 0) {
throw new Error(
`'${[commandLine]
.concat(args || [])
.join(' ')}' exited with a non-zero code: ${exitCode}`
)
}
}

export async function getLatestRelease(
repo: string
): Promise<c.LatestReleaseResponse['data']> {
Expand Down

0 comments on commit 6456dc6

Please sign in to comment.