Skip to content

Commit

Permalink
Do not upload log artifact when no log is present
Browse files Browse the repository at this point in the history
- This fixes #207, older CUDA versions don't have an installer log at
  the hardcoded location of /var/log/cuda-installer.log so the
  artifact uploader would fail.
- To fix this let's not upload any artifacts in the first place if there
  is no log file to upload.
  • Loading branch information
Jimver authored Mar 19, 2023
1 parent 90c3203 commit 92536f7
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/installer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as artifact from '@actions/artifact'
import * as core from '@actions/core'
import * as glob from '@actions/glob'
import {OSType, getOs} from './platform'
import {SemVer} from 'semver'
import {exec} from '@actions/exec'
Expand Down Expand Up @@ -64,25 +65,31 @@ export async function install(
const exitCode = await exec(command, installArgs, execOptions)
core.debug(`Installer exit code: ${exitCode}`)
} catch (error) {
core.debug(`Error during installation: ${error}`)
core.warning(`Error during installation: ${error}`)
throw error
} finally {
// Always upload installation log regardless of error
if ((await getOs()) === OSType.linux) {
const artifactClient = artifact.create()
const artifactName = 'install-log'
const files = ['/var/log/cuda-installer.log']
const rootDirectory = '/var/log'
const artifactOptions = {
continueOnError: true
const patterns = ['/var/log/cuda-installer.log']
const globber = await glob.create(patterns.join('\n'))
const files = await globber.glob()
if (files.length > 0) {
const rootDirectory = '/var/log'
const artifactOptions = {
continueOnError: true
}
const uploadResult = await artifactClient.uploadArtifact(
artifactName,
files,
rootDirectory,
artifactOptions
)
core.debug(`Upload result: ${uploadResult}`)
} else {
core.debug(`No log file to upload`)
}
const uploadResult = await artifactClient.uploadArtifact(
artifactName,
files,
rootDirectory,
artifactOptions
)
core.debug(`Upload result: ${uploadResult}`)
}
}
}

0 comments on commit 92536f7

Please sign in to comment.