Compare commits

..

1 Commits

Author SHA1 Message Date
Sascha Mann
6ae948d0f4 Publish v0.1.0 2019-08-13 18:05:27 +02:00
5 changed files with 69 additions and 207 deletions

View File

@@ -1,14 +1,6 @@
# setup-julia Action # setup-julia Action
This action sets up a Julia environment for use in actions by downloading a specified version of Julia and adding it to PATH. This action sets up a Julia environment for use in actions by download a specified version of Julia and adding it to PATH.
## Table of Contents
- [Table of Contents](#table-of-contents)
- [Usage](#usage)
- [Versioning](#versioning)
- [Future plans & ideas](#future-plans--ideas)
- [Words of caution](#words-of-caution)
- [Licence info](#licence-info)
## Usage ## Usage
@@ -21,7 +13,7 @@ Take a look at [github.com/exercism/julia](https://github.com/exercism/julia/pul
```yaml ```yaml
steps: steps:
- uses: actions/checkout@v1.0.0 - uses: actions/checkout@v1.0.0
- uses: julia-actions/setup-julia@v0.2 - uses: julia-actions/setup-julia@v0.1.0
with: with:
version: 1.0.4 version: 1.0.4
- run: julia -e 'println("Hello, World!")' - run: julia -e 'println("Hello, World!")'
@@ -29,8 +21,6 @@ steps:
### Matrix Testing: ### Matrix Testing:
#### 64-bit Julia only
```yaml ```yaml
jobs: jobs:
test: test:
@@ -43,82 +33,12 @@ jobs:
steps: steps:
- uses: actions/checkout@v1.0.0 - uses: actions/checkout@v1.0.0
- name: "Set up Julia" - name: "Set up Julia"
uses: julia-actions/setup-julia@v0.2 uses: julia-actions/setup-julia@v0.1.0
with: with:
version: ${{ matrix.julia-version }} version: ${{ matrix.julia-version }}
- run: julia -e 'println("Hello, World!")' - run: julia -e 'println("Hello, World!")'
``` ```
#### 32-bit Julia
```yaml
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1.0.4, 1.1.1, 1.2.0-rc3, 1.3.0-alpha]
julia-arch: [x64, x86]
os: [ubuntu-latest, windows-latest, macOS-latest]
# 32-bit Julia binaries are not available on macOS
exclude:
- os: macOS-latest
julia-arch: x86
steps:
- uses: actions/checkout@v1.0.0
- name: "Set up Julia"
uses: julia-actions/setup-julia@v0.2
with:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}
- run: julia -e 'println("Hello, World!")'
```
Alternatively, you can include specific version and OS combinations that will use 32-bit Julia:
```yaml
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1.0.4, 1.1.1, 1.2.0-rc3, 1.3.0-alpha]
os: [ubuntu-latest, windows-latest, macOS-latest]
# Additionally create a job using 32-bit Julia 1.0.4 on windows-latest
include:
- os: windows-latest
julia-version: [1.0.4]
julia-arch: x86
steps:
- uses: actions/checkout@v1.0.0
- name: "Set up Julia"
uses: julia-actions/setup-julia@v0.2
with:
version: ${{ matrix.julia-version }}
- run: julia -e 'println("Hello, World!")'
```
## Versioning
This action follows [GitHub's advice](https://help.github.com/en/articles/about-actions#versioning-your-action) on versioning actions, with an additional `latest` tag.
If you don't want to deal with updating the version of the action, similiarly to how Travis CI handles it, use `latest` or major version branches.
It's unlikely, but not impossible, that there will be breaking changes post-v1.0.0 unless a new major version of Julia is introduced.
You can specify commits, branches or tags in your workflows as follows:
```yaml
steps:
- uses: julia-actions/setup-julia@6ae948d # commit SHA
- uses: julia-actions/setup-julia@master # branch
- uses: julia-actions/setup-julia@latest # latest version tag (may break existing workflows)
- uses: julia-actions/setup-julia@v1 # major version tag
- uses: julia-actions/setup-julia@v0.1.0 # specific version tag
```
## Future plans & ideas ## Future plans & ideas
In no particular order: In no particular order:
@@ -127,8 +47,9 @@ In no particular order:
* Check if a cached version of Julia is available instead of installing it everytime CI runs. * Check if a cached version of Julia is available instead of installing it everytime CI runs.
* Add version shortcuts like `1.x`, `1.1.x`, `latest` and `lts`. * Add version shortcuts like `1.x`, `1.1.x`, `latest` and `lts`.
* Add support for nightly Julia builds. * Add support for nightly Julia builds.
* Support 32-bit Julia on 64-bit windows.
* Write some unit tests for the action. * Write some unit tests for the action.
* Add CI script that checks if tags have been updated on release. * Figure out the best way to handle versioning.
* Hash and signature checks. * Hash and signature checks.
### Other Julia-related actions: ### Other Julia-related actions:
@@ -146,7 +67,7 @@ This action will likely be updated quite frequently in the near future. I'm shar
**DO NOT USE THIS AS YOUR ONLY FORM OF CI** (yet). **DO NOT USE THIS AS YOUR ONLY FORM OF CI** (yet).
Unfortunately, because non-container actions must use JavaScript/TypeScript as scripting language, `npm` is involved. The published action only uses the toolkit-dependencies maintained by GitHub but, as usual with `npm`, these load over 50 transitive dependencies. If this causes issues with your security policies, you might want to fork the action, so that you can audit and lock exact versions of all direct and transitive dependencies. Unfortunately, because non-container actions must use JavaScript/TypeScript as scripting language, `npm` is involved. The dependencies are vendored but this action relies 100% on GitHub to audit the dependencies they add to their action toolkit.
## Licence info ## Licence info
Parts of this software have been derived from the `setup-go` [action](https://github.com/actions/setup-go) and the [JavaScript Action Template](https://github.com/actions/javascript-template), both released by GitHub under the MIT licence. Parts of this software have been derived from the `setup-go` [action](https://github.com/actions/setup-go) and the [JavaScript Action Template](https://github.com/actions/javascript-template), both released by GitHub under the MIT licence.

View File

@@ -5,10 +5,6 @@ inputs:
version: version:
description: 'The Julia version to download (if necessary) and use. Example: 1.0.4' description: 'The Julia version to download (if necessary) and use. Example: 1.0.4'
default: '1.0.4' default: '1.0.4'
arch:
description: 'Architecture of the Julia binaries. Defaults to x64.'
required: false
default: 'x64'
runs: runs:
using: 'node12' using: 'node12'
main: 'lib/setup-julia.js' main: 'lib/setup-julia.js'

View File

@@ -1,16 +0,0 @@
# Release checklist
Version: `1.b.c`
- [x] Create release branch `releases/v1.b.c`
- [x] Unignore `node_modules/` by adding `!` in front in `.gitignore`
- [x] Delete `node_modules/`
- [x] Install production dependencies: `npm install --production`
- [x] Add `node_modules/`: `git add node_modules`
- [x] Commit & push action: `git commit -a -m "Publish v1.b.c."`, then `git push`
- [x] Test the action with an example package
- [x] Create tags
- [x] `v1.b.c` pointing at the last commit in `releases/v1.b.c`
- [x] `latest` pointing at the latest version of the highest major version
- [x] `v1` pointing at the latest `1.x.x` version
- [x] Push tags

View File

@@ -26,42 +26,39 @@ core.debug(`platform: ${osPlat}`);
function getMajorMinorVersion(version) { function getMajorMinorVersion(version) {
return version.split('.').slice(0, 2).join('.'); return version.split('.').slice(0, 2).join('.');
} }
function getDownloadURL(version, arch) { function getDownloadURL(version) {
const baseURL = 'https://julialang-s3.julialang.org/bin'; const baseURL = 'https://julialang-s3.julialang.org/bin';
let platform; let platform, arch;
const versionDir = getMajorMinorVersion(version); const versionDir = getMajorMinorVersion(version);
if (osPlat === 'win32') { // Windows if (osPlat === 'win32') { // Windows
platform = 'winnt'; platform = 'winnt';
arch = 'x64';
} }
else if (osPlat === 'darwin') { // macOS else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS';
}
platform = 'mac'; platform = 'mac';
arch = 'x64';
} }
else if (osPlat === 'linux') { // Linux else if (osPlat === 'linux') { // Linux
platform = 'linux'; platform = 'linux';
arch = 'x64';
} }
else { else {
throw `Platform ${osPlat} is not supported`; throw `Platform ${osPlat} is not supported`;
} }
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}`; return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version)}`;
} }
function getFileName(version, arch) { function getFileName(version) {
let versionExt, ext; let versionExt, ext;
if (osPlat === 'win32') { // Windows if (osPlat === 'win32') { // Windows
versionExt = arch == 'x64' ? '-win64' : '-win32'; versionExt = '-win64';
ext = 'exe'; ext = 'exe';
} }
else if (osPlat === 'darwin') { // macOS else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS';
}
versionExt = '-mac64'; versionExt = '-mac64';
ext = 'dmg'; ext = 'dmg';
} }
else if (osPlat === 'linux') { // Linux else if (osPlat === 'linux') { // Linux
versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686'; versionExt = '-linux-x86_64';
ext = 'tar.gz'; ext = 'tar.gz';
} }
else { else {
@@ -69,50 +66,34 @@ function getFileName(version, arch) {
} }
return `julia-${version}${versionExt}.${ext}`; return `julia-${version}${versionExt}.${ext}`;
} }
function installJulia(version, arch) {
return __awaiter(this, void 0, void 0, function* () {
// Download Julia
const downloadURL = getDownloadURL(version, arch);
core.debug(`downloading Julia from ${downloadURL}`);
const juliaDownloadPath = yield tc.downloadTool(downloadURL);
// Install it
switch (osPlat) {
case 'linux':
const juliaExtractedFolder = yield tc.extractTar(juliaDownloadPath);
return path.join(juliaExtractedFolder, `julia-${version}`);
case 'win32':
const juliaInstallationPath = path.join('C:', 'Julia');
yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`]);
return juliaInstallationPath;
case 'darwin':
yield exec.exec('hdiutil', ['attach', juliaDownloadPath]);
return `/Volumes/Julia-${version}/Julia-${getMajorMinorVersion(version)}.app/Contents/Resources/julia`;
default:
throw `Platform ${osPlat} is not supported`;
}
});
}
function run() { function run() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
const version = core.getInput('version'); const version = core.getInput('version');
const arch = core.getInput('arch'); core.debug(`selected Julia version: ${version}`);
core.debug(`selected Julia version: ${arch}/${version}`); // Download Julia
// Search in cache const downloadURL = getDownloadURL(version);
let juliaPath; core.debug(`download Julia from ${downloadURL}`);
juliaPath = tc.find('julia', version, arch); const juliaDownloadPath = yield tc.downloadTool(downloadURL);
if (!juliaPath) { // Install Julia
core.debug(`could not find Julia ${version} in cache`); if (osPlat === 'linux') { // Linux
const juliaInstallationPath = yield installJulia(version, arch); const juliaExtractedFolder = yield tc.extractTar(juliaDownloadPath);
// Add it to cache const juliaCachedPath = yield tc.cacheDir(juliaExtractedFolder, 'julia', version);
juliaPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version, arch); const juliaPath = path.join(juliaCachedPath, `julia-${version}`);
core.debug(`added Julia to cache: ${juliaPath}`); core.addPath(path.join(juliaPath, 'bin'));
} }
else { else if (osPlat === 'win32') { // Windows
core.debug(`using cached version of Julia: ${juliaPath}`); // Install Julia in C:\Julia
const juliaInstallationPath = path.join('C:', 'Julia');
yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`]);
const juliaCachedPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version);
core.addPath(path.join(juliaCachedPath, 'bin'));
}
else if (osPlat === 'darwin') { // macOS
yield exec.exec('hdiutil', ['attach', juliaDownloadPath]);
const juliaCachedPath = yield tc.cacheDir(`/Volumes/Julia-${version}/Julia-${getMajorMinorVersion(version)}.app/Contents/Resources/julia`, 'julia', version);
core.addPath(path.join(juliaCachedPath, 'bin'));
} }
// Add it to PATH
core.addPath(path.join(juliaPath, 'bin'));
// Test if Julia has been installed by showing versioninfo() // Test if Julia has been installed by showing versioninfo()
yield exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()']); yield exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()']);
} }

View File

@@ -13,41 +13,38 @@ function getMajorMinorVersion(version: string): string {
return version.split('.').slice(0, 2).join('.') return version.split('.').slice(0, 2).join('.')
} }
function getDownloadURL(version: string, arch: string): string { function getDownloadURL(version: string): string {
const baseURL = 'https://julialang-s3.julialang.org/bin' const baseURL = 'https://julialang-s3.julialang.org/bin'
let platform: string let platform: string, arch: string
const versionDir = getMajorMinorVersion(version) const versionDir = getMajorMinorVersion(version)
if (osPlat === 'win32') { // Windows if (osPlat === 'win32') { // Windows
platform = 'winnt' platform = 'winnt'
arch = 'x64'
} else if (osPlat === 'darwin') { // macOS } else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS'
}
platform = 'mac' platform = 'mac'
arch = 'x64'
} else if (osPlat === 'linux') { // Linux } else if (osPlat === 'linux') { // Linux
platform = 'linux' platform = 'linux'
arch = 'x64'
} else { } else {
throw `Platform ${osPlat} is not supported` throw `Platform ${osPlat} is not supported`
} }
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}` return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version)}`
} }
function getFileName(version: string, arch: string): string { function getFileName(version: string): string {
let versionExt: string, ext: string let versionExt: string, ext: string
if (osPlat === 'win32') { // Windows if (osPlat === 'win32') { // Windows
versionExt = arch == 'x64' ? '-win64' : '-win32' versionExt = '-win64'
ext = 'exe' ext = 'exe'
} else if (osPlat === 'darwin') { // macOS } else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS'
}
versionExt = '-mac64' versionExt = '-mac64'
ext = 'dmg' ext = 'dmg'
} else if (osPlat === 'linux') { // Linux } else if (osPlat === 'linux') { // Linux
versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686' versionExt = '-linux-x86_64'
ext = 'tar.gz' ext = 'tar.gz'
} else { } else {
throw `Platform ${osPlat} is not supported` throw `Platform ${osPlat} is not supported`
@@ -56,53 +53,36 @@ function getFileName(version: string, arch: string): string {
return `julia-${version}${versionExt}.${ext}` return `julia-${version}${versionExt}.${ext}`
} }
async function installJulia(version: string, arch: string): Promise<string> {
// Download Julia
const downloadURL = getDownloadURL(version, arch)
core.debug(`downloading Julia from ${downloadURL}`)
const juliaDownloadPath = await tc.downloadTool(downloadURL)
// Install it
switch (osPlat) {
case 'linux':
const juliaExtractedFolder = await tc.extractTar(juliaDownloadPath)
return path.join(juliaExtractedFolder, `julia-${version}`)
case 'win32':
const juliaInstallationPath = path.join('C:', 'Julia')
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`])
return juliaInstallationPath
case 'darwin':
await exec.exec('hdiutil', ['attach', juliaDownloadPath])
return `/Volumes/Julia-${version}/Julia-${getMajorMinorVersion(version)}.app/Contents/Resources/julia`
default:
throw `Platform ${osPlat} is not supported`
}
}
async function run() { async function run() {
try { try {
const version = core.getInput('version') const version = core.getInput('version')
const arch = core.getInput('arch') core.debug(`selected Julia version: ${version}`)
core.debug(`selected Julia version: ${arch}/${version}`)
// Search in cache // Download Julia
let juliaPath: string; const downloadURL = getDownloadURL(version)
juliaPath = tc.find('julia', version, arch) core.debug(`download Julia from ${downloadURL}`)
const juliaDownloadPath = await tc.downloadTool(downloadURL)
if (!juliaPath) { // Install Julia
core.debug(`could not find Julia ${version} in cache`) if (osPlat === 'linux') { // Linux
const juliaInstallationPath = await installJulia(version, arch); const juliaExtractedFolder = await tc.extractTar(juliaDownloadPath)
const juliaCachedPath = await tc.cacheDir(juliaExtractedFolder, 'julia', version)
const juliaPath = path.join(juliaCachedPath, `julia-${version}`)
core.addPath(path.join(juliaPath, 'bin'))
// Add it to cache } else if (osPlat === 'win32') { // Windows
juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version, arch) // Install Julia in C:\Julia
core.debug(`added Julia to cache: ${juliaPath}`) const juliaInstallationPath = path.join('C:', 'Julia')
} else { await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${juliaInstallationPath}" -NoNewWindow -Wait`])
core.debug(`using cached version of Julia: ${juliaPath}`) const juliaCachedPath = await tc.cacheDir(juliaInstallationPath, 'julia', version)
core.addPath(path.join(juliaCachedPath, 'bin'))
} else if (osPlat === 'darwin') { // macOS
await exec.exec('hdiutil', ['attach', juliaDownloadPath])
const juliaCachedPath = await tc.cacheDir(`/Volumes/Julia-${version}/Julia-${getMajorMinorVersion(version)}.app/Contents/Resources/julia`, 'julia', version)
core.addPath(path.join(juliaCachedPath, 'bin'))
} }
// Add it to PATH
core.addPath(path.join(juliaPath, 'bin'))
// Test if Julia has been installed by showing versioninfo() // Test if Julia has been installed by showing versioninfo()
await exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()']) await exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()'])
} catch (error) { } catch (error) {