Compare commits

...

94 Commits

Author SHA1 Message Date
Sascha Mann
07778fc13e Add production dependencies & build 2020-09-26 18:25:53 +02:00
Sascha Mann
def57cde21 Bump version to 1.3.0 2020-09-26 18:24:53 +02:00
Sascha Mann
c639390e13 Handle install directories using tool-cache (#46)
* Make test builds more verbose

* Handle install directories using tool-cache

* Bump version to 1.3.0-DEV
2020-09-26 18:20:43 +02:00
Sascha Mann
b469b93959 Bump version 2020-09-24 22:10:06 +02:00
Kyungdahm Yun
d622e3db7b Add Julia 1.5.2 2020-09-24 22:08:18 +02:00
Sascha Mann
8aadcc1915 Add Julia 1.5.1 2020-08-26 21:17:30 +02:00
Sascha Mann
01ebb7f57a Update example-builds-nightly.yml 2020-08-26 21:14:23 +02:00
Sascha Mann
44bf6b3b7d Bump version to 1.2.0 2020-08-18 23:05:40 +02:00
Sascha Mann
b4e544c83e Add IP to debug logs 2020-08-18 23:04:06 +02:00
dependabot-preview[bot]
fc275221aa Bump bin from ceb0aec to 9ceca17 (#42) 2020-08-03 10:03:49 +00:00
Sascha Mann
f7961d5fc8 Bump version 2020-08-02 15:16:43 +02:00
Sascha Mann
19781e4bbc Add Julia 1.5.0 2020-08-02 15:12:22 +02:00
dependabot-preview[bot]
1b9230a354 Bump bin from aca4c56 to ceb0aec (#41) 2020-08-01 10:21:52 +00:00
Sascha Mann
a2cbd4a70f Re-add scripts as submodule 2020-08-01 12:05:29 +02:00
Sascha Mann
28af8fd3e2 Delete scripts 2020-08-01 11:58:40 +02:00
Sascha Mann
aced07b9c9 Fail build when inputs are empty 2020-07-30 13:21:38 +02:00
Sascha Mann
6b1edeb409 Bump version 2020-07-27 22:10:47 +02:00
Sascha Mann
4f37a4b06c Add Julia 1.5.0-rc2 2020-07-27 22:06:55 +02:00
Dilum Aluthge
b6c79c651a Merge pull request #39 from julia-actions/dependabot/npm_and_yarn/lodash-4.17.19
Bump lodash from 4.17.15 to 4.17.19
2020-07-17 21:01:04 -04:00
dependabot[bot]
2686c6a9d0 Bump lodash from 4.17.15 to 4.17.19
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-18 00:08:12 +00:00
Sascha Mann
55f774e778 Remove privacy info again
See https://discourse.julialang.org/t/pkg-jl-telemetry-should-be-opt-in/42209/374?u=saschamann
2020-07-10 19:46:08 +02:00
Sascha Mann
d2ec2a4741 Remove redundant await 2020-07-10 15:19:45 +02:00
Sascha Mann
e8b6657769 Fix debug step order 2020-07-07 13:51:16 +02:00
Sascha Mann
9935e37e60 Add debug info to nightly builds and increase frequency temporarily 2020-07-06 00:41:49 +02:00
Sascha Mann
5c7eefcc01 Add basic contribution instructions 2020-07-05 16:27:49 +02:00
Sascha Mann
226eae6f8c Add bug report issue template 2020-07-05 16:22:50 +02:00
Sascha Mann
415c8550da Bump version 2020-07-05 14:10:58 +02:00
Sascha Mann
85cbcd387e Fix error throwing
throw 'error' does not display an error message on GitHub Actions
anymore.
2020-07-05 14:10:57 +02:00
Sascha Mann
802776bd6a Throw error if version range doesn't match anything
fixes #38
2020-07-05 14:10:57 +02:00
Sascha Mann
477bec664c Fix mistakes in version range examples 2020-07-03 10:15:16 +02:00
Sascha Mann
c766abf0da Change ^1.3-0 -> ^1.3.0-0 in examples 2020-07-03 10:08:00 +02:00
Sascha Mann
3eb3524cb4 Fix divergence caused by not running npm i before build 2020-06-30 23:45:16 +02:00
Sascha Mann
6ac7df4cef Add Julia 1.5.0-rc1 2020-06-30 23:39:12 +02:00
Sascha Mann
c7bbfb8ea8 Bump version to 1.1.7 2020-06-25 14:29:50 +02:00
Sascha Mann
be4aa6964b Move third party information 2020-06-25 14:28:46 +02:00
Sascha Mann
1cabf59107 Add Privacy Info to README 2020-06-25 14:23:32 +02:00
Sascha Mann
8945494c8c Document pre-release version range syntax -0
Also add a link to REPL.it to play with the version matching logic.
2020-06-01 22:48:13 +02:00
Sascha Mann
a81735fc3d Add Julia 1.5.0-beta1 2020-05-29 10:24:13 +02:00
Sascha Mann
2c2ccf4805 Add Julia 1.4.2 and update deps 2020-05-28 12:02:01 +02:00
Sascha Mann
0352b39425 Bump action version to 1.1.4 2020-04-15 14:04:09 +02:00
Sascha Mann
5ed1ab9531 Add Julia 1.4.1 2020-04-15 13:54:34 +02:00
Sascha Mann
b440227ef4 Use @zeit/ncc to distribute action 2020-03-24 20:05:33 +01:00
Sascha Mann
e07eb0ff2a Remove debugging steps from workflows 2020-03-22 18:16:49 +01:00
Sascha Mann
0c24e24eb5 Add Julia 1.4.0 2020-03-22 18:09:09 +01:00
Sascha Mann
abd4c5ae03 Run npm audit fix 2020-03-22 18:07:32 +01:00
Sascha Mann
51f7dbcff0 Add 'v1.4.0-rc2' 2020-03-11 14:19:14 +01:00
Sascha Mann
06264a4b68 Run npm audit fix --force 2020-03-11 14:19:14 +01:00
Sascha Mann
8f56a5b739 Remove @actions/github dependency
(fixes #27)
2020-03-11 14:19:02 +01:00
Sascha Mann
83f4f82909 Don't show versioninfo() by default (#25)
* Only show versioninfo() in debug mode

* Add input to specify if versioninfo() is displayed

* No access to secrets
2020-02-19 20:45:01 +01:00
Sascha Mann
eba5daa7a3 Add shell: bash to examples
fixes #23
2020-02-17 13:59:12 +01:00
Sascha Mann
150b180e77 Fix v1.4.0-rc1 version string 2020-02-13 10:48:40 +01:00
Sascha Mann
df27cccb6d Add Julia 1.4.0-rc1 to version list 2020-01-23 23:51:41 +01:00
Sascha Mann
4e8b9a1f06 Revert "Temporarily increase frequency of nightly builds"
This reverts commit 6c0c21977e.
2020-01-08 21:12:02 +01:00
Sascha Mann
960c1f45ca Delete release checklist
No longer needed, the bash script `bin/build-release` covers all of this.
2019-12-31 11:08:25 +01:00
Sascha Mann
ca58c641a5 Add Julia 1.3.1 to version list (#22) 2019-12-31 10:53:40 +01:00
Sascha Mann
6c0c21977e Temporarily increase frequency of nightly builds
The download of the nightly linux binaries still fails seemingly randomly. To get more information, the build will be run every 15 minutes temporarily.
2019-12-09 11:34:15 +01:00
Sascha Mann
6a79c57a32 Include debug info in CI builds (#19) 2019-12-05 20:21:48 +01:00
Sascha Mann
2efcc69643 Add Julia 1.3.0 to versions 2019-11-26 21:12:15 +01:00
Sascha Mann
d8b4778b2d Add (scheduled) CI runs (#15) 2019-11-26 17:05:08 +01:00
Sascha Mann
c8ae0bede2 Update versions in README 2019-11-25 14:56:26 +01:00
Sascha Mann
34454fe7cf Remove nightly from README TODOs 2019-11-25 14:22:23 +01:00
Sascha Mann
689d600802 Fix Windows install script 2019-11-25 14:22:23 +01:00
Sascha Mann
df485a1da6 Fix macOS install script 2019-11-25 14:22:23 +01:00
Sascha Mann
41539df7fe Fix linux install script 2019-11-25 14:22:23 +01:00
Sascha Mann
767e91ee6e Support nightly Julia builds 2019-11-25 14:22:23 +01:00
Sascha Mann
b199a80ea6 Add script to build test release 2019-11-25 14:22:23 +01:00
Sascha Mann
67ef5af2fd Run npm audit fix 2019-11-20 20:00:27 +01:00
Sascha Mann
7e7f2c80d1 Add v1.3.0-rc5 2019-11-20 19:58:43 +01:00
Sascha Mann
062cb2b1a5 Default to Julia version 1 2019-11-20 19:58:43 +01:00
Sascha Mann
61303b8b4b Add warning about quotes around versions 2019-11-20 19:58:43 +01:00
Sascha Mann
0f80dc983e Remove unit tests from README ToDo 2019-11-20 19:58:43 +01:00
Sascha Mann
29cdcebc07 Add tests for range input 2019-11-20 19:58:43 +01:00
Sascha Mann
b75da77172 Update documentation of ranges 2019-11-20 19:58:43 +01:00
Sascha Mann
dc7c0defbe Always use hardcoded versions to match ranges 2019-11-20 19:58:43 +01:00
Sascha Mann
5354e1e908 Fall back to hardcoded versions when API errors
This is a temporary fix until we can get Julia versions directly
from julialang.org. Right now the GitHub API randomly fails due to
rate limiting which leads to builds failing even if a valid specific
version was specified.
2019-11-20 19:58:43 +01:00
Sascha Mann
2900978394 Document version ranges & tidy up README 2019-11-20 19:58:43 +01:00
Sascha Mann
0f0b1bb9ba Add some unit tests for getJuliaVersions 2019-11-20 19:58:43 +01:00
Sascha Mann
16c0aaf600 Refactor getJuliaVersion to make it testable 2019-11-20 19:58:43 +01:00
Sascha Mann
dc7dce0a2d Move functions to separate file for easier unit testing 2019-11-20 19:58:43 +01:00
Sascha Mann
3861b0a708 Print full response in debug logs 2019-11-20 19:58:43 +01:00
Sascha Mann
8007d2c472 Remove trailing v from versions before download 2019-11-20 19:58:43 +01:00
Sascha Mann
955535b050 Support version ranges as input version 2019-11-20 19:58:43 +01:00
dependabot-preview[bot]
53af7ff088 Bump @types/node from 12.6.9 to 12.12.7 (#12) 2019-11-10 16:40:58 +00:00
dependabot-preview[bot]
1fef3e0e61 Bump @types/jest from 24.0.16 to 24.0.22 (#13) 2019-11-10 16:38:24 +00:00
dependabot-preview[bot]
f126476e08 Bump ts-jest from 24.0.2 to 24.1.0 (#11) 2019-11-10 16:38:18 +00:00
dependabot-preview[bot]
48e7b97239 Bump @actions/github from 1.0.0 to 1.1.0 (#10) 2019-11-10 16:38:15 +00:00
dependabot-preview[bot]
5c3252fb75 Bump prettier from 1.18.2 to 1.19.1 (#9) 2019-11-10 16:34:19 +00:00
Sascha Mann
425aaf9321 Add Dependabot information to README 2019-11-10 12:27:28 +01:00
Sascha Mann
d82325fb86 Add bash script to build & tag release 2019-11-09 18:23:27 +01:00
Sascha Mann
5334cf1301 Update examples in README 2019-11-05 15:19:11 +01:00
Sascha Mann
df0206ad59 Fix link to renamed template in README 2019-10-05 18:43:04 +02:00
Sascha Mann
2898e23df6 Hide generated JS code from diffs and stats 2019-10-02 17:23:56 +02:00
Sascha Mann
17e9ecd238 Apply fix: vulnerability in transitive dependency
Fixed by running `npm audit fix`.

More details: https://www.npmjs.com/advisories/1164

`handlebars` is a transitive dependency of jest.
2019-09-25 16:28:53 +02:00
Sascha Mann
d6aba32515 Fix versions in README example 2019-08-21 16:40:16 +02:00
21 changed files with 7904 additions and 1321 deletions

2
.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
# Hide generated JS code from diffs and language stats
lib/*.js linguist-generated=true

29
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,29 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG] "
labels: bug
assignees: SaschaMann
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Workflow file to reproduce the behavior:
```yaml
```
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots/Build logs**
If applicable, add screenshots to help explain your problem.
If possible, set the repo secret `ACTIONS_STEP_DEBUG` to `true` to [enable debug logs](https://github.com/actions/toolkit/blob/master/docs/action-debugging.md#how-to-access-step-debug-logs) and run the build again for more detailled logs.
**Additional context**
Add any other context about the problem here.

View File

@@ -0,0 +1,37 @@
name: Example builds (nightly)
on:
push:
pull_request:
schedule:
- cron: '37 17 * * *'
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
julia-arch: [x64, x86]
os: [ubuntu-latest, macOS-latest, windows-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: "Install dependencies"
run: |
npm install
npm run build
npm run pack
- name: "Set up Julia (nightly)"
uses: ./
with:
version: nightly
arch: ${{ matrix.julia-arch }}
show-versioninfo: 'true'
- run: julia --version

35
.github/workflows/example-builds.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: Example builds
on: [push, pull_request]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
julia-version: ['1.0.5', '1', '^1.5.0-beta1']
julia-arch: [x64, x86]
os: [ubuntu-latest, macOS-latest, windows-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: "Install dependencies"
run: |
npm install
npm run build
npm run pack
- name: "Set up Julia"
id: setup-julia
uses: ./
with:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}
show-versioninfo: 'true'
- run: julia --version

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
node_modules/
__tests__/runner/*
!dist/

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "bin"]
path = bin
url = git@github.com:julia-actions/bin.git

11
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,11 @@
# Dev docs / Contributing guide
## Building and tagging a release (requires write access)
1. Test your changes, merge into `master`.
2. Checkout `master`.
3. Bump the version number in [`package.json`](package.json).
4. Run `./bin/build-release julia-actions/setup-julia` to create a release branch and build a release.
5. Push the branch (**without tags**) and verify that CI is passing on it.
6. Run `git push --tags --force` to update the tags.
7. Create a release for the `vX.Y.Z` tag.

View File

@@ -1,33 +1,61 @@
# setup-julia Action
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=julia-actions/setup-julia)](https://dependabot.com)
This action sets up a Julia environment for use in actions by downloading a specified version of Julia and adding it to PATH.
## Table of Contents
- [Table of Contents](#table-of-contents)
- [Usage](#usage)
- [Basic](#basic)
- [Julia Versions](#julia-versions)
- [Matrix Testing](#matrix-testing)
- [Versioning](#versioning)
- [Future plans & ideas](#future-plans--ideas)
- [Words of caution](#words-of-caution)
- [Licence info](#licence-info)
- [Debug logs](#debug-logs)
- [Third party information](#third-party-information)
## Usage
See [action.yml](action.yml).
Take a look at [github.com/exercism/julia](https://github.com/exercism/julia/pull/153) for an example, non-package Julia project making use of this action.
You can find a list of example workflows making use of this action here: [julia-actions/example-workflows](https://github.com/julia-actions/example-workflows).
### Basic:
### Basic
```yaml
steps:
- uses: actions/checkout@v1.0.0
- uses: julia-actions/setup-julia@v0.1.0
- uses: julia-actions/setup-julia@v1
with:
version: 1.0.4
- run: julia -e 'println("Hello, World!")'
```
### Matrix Testing:
### Julia Versions
You can either specify specific Julia versions or version ranges. If you specify a version range, the **highest** available Julia version that matches the range will be selected.
**Warning:** It is strongly recommended to wrap versions in quotes. Otherwise, the YAML parser used by GitHub Actions parses certain versions as numbers which causes the wrong version to be selected. For example, `1.0` is parsed as `1`.
#### Examples
- `1.2.0` is a valid semver version. The action will try to download exactly this version. If it's not available, the build step will fail.
- `1.0` is a version range that will match the highest available Julia version that starts with `1.0`, e.g. `1.0.5`, excluding pre-releases.
- `^1.3.0-rc1` is a **caret** version range that includes pre-releases starting at `rc1`. It matches all versions `≥ 1.3.0-rc1` and `< 2.0.0`.
- `~1.3.0-rc1` is a **tilde** version range that includes pre-releases starting at `rc1`. It matches all versions `≥ 1.3.0-rc1` and `< 1.4.0`.
- `^1.3.0-0` is a **caret** version range that includes _all_ pre-releases. It matches all versions `≥ 1.3.0-` and `< 2.0.0`.
- `~1.3.0-0` is a **tilde** version range that includes _all_ pre-releases. It matches all versions `≥ 1.3.0-` and `< 1.4.0`.
- `nightly` will install the latest nightly build.
Internally the action uses node's semver package to resolve version ranges. Its [documentation](https://github.com/npm/node-semver#advanced-range-syntax) contains more details on the version range syntax. You can test what version will be selected for a given input in this JavaScript [REPL](https://repl.it/@SaschaMann/setup-julia-version-logic).
#### WARNING: Version ranges are experimental and potentially out of date
Currently the list of available versions is hardcoded. You have to use the latest version of the action to be able to install the latest Julia versions. Once available we will use a list of versions provided on julialang.org.
### Matrix Testing
`bash` is chosen as shell to enforce consistent behaviour across operating systems. [Other shells](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell) are available but you may have to escape quotation marks or otherwise adjust the syntax.
#### 64-bit Julia only
@@ -37,16 +65,17 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1.0.4, 1.1.1, 1.2.0-rc3, 1.3.0-alpha]
julia-version: ['1.0', '1.2.0', '^1.3.0-rc1']
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v1.0.0
- name: "Set up Julia"
uses: julia-actions/setup-julia@v0.1.0
uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
- run: julia -e 'println("Hello, World!")'
shell: bash
```
#### 32-bit Julia
@@ -57,7 +86,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1.0.4, 1.1.1, 1.2.0-rc3, 1.3.0-alpha]
julia-version: ['1.0', '1.2.0', '^1.3.0-rc1']
julia-arch: [x64, x86]
os: [ubuntu-latest, windows-latest, macOS-latest]
# 32-bit Julia binaries are not available on macOS
@@ -68,11 +97,12 @@ jobs:
steps:
- uses: actions/checkout@v1.0.0
- name: "Set up Julia"
uses: julia-actions/setup-julia@v0.1.0
uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}
- run: julia -e 'println("Hello, World!")'
shell: bash
```
Alternatively, you can include specific version and OS combinations that will use 32-bit Julia:
@@ -83,28 +113,29 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1.0.4, 1.1.1, 1.2.0-rc3, 1.3.0-alpha]
julia-version: ['1.0', '1.2.0', '^1.3.0-rc1']
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-version: ['1.0.4']
julia-arch: x86
steps:
- uses: actions/checkout@v1.0.0
- name: "Set up Julia"
uses: julia-actions/setup-julia@v0.1.0
uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
- run: julia -e 'println("Hello, World!")'
shell: bash
```
## 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.
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. [Dependabot](https://dependabot.com/) can also be used to automatically create Pull Requests to update actions used in your workflows.
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.
@@ -119,34 +150,11 @@ steps:
- uses: julia-actions/setup-julia@v0.1.0 # specific version tag
```
## Future plans & ideas
## Debug logs
In no particular order:
You can enable [Step Debug Logs](https://github.com/actions/toolkit/blob/main/docs/action-debugging.md#step-debug-logs) for more detailed logs.
Note that when debug logs are enabled, a request will be sent to `https://httpbin.julialang.org/ip` and the runner's IP will be printed to the debug logs.
### `setup-julia`:
* 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 support for nightly Julia builds.
* Write some unit tests for the action.
* Add CI script that checks if tags have been updated on release.
* Hash and signature checks.
### Other Julia-related actions:
These would be nice to have but I make no promises of ever creating them myself.
* Default build script for packages, similar to how Travis CI works if you don't specify a script.
* Find out if it's possible to cache packages using [`@actions/tool-cache`](https://github.com/actions/toolkit/tree/master/packages/tool-cache).
* Actions for standard tools like Documenter, Coverage reporting and so on
* Actions for registering and tagging package releases instead of relying on external apps.
## Words of caution
This action will likely be updated quite frequently in the near future. I'm sharing it now so that others who want to try out Julia on GitHub actions can do so without relying on Docker.
**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.
## 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.
## Third party information
Parts of this software have been derived from other open source software.
See [THIRD_PARTY_NOTICE.md](THIRD_PARTY_NOTICE.md) for details.

55
THIRD_PARTY_NOTICE.md Normal file
View File

@@ -0,0 +1,55 @@
# Third Party Notices and Information
Parts of this software have been derived from other open source software.
Find their full licence information below.
- [`setup-go` action](#setup-go-action)
- [TypeScript Action Template](#typescript-action-template)
## [`setup-go` action](https://github.com/actions/setup-go)
> The MIT License (MIT)
>
> Copyright (c) 2018 GitHub, Inc. and 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.
## [TypeScript Action Template](https://github.com/actions/typescript-action)
> The MIT License (MIT)
>
> Copyright (c) 2018 GitHub, Inc. and 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.

View File

@@ -1,3 +1,50 @@
describe('TODO - Add a test suite', () => {
it('TODO - Add a test', async () => {})
import * as installer from '../src/installer'
import * as semver from 'semver'
const testVersions = ['v1.3.0-rc4', 'v1.3.0-rc3', 'v1.3.0-rc2', 'v1.0.5', 'v1.2.0', 'v1.3.0-rc1', 'v1.2.0-rc3', 'v1.3.0-alpha', 'v1.2.0-rc2', 'v1.2.0-rc1', 'v1.1.1', 'v1.0.4', 'v1.1.0', 'v1.1.0-rc2', 'v1.1.0-rc1', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0']
describe('installer tests', () => {
describe('version matching', () => {
describe('specific versions', () => {
it('Doesn\'t change the version when given a valid semver version', async () => {
expect(await installer.getJuliaVersion([], '1.0.5')).toEqual('1.0.5')
expect(await installer.getJuliaVersion(['v1.0.5', 'v1.0.6'], '1.0.5')).toEqual('1.0.5')
expect(await installer.getJuliaVersion(['v1.0.4', 'v1.0.5'], '1.0.5')).toEqual('1.0.5')
expect(await installer.getJuliaVersion(['v1.0.4'], '1.0.5')).toEqual('1.0.5')
expect(await installer.getJuliaVersion([], '1.3.0-alpha')).toEqual('1.3.0-alpha')
expect(await installer.getJuliaVersion(['v1.2.0', 'v1.3.0-alpha', 'v1.3.0-rc1', 'v1.3.0'], '1.3.0-alpha')).toEqual('1.3.0-alpha')
expect(await installer.getJuliaVersion([], '1.3.0-rc2')).toEqual('1.3.0-rc2')
})
it('Doesn\'t change the version when given `nightly`', async () => {
expect(await installer.getJuliaVersion([], 'nightly')).toEqual('nightly')
expect(await installer.getJuliaVersion(testVersions, 'nightly')).toEqual('nightly')
})
})
describe('version ranges', () => {
it('Chooses the highest available version that matches the input', async () => {
expect(await installer.getJuliaVersion(testVersions, '1')).toEqual('1.2.0')
expect(await installer.getJuliaVersion(testVersions, '1.0')).toEqual('1.0.5')
expect(await installer.getJuliaVersion(testVersions, '^1.3.0-rc1')).toEqual('1.3.0-rc4')
expect(await installer.getJuliaVersion(testVersions, '^1.2.0-rc1')).toEqual('1.2.0')
})
})
describe('invalid version range (#38)', () => {
it('Throws an error if a version range does not match any available version', () => {
expect(() => {
installer.getJuliaVersion(['v1.5.0-rc1', 'v1.5.0-beta1', 'v1.4.2', 'v1.4.1', 'v1.4.0', 'v1.4.0-rc2', 'v1.4.0-rc1'], '1.6')
}).toThrowError()
})
})
})
describe('node-semver behaviour', () => {
describe('Windows installer change', () => {
it('Correctly understands >1.4.0', () => {
expect(semver.gtr('1.4.0-rc1', '1.3', {includePrerelease: true})).toBeTruthy()
expect(semver.gtr('1.4.0-DEV', '1.3', {includePrerelease: true})).toBeTruthy()
expect(semver.gtr('1.3.1', '1.3', {includePrerelease: true})).toBeFalsy()
expect(semver.gtr('1.3.2-rc1', '1.3', {includePrerelease: true})).toBeFalsy()
})
})
})
})

View File

@@ -4,14 +4,21 @@ author: 'Sascha Mann'
inputs:
version:
description: 'The Julia version to download (if necessary) and use. Example: 1.0.4'
default: '1.0.4'
default: '1'
arch:
description: 'Architecture of the Julia binaries. Defaults to x64.'
required: false
default: 'x64'
show-versioninfo:
description: 'Display InteractiveUtils.versioninfo() after installing'
required: false
default: 'false'
outputs:
julia-bindir:
description: 'Path to the directory containing the Julia executable. Equivalent to JULIA_BINDIR: https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_BINDIR'
runs:
using: 'node12'
main: 'lib/setup-julia.js'
main: 'dist/index.js'
branding:
icon: 'download'
color: 'green'

1
bin Submodule

Submodule bin added at 9ceca17c9c

4683
dist/index.js vendored Normal file

File diff suppressed because it is too large Load Diff

BIN
dist/unzip vendored Normal file

Binary file not shown.

View File

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

137
lib/installer.js generated Normal file
View File

@@ -0,0 +1,137 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const exec = __importStar(require("@actions/exec"));
const tc = __importStar(require("@actions/tool-cache"));
const fs = __importStar(require("fs"));
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const semver = __importStar(require("semver"));
// Store information about the environment
const osPlat = os.platform(); // possible values: win32 (Windows), linux (Linux), darwin (macOS)
core.debug(`platform: ${osPlat}`);
// This is temporary until we have a better way of fetching releases (see #1, #4 for details)
exports.juliaVersions = ['v1.5.2', 'v1.5.1', 'v1.5.0', 'v1.5.0-rc2', 'v1.5.0-rc1', 'v1.5.0-beta1', 'v1.4.2', 'v1.4.1', 'v1.4.0', 'v1.4.0-rc2', 'v1.4.0-rc1', 'v1.3.1', 'v1.3.0', 'v1.3.0-rc5', 'v1.3.0-rc4', 'v1.3.0-rc3', 'v1.3.0-rc2', 'v1.0.5', 'v1.2.0', 'v1.3.0-rc1', 'v1.2.0-rc3', 'v1.3.0-alpha', 'v1.2.0-rc2', 'v1.2.0-rc1', 'v1.1.1', 'v1.0.4', 'v1.1.0', 'v1.1.0-rc2', 'v1.1.0-rc1', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0', 'v0.7.0', 'v1.0.0-rc1', 'v0.7.0-rc3', 'v0.7.0-rc2', 'v0.7.0-rc1', 'v0.7.0-beta2', 'v0.6.4', 'v0.7.0-beta', 'v0.7.0-alpha', 'v0.6.3', 'v0.6.2', 'v0.6.1', 'v0.6.0', 'v0.6.0-rc3', 'v0.6.0-rc2', 'v0.5.2', 'v0.6.0-rc1', 'v0.6.0-pre.beta', 'v0.5.1', 'v0.6.0-pre.alpha', 'v0.5.0', 'v0.4.7', 'v0.5.0-rc4', 'v0.5.0-rc3', 'v0.5.0-rc2', 'v0.5.0-rc1', 'v0.5.0-rc0', 'v0.4.6', 'v0.4.5', 'v0.4.4', 'v0.4.3', 'v0.4.2', 'v0.4.1', 'v0.3.12', 'v0.4.0', 'v0.4.0-rc4', 'v0.4.0-rc3', 'v0.4.0-rc2', 'v0.4.0-rc1', 'v0.3.11', 'v0.3.10', 'v0.3.9', 'v0.3.8', 'v0.3.7', 'v0.3.6', 'v0.3.5', 'v0.3.4', 'v0.3.3', 'v0.3.2', 'v0.3.1', 'v0.3.0', 'v0.3.0-rc4', 'v0.3.0-rc3', 'v0.3.0-rc2', 'v0.3.0-rc1', 'v0.2.0-rc1', 'v0.2.0-rc3', 'v0.2.0-rc4', 'v0.2.0', 'v0.2.0-rc2'];
function getJuliaVersion(availableReleases, versionInput) {
if (semver.valid(versionInput) == versionInput) {
// versionInput is a valid version, use it directly
return versionInput;
}
// nightlies
if (versionInput == 'nightly') {
return 'nightly';
}
// Use the highest available version that matches versionInput
let version = semver.maxSatisfying(availableReleases, versionInput);
if (version == null) {
throw new Error(`Could not find a Julia version that matches ${versionInput}`);
}
// GitHub tags start with v, remove it
version = version.replace(/^v/, '');
return version;
}
exports.getJuliaVersion = getJuliaVersion;
function getMajorMinorVersion(version) {
return version.split('.').slice(0, 2).join('.');
}
function getDownloadURL(version, arch) {
let platform;
if (osPlat === 'win32') { // Windows
platform = 'winnt';
}
else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw new Error('32-bit Julia is not available on macOS');
}
platform = 'mac';
}
else if (osPlat === 'linux') { // Linux
platform = 'linux';
}
else {
throw new Error(`Platform ${osPlat} is not supported`);
}
// nightlies
if (version == 'nightly') {
const baseURL = 'https://julialangnightlies-s3.julialang.org/bin';
return `${baseURL}/${platform}/${arch}/${getFileName('latest', arch)}`;
}
// normal versions
const baseURL = 'https://julialang-s3.julialang.org/bin';
const versionDir = getMajorMinorVersion(version);
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}`;
}
function getFileName(version, arch) {
let versionExt, ext;
if (osPlat === 'win32') { // Windows
versionExt = arch == 'x64' ? '-win64' : '-win32';
ext = 'exe';
}
else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw new Error('32-bit Julia is not available on macOS');
}
versionExt = '-mac64';
ext = 'dmg';
}
else if (osPlat === 'linux') { // Linux
if (version == 'latest') { // nightly version
versionExt = arch == 'x64' ? '-linux64' : '-linux32';
}
else {
versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686';
}
ext = 'tar.gz';
}
else {
throw new Error(`Platform ${osPlat} is not supported`);
}
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);
const tempInstallDir = fs.mkdtempSync(`julia-${arch}-${version}-`);
// Install it
switch (osPlat) {
case 'linux':
// tc.extractTar doesn't support stripping components, so we have to call tar manually
yield exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir]);
return tempInstallDir;
case 'win32':
if (version == 'nightly' || semver.gtr(version, '1.3', { includePrerelease: true })) {
// The installer changed in 1.4: https://github.com/JuliaLang/julia/blob/ef0c9108b12f3ae177c51037934351ffa703b0b5/NEWS.md#build-system-changes
yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`]);
}
else {
yield exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`]);
}
return tempInstallDir;
case 'darwin':
yield exec.exec('hdiutil', ['attach', juliaDownloadPath]);
yield exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`]);
return path.join(tempInstallDir, 'julia');
default:
throw new Error(`Platform ${osPlat} is not supported`);
}
});
}
exports.installJulia = installJulia;

121
lib/setup-julia.js generated
View File

@@ -18,103 +18,70 @@ Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const exec = __importStar(require("@actions/exec"));
const tc = __importStar(require("@actions/tool-cache"));
const os = __importStar(require("os"));
const fs = __importStar(require("fs"));
const https = __importStar(require("https"));
const path = __importStar(require("path"));
// Store information about the environment
const osPlat = os.platform(); // possible values: win32 (Windows), linux (Linux), darwin (macOS)
core.debug(`platform: ${osPlat}`);
function getMajorMinorVersion(version) {
return version.split('.').slice(0, 2).join('.');
}
function getDownloadURL(version, arch) {
const baseURL = 'https://julialang-s3.julialang.org/bin';
let platform;
const versionDir = getMajorMinorVersion(version);
if (osPlat === 'win32') { // Windows
platform = 'winnt';
}
else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS';
}
platform = 'mac';
}
else if (osPlat === 'linux') { // Linux
platform = 'linux';
}
else {
throw `Platform ${osPlat} is not supported`;
}
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}`;
}
function getFileName(version, arch) {
let versionExt, ext;
if (osPlat === 'win32') { // Windows
versionExt = arch == 'x64' ? '-win64' : '-win32';
ext = 'exe';
}
else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS';
}
versionExt = '-mac64';
ext = 'dmg';
}
else if (osPlat === 'linux') { // Linux
versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686';
ext = 'tar.gz';
}
else {
throw `Platform ${osPlat} is not supported`;
}
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`;
}
});
}
const installer = __importStar(require("./installer"));
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const version = core.getInput('version');
// Debugging info
if (core.isDebug()) {
// Log Runner IP Address
https.get('https://httpbin.julialang.org/ip', resp => {
let data = '';
resp.on('data', chunk => {
data += chunk;
});
resp.on('end', () => {
core.debug(`Runner IP address: ${JSON.parse(data).origin}`);
});
}).on('error', err => {
core.debug(`ERROR: Could not retrieve runner IP: ${err}`);
});
}
// Inputs
const versionInput = core.getInput('version');
const arch = core.getInput('arch');
// It can easily happen that, for example, a workflow file contains an input `version: ${{ matrix.julia-version }}`
// while the strategy matrix only contains a key `${{ matrix.version }}`.
// In that case, we want the action to fail, rather than trying to download julia from an URL that's missing parts and 404ing.
// We _could_ fall back to the default but that means that builds silently do things differently than they're meant to, which
// is worse than failing the build.
if (!versionInput) {
throw new Error('Version input must not be null');
}
if (!arch) {
throw new Error(`Arch input must not be null`);
}
const availableReleases = installer.juliaVersions;
const version = installer.getJuliaVersion(availableReleases, versionInput);
core.debug(`selected Julia version: ${arch}/${version}`);
// Search in cache
let juliaPath;
juliaPath = tc.find('julia', version, arch);
if (!juliaPath) {
core.debug(`could not find Julia ${version} in cache`);
const juliaInstallationPath = yield installJulia(version, arch);
const juliaInstallationPath = yield installer.installJulia(version, arch);
// Add it to cache
juliaPath = yield tc.cacheDir(juliaInstallationPath, 'julia', version, arch);
core.debug(`added Julia to cache: ${juliaPath}`);
// Remove temporary dir
fs.rmdirSync(juliaInstallationPath, { recursive: true });
}
else {
core.debug(`using cached version of Julia: ${juliaPath}`);
}
// Add it to PATH
core.addPath(path.join(juliaPath, 'bin'));
// Test if Julia has been installed by showing versioninfo()
yield exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()']);
// Set output
core.setOutput('julia-bindir', path.join(juliaPath, 'bin'));
// Test if Julia has been installed
exec.exec('julia', ['--version']);
// If enabled, also show the full version info
if (core.getInput('show-versioninfo') == 'true') {
exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()']);
}
}
catch (error) {
core.setFailed(error.message);

3660
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,12 @@
{
"name": "setup-julia",
"version": "0.1.0",
"version": "1.3.0",
"private": true,
"description": "setup Julia action",
"main": "lib/setup-julia.js",
"scripts": {
"build": "tsc",
"format": "prettier --single-quote --print-width 120 --tab-width 4 --no-semi --write **/*.ts",
"format-check": "prettier --single-quote --print-width 120 --tab-width 4 --no-semi --check **/*.ts",
"pack": "ncc build",
"test": "jest"
},
"repository": {
@@ -22,21 +21,21 @@
"author": "Sascha Mann <git@mail.saschamann.eu>",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.0.0",
"@actions/io": "^1.0.0",
"@actions/core": "^1.2.4",
"@actions/exec": "^1.0.0",
"@actions/github": "^1.0.0",
"@actions/io": "^1.0.0",
"@actions/tool-cache": "^1.0.0",
"semver": "^6.1.1"
"semver": "^6.3.0"
},
"devDependencies": {
"@types/jest": "^24.0.13",
"@types/node": "^12.0.4",
"@types/node": "^12.12.7",
"@types/semver": "^6.0.0",
"@zeit/ncc": "^0.22.0",
"jest": "^24.8.0",
"jest-circus": "^24.7.1",
"prettier": "^1.17.1",
"ts-jest": "^24.0.2",
"ts-jest": "^26.0.0",
"typescript": "^3.5.1"
}
}

129
src/installer.ts Normal file
View File

@@ -0,0 +1,129 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as tc from '@actions/tool-cache'
import * as fs from 'fs'
import * as os from 'os'
import * as path from 'path'
import * as semver from 'semver'
// Store information about the environment
const osPlat = os.platform() // possible values: win32 (Windows), linux (Linux), darwin (macOS)
core.debug(`platform: ${osPlat}`)
// This is temporary until we have a better way of fetching releases (see #1, #4 for details)
export const juliaVersions = ['v1.5.2', 'v1.5.1', 'v1.5.0', 'v1.5.0-rc2', 'v1.5.0-rc1', 'v1.5.0-beta1', 'v1.4.2', 'v1.4.1', 'v1.4.0', 'v1.4.0-rc2', 'v1.4.0-rc1', 'v1.3.1', 'v1.3.0', 'v1.3.0-rc5', 'v1.3.0-rc4', 'v1.3.0-rc3', 'v1.3.0-rc2', 'v1.0.5', 'v1.2.0', 'v1.3.0-rc1', 'v1.2.0-rc3', 'v1.3.0-alpha', 'v1.2.0-rc2', 'v1.2.0-rc1', 'v1.1.1', 'v1.0.4', 'v1.1.0', 'v1.1.0-rc2', 'v1.1.0-rc1', 'v1.0.3', 'v1.0.2', 'v1.0.1', 'v1.0.0', 'v0.7.0', 'v1.0.0-rc1', 'v0.7.0-rc3', 'v0.7.0-rc2', 'v0.7.0-rc1', 'v0.7.0-beta2', 'v0.6.4', 'v0.7.0-beta', 'v0.7.0-alpha', 'v0.6.3', 'v0.6.2', 'v0.6.1', 'v0.6.0', 'v0.6.0-rc3', 'v0.6.0-rc2', 'v0.5.2', 'v0.6.0-rc1', 'v0.6.0-pre.beta', 'v0.5.1', 'v0.6.0-pre.alpha', 'v0.5.0', 'v0.4.7', 'v0.5.0-rc4', 'v0.5.0-rc3', 'v0.5.0-rc2', 'v0.5.0-rc1', 'v0.5.0-rc0', 'v0.4.6', 'v0.4.5', 'v0.4.4', 'v0.4.3', 'v0.4.2', 'v0.4.1', 'v0.3.12', 'v0.4.0', 'v0.4.0-rc4', 'v0.4.0-rc3', 'v0.4.0-rc2', 'v0.4.0-rc1', 'v0.3.11', 'v0.3.10', 'v0.3.9', 'v0.3.8', 'v0.3.7', 'v0.3.6', 'v0.3.5', 'v0.3.4', 'v0.3.3', 'v0.3.2', 'v0.3.1', 'v0.3.0', 'v0.3.0-rc4', 'v0.3.0-rc3', 'v0.3.0-rc2', 'v0.3.0-rc1', 'v0.2.0-rc1', 'v0.2.0-rc3', 'v0.2.0-rc4', 'v0.2.0', 'v0.2.0-rc2']
export function getJuliaVersion(availableReleases: string[], versionInput: string): string {
if (semver.valid(versionInput) == versionInput) {
// versionInput is a valid version, use it directly
return versionInput
}
// nightlies
if (versionInput == 'nightly') {
return 'nightly'
}
// Use the highest available version that matches versionInput
let version = semver.maxSatisfying(availableReleases, versionInput)
if (version == null) {
throw new Error(`Could not find a Julia version that matches ${versionInput}`)
}
// GitHub tags start with v, remove it
version = version.replace(/^v/, '')
return version
}
function getMajorMinorVersion(version: string): string {
return version.split('.').slice(0, 2).join('.')
}
function getDownloadURL(version: string, arch: string): string {
let platform: string
if (osPlat === 'win32') { // Windows
platform = 'winnt'
} else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw new Error('32-bit Julia is not available on macOS')
}
platform = 'mac'
} else if (osPlat === 'linux') { // Linux
platform = 'linux'
} else {
throw new Error(`Platform ${osPlat} is not supported`)
}
// nightlies
if (version == 'nightly') {
const baseURL = 'https://julialangnightlies-s3.julialang.org/bin'
return `${baseURL}/${platform}/${arch}/${getFileName('latest', arch)}`
}
// normal versions
const baseURL = 'https://julialang-s3.julialang.org/bin'
const versionDir = getMajorMinorVersion(version)
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}`
}
function getFileName(version: string, arch: string): string {
let versionExt: string, ext: string
if (osPlat === 'win32') { // Windows
versionExt = arch == 'x64' ? '-win64' : '-win32'
ext = 'exe'
} else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw new Error('32-bit Julia is not available on macOS')
}
versionExt = '-mac64'
ext = 'dmg'
} else if (osPlat === 'linux') { // Linux
if (version == 'latest') { // nightly version
versionExt = arch == 'x64' ? '-linux64' : '-linux32'
} else {
versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686'
}
ext = 'tar.gz'
} else {
throw new Error(`Platform ${osPlat} is not supported`)
}
return `julia-${version}${versionExt}.${ext}`
}
export 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)
const tempInstallDir = fs.mkdtempSync(`julia-${arch}-${version}-`)
// Install it
switch (osPlat) {
case 'linux':
// tc.extractTar doesn't support stripping components, so we have to call tar manually
await exec.exec('tar', ['xf', juliaDownloadPath, '--strip-components=1', '-C', tempInstallDir])
return tempInstallDir
case 'win32':
if (version == 'nightly' || semver.gtr(version, '1.3', {includePrerelease: true})) {
// The installer changed in 1.4: https://github.com/JuliaLang/julia/blob/ef0c9108b12f3ae177c51037934351ffa703b0b5/NEWS.md#build-system-changes
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/SILENT /dir=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`])
} else {
await exec.exec('powershell', ['-Command', `Start-Process -FilePath ${juliaDownloadPath} -ArgumentList "/S /D=${path.join(process.cwd(), tempInstallDir)}" -NoNewWindow -Wait`])
}
return tempInstallDir
case 'darwin':
await exec.exec('hdiutil', ['attach', juliaDownloadPath])
await exec.exec('/bin/bash', ['-c', `cp -a /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia ${tempInstallDir}`])
return path.join(tempInstallDir, 'julia')
default:
throw new Error(`Platform ${osPlat} is not supported`)
}
}

View File

@@ -2,87 +2,50 @@ import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as tc from '@actions/tool-cache'
import * as os from 'os'
import * as fs from 'fs'
import * as https from 'https'
import * as path from 'path'
// Store information about the environment
const osPlat = os.platform() // possible values: win32 (Windows), linux (Linux), darwin (macOS)
core.debug(`platform: ${osPlat}`)
function getMajorMinorVersion(version: string): string {
return version.split('.').slice(0, 2).join('.')
}
function getDownloadURL(version: string, arch: string): string {
const baseURL = 'https://julialang-s3.julialang.org/bin'
let platform: string
const versionDir = getMajorMinorVersion(version)
if (osPlat === 'win32') { // Windows
platform = 'winnt'
} else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS'
}
platform = 'mac'
} else if (osPlat === 'linux') { // Linux
platform = 'linux'
} else {
throw `Platform ${osPlat} is not supported`
}
return `${baseURL}/${platform}/${arch}/${versionDir}/${getFileName(version, arch)}`
}
function getFileName(version: string, arch: string): string {
let versionExt: string, ext: string
if (osPlat === 'win32') { // Windows
versionExt = arch == 'x64' ? '-win64' : '-win32'
ext = 'exe'
} else if (osPlat === 'darwin') { // macOS
if (arch == 'x86') {
throw '32-bit Julia is not available on macOS'
}
versionExt = '-mac64'
ext = 'dmg'
} else if (osPlat === 'linux') { // Linux
versionExt = arch == 'x64' ? '-linux-x86_64' : '-linux-i686'
ext = 'tar.gz'
} else {
throw `Platform ${osPlat} is not supported`
}
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`
}
}
import * as installer from './installer'
async function run() {
try {
const version = core.getInput('version')
// Debugging info
if (core.isDebug()) {
// Log Runner IP Address
https.get('https://httpbin.julialang.org/ip', resp => {
let data = ''
resp.on('data', chunk => {
data += chunk
})
resp.on('end', () => {
core.debug(`Runner IP address: ${JSON.parse(data).origin}`)
})
}).on('error', err => {
core.debug(`ERROR: Could not retrieve runner IP: ${err}`)
})
}
// Inputs
const versionInput = core.getInput('version')
const arch = core.getInput('arch')
// It can easily happen that, for example, a workflow file contains an input `version: ${{ matrix.julia-version }}`
// while the strategy matrix only contains a key `${{ matrix.version }}`.
// In that case, we want the action to fail, rather than trying to download julia from an URL that's missing parts and 404ing.
// We _could_ fall back to the default but that means that builds silently do things differently than they're meant to, which
// is worse than failing the build.
if (!versionInput) {
throw new Error('Version input must not be null')
}
if (!arch) {
throw new Error(`Arch input must not be null`)
}
const availableReleases = installer.juliaVersions
const version = installer.getJuliaVersion(availableReleases, versionInput)
core.debug(`selected Julia version: ${arch}/${version}`)
// Search in cache
@@ -91,20 +54,31 @@ async function run() {
if (!juliaPath) {
core.debug(`could not find Julia ${version} in cache`)
const juliaInstallationPath = await installJulia(version, arch);
const juliaInstallationPath = await installer.installJulia(version, arch);
// Add it to cache
juliaPath = await tc.cacheDir(juliaInstallationPath, 'julia', version, arch)
core.debug(`added Julia to cache: ${juliaPath}`)
// Remove temporary dir
fs.rmdirSync(juliaInstallationPath, {recursive: true})
} else {
core.debug(`using cached version of Julia: ${juliaPath}`)
}
// Add it to PATH
core.addPath(path.join(juliaPath, 'bin'))
// Set output
core.setOutput('julia-bindir', path.join(juliaPath, 'bin'))
// Test if Julia has been installed by showing versioninfo()
await exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()'])
// Test if Julia has been installed
exec.exec('julia', ['--version'])
// If enabled, also show the full version info
if (core.getInput('show-versioninfo') == 'true') {
exec.exec('julia', ['-e', 'using InteractiveUtils; versioninfo()'])
}
} catch (error) {
core.setFailed(error.message)
}