Implement first version of cuda installer
This commit is contained in:
+61
-53
@@ -1,54 +1,62 @@
|
||||
{
|
||||
"plugins": ["jest", "@typescript-eslint"],
|
||||
"extends": ["plugin:github/recommended"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 9,
|
||||
"sourceType": "module",
|
||||
"project": "./tsconfig.eslint.json"
|
||||
},
|
||||
"rules": {
|
||||
"eslint-comments/no-use": "off",
|
||||
"import/no-namespace": "off",
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": "error",
|
||||
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
|
||||
"@typescript-eslint/no-require-imports": "error",
|
||||
"@typescript-eslint/array-type": "error",
|
||||
"@typescript-eslint/await-thenable": "error",
|
||||
"@typescript-eslint/ban-ts-comment": "error",
|
||||
"camelcase": "off",
|
||||
"@typescript-eslint/consistent-type-assertions": "error",
|
||||
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
|
||||
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
||||
"@typescript-eslint/no-array-constructor": "error",
|
||||
"@typescript-eslint/no-empty-interface": "error",
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@typescript-eslint/no-extraneous-class": "error",
|
||||
"@typescript-eslint/no-for-in-array": "error",
|
||||
"@typescript-eslint/no-inferrable-types": "error",
|
||||
"@typescript-eslint/no-misused-new": "error",
|
||||
"@typescript-eslint/no-namespace": "error",
|
||||
"@typescript-eslint/no-non-null-assertion": "warn",
|
||||
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
||||
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
||||
"@typescript-eslint/no-useless-constructor": "error",
|
||||
"@typescript-eslint/no-var-requires": "error",
|
||||
"@typescript-eslint/prefer-for-of": "warn",
|
||||
"@typescript-eslint/prefer-function-type": "warn",
|
||||
"@typescript-eslint/prefer-includes": "error",
|
||||
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
||||
"@typescript-eslint/promise-function-async": "error",
|
||||
"@typescript-eslint/require-array-sort-compare": "error",
|
||||
"@typescript-eslint/restrict-plus-operands": "error",
|
||||
"semi": "off",
|
||||
"@typescript-eslint/semi": ["error", "never"],
|
||||
"@typescript-eslint/type-annotation-spacing": "error",
|
||||
"@typescript-eslint/unbound-method": "error"
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true,
|
||||
"jest/globals": true
|
||||
}
|
||||
}
|
||||
"plugins": ["jest", "@typescript-eslint"],
|
||||
"extends": ["plugin:github/recommended"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 9,
|
||||
"sourceType": "module",
|
||||
"project": "./tsconfig.eslint.json"
|
||||
},
|
||||
"rules": {
|
||||
"eslint-comments/no-use": "off",
|
||||
"import/no-namespace": "off",
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": ["error"],
|
||||
"@typescript-eslint/explicit-member-accessibility": [
|
||||
"error",
|
||||
{"accessibility": "no-public"}
|
||||
],
|
||||
"no-shadow": "off",
|
||||
"@typescript-eslint/no-shadow": ["error"],
|
||||
"@typescript-eslint/no-require-imports": "error",
|
||||
"@typescript-eslint/array-type": "error",
|
||||
"@typescript-eslint/await-thenable": "error",
|
||||
"@typescript-eslint/ban-ts-comment": "error",
|
||||
"camelcase": "off",
|
||||
"@typescript-eslint/consistent-type-assertions": "error",
|
||||
"@typescript-eslint/explicit-function-return-type": [
|
||||
"error",
|
||||
{"allowExpressions": true}
|
||||
],
|
||||
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
||||
"@typescript-eslint/no-array-constructor": "error",
|
||||
"@typescript-eslint/no-empty-interface": "error",
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@typescript-eslint/no-extraneous-class": "error",
|
||||
"@typescript-eslint/no-for-in-array": "error",
|
||||
"@typescript-eslint/no-inferrable-types": "error",
|
||||
"@typescript-eslint/no-misused-new": "error",
|
||||
"@typescript-eslint/no-namespace": "error",
|
||||
"@typescript-eslint/no-non-null-assertion": "warn",
|
||||
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
||||
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
||||
"@typescript-eslint/no-useless-constructor": "error",
|
||||
"@typescript-eslint/no-var-requires": "error",
|
||||
"@typescript-eslint/prefer-for-of": "warn",
|
||||
"@typescript-eslint/prefer-function-type": "warn",
|
||||
"@typescript-eslint/prefer-includes": "error",
|
||||
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
||||
"@typescript-eslint/promise-function-async": "error",
|
||||
"@typescript-eslint/require-array-sort-compare": "error",
|
||||
"@typescript-eslint/restrict-plus-operands": "error",
|
||||
"semi": "off",
|
||||
"@typescript-eslint/semi": ["error", "never"],
|
||||
"@typescript-eslint/type-annotation-spacing": "error",
|
||||
"@typescript-eslint/unbound-method": "error"
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true,
|
||||
"jest/globals": true
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -96,4 +96,4 @@ Thumbs.db
|
||||
|
||||
# Ignore built ts files
|
||||
__tests__/runner/*
|
||||
lib/**/*
|
||||
lib/
|
||||
@@ -0,0 +1,10 @@
|
||||
import {getLinks} from '../../src/links/links'
|
||||
import {LinuxLinks} from '../../src/links/linuxLinks'
|
||||
import {WindowsLinks} from '../../src/links/windowsLinks'
|
||||
|
||||
test('getLinks gives a valid ILinks class', async () => {
|
||||
const links = await getLinks()
|
||||
expect(
|
||||
links instanceof LinuxLinks || links instanceof WindowsLinks
|
||||
).toBeTruthy()
|
||||
})
|
||||
@@ -0,0 +1,26 @@
|
||||
import {SemVer} from 'semver'
|
||||
import {ILinks} from '../../src/links/links'
|
||||
import {LinuxLinks} from '../../src/links/linuxLinks'
|
||||
|
||||
test('Linux Cuda versions in descending order', async () => {
|
||||
const wLinks: ILinks = LinuxLinks.Instance
|
||||
const versions = wLinks.getAvailableCudaVersions()
|
||||
for (let i = 0; i < versions.length - 1; i++) {
|
||||
const versionA: SemVer = versions[i]
|
||||
const versionB: SemVer = versions[i + 1]
|
||||
expect(versionA.compare(versionB)).toBe(1) // A should be greater than B
|
||||
}
|
||||
})
|
||||
|
||||
test('Linux Cuda version to URL map contains valid URLs', async () => {
|
||||
for (const version of LinuxLinks.Instance.getAvailableCudaVersions()) {
|
||||
const url: URL = LinuxLinks.Instance.getURLFromCudaVersion(version)
|
||||
expect(url).toBeInstanceOf(URL)
|
||||
}
|
||||
})
|
||||
|
||||
test('There is at least linux 1 version url pair', async () => {
|
||||
expect(
|
||||
LinuxLinks.Instance.getAvailableCudaVersions().length
|
||||
).toBeGreaterThanOrEqual(1)
|
||||
})
|
||||
@@ -1,21 +0,0 @@
|
||||
import {SemVer} from 'semver'
|
||||
import {
|
||||
getAvailableCudaVersions,
|
||||
getURLFromCudaVersion
|
||||
} from '../../src/links/windows'
|
||||
|
||||
test('Windows Cuda versions in descending order', async () => {
|
||||
const versions = getAvailableCudaVersions()
|
||||
for (let i = 0; i < versions.length - 1; i++) {
|
||||
const versionA = new SemVer(versions[i])
|
||||
const versionB = new SemVer(versions[i + 1])
|
||||
expect(versionA.compare(versionB)).toBe(1) // A should be greater than B
|
||||
}
|
||||
})
|
||||
|
||||
test('Windows Cuda version to URL map contains valid URLs', async () => {
|
||||
for (const version of getAvailableCudaVersions()) {
|
||||
const url = getURLFromCudaVersion(version)
|
||||
expect(url).toBeInstanceOf(URL)
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,26 @@
|
||||
import {SemVer} from 'semver'
|
||||
import {WindowsLinks} from '../../src/links/windowsLinks'
|
||||
import {ILinks} from '../../src/links/links'
|
||||
|
||||
test('Windows Cuda versions in descending order', async () => {
|
||||
const wLinks: ILinks = WindowsLinks.Instance
|
||||
const versions = wLinks.getAvailableCudaVersions()
|
||||
for (let i = 0; i < versions.length - 1; i++) {
|
||||
const versionA: SemVer = versions[i]
|
||||
const versionB: SemVer = versions[i + 1]
|
||||
expect(versionA.compare(versionB)).toBe(1) // A should be greater than B
|
||||
}
|
||||
})
|
||||
|
||||
test('Windows Cuda version to URL map contains valid URLs', async () => {
|
||||
for (const version of WindowsLinks.Instance.getAvailableCudaVersions()) {
|
||||
const url: URL = WindowsLinks.Instance.getURLFromCudaVersion(version)
|
||||
expect(url).toBeInstanceOf(URL)
|
||||
}
|
||||
})
|
||||
|
||||
test('There is at least windows 1 version url pair', async () => {
|
||||
expect(
|
||||
WindowsLinks.Instance.getAvailableCudaVersions().length
|
||||
).toBeGreaterThanOrEqual(1)
|
||||
})
|
||||
+11
-3
@@ -4,12 +4,20 @@ import * as path from 'path'
|
||||
|
||||
// shows how the runner will run a javascript action with env / stdout protocol
|
||||
test('runs action', () => {
|
||||
process.env['INPUT_CUDA'] = '11.2.1'
|
||||
process.env['INPUT_CUDA'] = '11.2.2'
|
||||
const np = process.execPath
|
||||
const ip = path.join(__dirname, '..', 'lib', 'main.js')
|
||||
const options: cp.ExecFileSyncOptions = {
|
||||
env: process.env
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(cp.execFileSync(np, [ip], options).toString())
|
||||
try {
|
||||
const result = cp.execFileSync(np, [ip], options).toString()
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Result: ${result}`)
|
||||
} catch (err) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(err)
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(err.stdout.toString())
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import {getOs, OSType} from '../src/platform'
|
||||
import os from 'os'
|
||||
|
||||
test('Return either windows of linux platform', async () => {
|
||||
const osPlatform = await getOs()
|
||||
const osString = os.platform()
|
||||
let expected: OSType
|
||||
switch (osString) {
|
||||
case 'win32':
|
||||
expected = OSType.windows
|
||||
break
|
||||
case 'linux':
|
||||
expected = OSType.linux
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unexpected platform: ${osString}`)
|
||||
}
|
||||
expect(osPlatform).toBe(expected)
|
||||
})
|
||||
@@ -0,0 +1,23 @@
|
||||
import {SemVer} from 'semver'
|
||||
import {getVersion} from '../src/version'
|
||||
|
||||
test('Successfully parse correct version', async () => {
|
||||
const versionString = '11.2.2'
|
||||
const version = await getVersion(versionString)
|
||||
expect(version).toBeInstanceOf(SemVer)
|
||||
expect(version.compare(new SemVer(versionString))).toBe(0)
|
||||
})
|
||||
|
||||
test('Expect error to be thrown on invalid version string', async () => {
|
||||
const versionString = 'invalid version string that does not conform to semver'
|
||||
await expect(getVersion(versionString)).rejects.toThrow(
|
||||
TypeError(`Invalid Version: ${versionString}`)
|
||||
)
|
||||
})
|
||||
|
||||
test('Expect error to be thrown on unavailable version', async () => {
|
||||
const versionString = '0.0.1'
|
||||
await expect(getVersion(versionString)).rejects.toThrowError(
|
||||
`Version not available: ${versionString}`
|
||||
)
|
||||
})
|
||||
+1
-1
@@ -5,7 +5,7 @@ inputs:
|
||||
cuda:
|
||||
description: 'Cuda version'
|
||||
required: false
|
||||
default: '11.2.1'
|
||||
default: '11.2.2'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: dist/index.js
|
||||
|
||||
+8054
-22
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
+149
@@ -9,3 +9,152 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@actions/exec
|
||||
MIT
|
||||
|
||||
@actions/http-client
|
||||
MIT
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
@actions/io
|
||||
MIT
|
||||
|
||||
@actions/tool-cache
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
lru-cache
|
||||
ISC
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
semver
|
||||
ISC
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
tunnel
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Koichi Kobayashi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
uuid
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010-2016 Robert Kieffer and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
yallist
|
||||
ISC
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
Generated
+483
-763
File diff suppressed because it is too large
Load Diff
+12
-10
@@ -2,7 +2,7 @@
|
||||
"name": "cuda",
|
||||
"version": "0.1.0",
|
||||
"description": "GitHub Action to install CUDA",
|
||||
"main": "dist/index.js",
|
||||
"main": "lib/main.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"format": "prettier --write **/*.ts jest.config.js",
|
||||
@@ -28,22 +28,24 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/tool-cache": "^1.6.1",
|
||||
"@types/semver": "^7.3.4",
|
||||
"semver": "^7.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node": "^14.14.9",
|
||||
"@typescript-eslint/parser": "^4.8.1",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/node": "^14.14.33",
|
||||
"@typescript-eslint/parser": "^4.17.0",
|
||||
"@vercel/ncc": "^0.25.1",
|
||||
"eslint": "^7.17.0",
|
||||
"eslint-plugin-github": "^4.1.1",
|
||||
"eslint-plugin-jest": "^24.1.3",
|
||||
"eslint": "^7.21.0",
|
||||
"eslint-plugin-github": "^4.1.2",
|
||||
"eslint-plugin-jest": "^24.2.1",
|
||||
"jest": "^26.6.3",
|
||||
"jest-circus": "^26.6.3",
|
||||
"js-yaml": "^3.14.0",
|
||||
"js-yaml": "^3.14.1",
|
||||
"prettier": "2.2.1",
|
||||
"ts-jest": "^26.4.4",
|
||||
"typescript": "^4.1.3"
|
||||
"ts-jest": "^26.5.3",
|
||||
"typescript": "^4.2.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import * as core from '@actions/core'
|
||||
import * as tc from '@actions/tool-cache'
|
||||
import {SemVer} from 'semver'
|
||||
import {getLinks, ILinks} from './links/links'
|
||||
import {getOs, OSType} from './platform'
|
||||
|
||||
// Download helper which returns the installer executable and caches it for next runs
|
||||
export async function download(version: SemVer): Promise<string> {
|
||||
// First try to find tool with desired version in tool cache
|
||||
const toolName = 'cuda_installer'
|
||||
const toolPath = tc.find(toolName, `${version}`)
|
||||
if (toolPath) {
|
||||
// Tool is already in cache
|
||||
core.debug(`Found in cache ${toolPath}`)
|
||||
return toolPath
|
||||
} else {
|
||||
core.debug(`Not found in cache, downloading...`)
|
||||
// Get download URL
|
||||
const links: ILinks = await getLinks()
|
||||
const url: URL = links.getURLFromCudaVersion(version)
|
||||
// Get intsaller filename extension depending on OS
|
||||
let fileExtension: string
|
||||
const osType = await getOs()
|
||||
switch (osType) {
|
||||
case OSType.windows:
|
||||
fileExtension = 'exe'
|
||||
break
|
||||
case OSType.linux:
|
||||
fileExtension = 'run'
|
||||
break
|
||||
}
|
||||
// Pathname for destination
|
||||
const destFileName = `${toolName}_${version}.${fileExtension}`
|
||||
// Download executable
|
||||
const path: string = await tc.downloadTool(url.toString(), destFileName)
|
||||
// Cache download
|
||||
const cachedPath = await tc.cacheFile(
|
||||
path,
|
||||
destFileName,
|
||||
toolName,
|
||||
`${version}`
|
||||
)
|
||||
return cachedPath
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import {exec} from '@actions/exec'
|
||||
import {SemVer} from 'semver'
|
||||
import {download} from './downloader'
|
||||
import * as core from '@actions/core'
|
||||
|
||||
export async function install(version: SemVer): Promise<void> {
|
||||
const executablePath: string = await download(version)
|
||||
const options = {
|
||||
listeners: {
|
||||
stdout: (data: Buffer) => {
|
||||
core.debug(data.toString())
|
||||
},
|
||||
stderr: (data: Buffer) => {
|
||||
core.debug(`Error: ${data.toString()}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
core.debug(`Running install executable: ${executablePath}`)
|
||||
const exitCode = await exec(executablePath, undefined, options)
|
||||
core.debug(`Installer exit code: ${exitCode}`)
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
export async function wait(milliseconds: number): Promise<string> {
|
||||
return new Promise(resolve => {
|
||||
if (isNaN(milliseconds)) {
|
||||
throw new Error('milliseconds not a number')
|
||||
}
|
||||
|
||||
setTimeout(() => resolve('done!'), milliseconds)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import {SemVer} from 'semver'
|
||||
import {getOs, OSType} from '../platform'
|
||||
import {LinuxLinks} from './linuxLinks'
|
||||
import {WindowsLinks} from './windowsLinks'
|
||||
|
||||
// Interface for getting cuda versions and corresponding download URLs
|
||||
export interface ILinks {
|
||||
getAvailableCudaVersions(): SemVer[]
|
||||
getURLFromCudaVersion(version: SemVer): URL
|
||||
}
|
||||
|
||||
// Platform independent getter for ILinks interface
|
||||
export async function getLinks(): Promise<ILinks> {
|
||||
const osType = await getOs()
|
||||
switch (osType) {
|
||||
case OSType.windows:
|
||||
return WindowsLinks.Instance
|
||||
case OSType.linux:
|
||||
return LinuxLinks.Instance
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import {SemVer} from 'semver'
|
||||
import {ILinks} from './links'
|
||||
|
||||
const cudaVersionStringToURLStringLinux = new Map([
|
||||
[
|
||||
'11.2.2',
|
||||
'https://developer.download.nvidia.com/compute/cuda/11.2.2/local_installers/cuda_11.2.2_460.32.03_linux.run'
|
||||
],
|
||||
[
|
||||
'11.2.1',
|
||||
'https://developer.download.nvidia.com/compute/cuda/11.2.1/local_installers/cuda_11.2.1_460.32.03_linux.run'
|
||||
],
|
||||
[
|
||||
'10.2.89',
|
||||
'https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run'
|
||||
],
|
||||
[
|
||||
'9.2.148',
|
||||
'https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda_9.2.148_396.37_linux'
|
||||
],
|
||||
[
|
||||
'8.0.61',
|
||||
'https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run'
|
||||
]
|
||||
])
|
||||
|
||||
/**
|
||||
* Singleton class for windows links.
|
||||
*/
|
||||
export class LinuxLinks implements ILinks {
|
||||
// Singleton instance
|
||||
private static _instance: LinuxLinks
|
||||
|
||||
// Map of cuda SemVer version to download URL
|
||||
private cudaVersionToURL = new Map(
|
||||
[...cudaVersionStringToURLStringLinux].map(([k, v]) => [
|
||||
new SemVer(k),
|
||||
new URL(v)
|
||||
])
|
||||
)
|
||||
|
||||
// Private constructor to prevent instantiation
|
||||
private constructor() {}
|
||||
|
||||
static get Instance(): LinuxLinks {
|
||||
// Do you need arguments? Make it a regular static method instead.
|
||||
return this._instance || (this._instance = new this())
|
||||
}
|
||||
|
||||
getAvailableCudaVersions(): SemVer[] {
|
||||
return Array.from(this.cudaVersionToURL.keys())
|
||||
}
|
||||
|
||||
getURLFromCudaVersion(version: SemVer): URL {
|
||||
const urlString = this.cudaVersionToURL.get(version)
|
||||
if (urlString === undefined) {
|
||||
throw new Error(`Invalid version: ${version}`)
|
||||
}
|
||||
return urlString
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
import {SemVer} from 'semver'
|
||||
import {ILinks} from './links'
|
||||
|
||||
// 11.2.1 https://developer.download.nvidia.com/compute/cuda/11.2.1/local_installers/cuda_11.2.1_461.09_win10.exe
|
||||
// 10.2 https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_441.22_win10.exe
|
||||
// 9.2 https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers2/cuda_9.2.148_win10
|
||||
@@ -18,7 +21,11 @@
|
||||
// "11.0.167" = "http://developer.download.nvidia.com/compute/cuda/11.0.1/network_installers/cuda_11.0.1_win10_network.exe"
|
||||
// }
|
||||
|
||||
const cudaVersionToURL = new Map([
|
||||
const cudaVersionStringToURLStringWindows = new Map([
|
||||
[
|
||||
'11.2.2',
|
||||
'https://developer.download.nvidia.com/compute/cuda/11.2.2/local_installers/cuda_11.2.2_461.33_win10.exe'
|
||||
],
|
||||
[
|
||||
'11.2.1',
|
||||
'https://developer.download.nvidia.com/compute/cuda/11.2.1/local_installers/cuda_11.2.1_461.09_win10.exe'
|
||||
@@ -37,14 +44,38 @@ const cudaVersionToURL = new Map([
|
||||
]
|
||||
])
|
||||
|
||||
export function getAvailableCudaVersions(): string[] {
|
||||
return Array.from(cudaVersionToURL.keys())
|
||||
}
|
||||
/**
|
||||
* Singleton class for windows links.
|
||||
*/
|
||||
export class WindowsLinks implements ILinks {
|
||||
// Singleton instance
|
||||
private static _instance: WindowsLinks
|
||||
|
||||
export function getURLFromCudaVersion(version: string): URL {
|
||||
const urlString = cudaVersionToURL.get(version)
|
||||
if (urlString === undefined) {
|
||||
throw new Error(`Invalid version: ${version}`)
|
||||
// Map of cuda SemVer version to download URL
|
||||
private cudaVersionToURL = new Map(
|
||||
[...cudaVersionStringToURLStringWindows].map(([k, v]) => [
|
||||
new SemVer(k),
|
||||
new URL(v)
|
||||
])
|
||||
)
|
||||
|
||||
// Private constructor to prevent instantiation
|
||||
private constructor() {}
|
||||
|
||||
static get Instance(): WindowsLinks {
|
||||
// Do you need arguments? Make it a regular static method instead.
|
||||
return this._instance || (this._instance = new this())
|
||||
}
|
||||
|
||||
getAvailableCudaVersions(): SemVer[] {
|
||||
return Array.from(this.cudaVersionToURL.keys())
|
||||
}
|
||||
|
||||
getURLFromCudaVersion(version: SemVer): URL {
|
||||
const urlString = this.cudaVersionToURL.get(version)
|
||||
if (urlString === undefined) {
|
||||
throw new Error(`Invalid version: ${version}`)
|
||||
}
|
||||
return urlString
|
||||
}
|
||||
return new URL(urlString)
|
||||
}
|
||||
+7
-3
@@ -1,13 +1,17 @@
|
||||
import * as core from '@actions/core'
|
||||
import {install} from './installer'
|
||||
import {getVersion} from './version'
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
const cuda: string = core.getInput('cuda')
|
||||
core.debug(`Desired cuda version: ${cuda}`) // debug is only output if you set the secret `ACTIONS_RUNNER_DEBUG` to true
|
||||
|
||||
// TODO Install cuda here
|
||||
// 1. Install
|
||||
// 2. Add CUDA environment variables to GitHub environment variables
|
||||
// Parse version string
|
||||
const version = await getVersion(cuda)
|
||||
// Install
|
||||
await install(version)
|
||||
// TODO Add CUDA environment variables to GitHub environment variables
|
||||
|
||||
// steps:
|
||||
// - run: echo Cuda version ${{ inputs.cuda }}.
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import os from 'os'
|
||||
import {debug} from '@actions/core'
|
||||
|
||||
export enum OSType {
|
||||
windows,
|
||||
linux
|
||||
}
|
||||
|
||||
export async function getOs(): Promise<OSType> {
|
||||
const osPlatform = os.platform()
|
||||
switch (osPlatform) {
|
||||
case 'win32':
|
||||
return OSType.windows
|
||||
case 'linux':
|
||||
return OSType.linux
|
||||
default:
|
||||
debug(`Unsupported OS: ${osPlatform}`)
|
||||
throw new Error(`Unsupported OS: ${osPlatform}`)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import {SemVer} from 'semver'
|
||||
import {getLinks, ILinks} from './links/links'
|
||||
import {debug} from '@actions/core'
|
||||
|
||||
// Helper for converting string to SemVer and verifying it exists in the links
|
||||
export async function getVersion(versionString: string): Promise<SemVer> {
|
||||
const version = new SemVer(versionString)
|
||||
const links: ILinks = await getLinks()
|
||||
debug(`At links: ${links}`)
|
||||
const versions = links.getAvailableCudaVersions()
|
||||
debug(`Available versions: ${versions}`)
|
||||
if (versions.find(v => v.compare(version) === 0) !== undefined) {
|
||||
debug(`Version available: ${version}`)
|
||||
return version
|
||||
} else {
|
||||
debug(`Version not available error!`)
|
||||
throw new Error(`Version not available: ${version}`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user