Skip to content

Commit

Permalink
Ease Elixir escripts execution by adding ${HOME}/.mix/escripts to path (
Browse files Browse the repository at this point in the history
#153)

* feat: add escripts to path

* Update src/install-elixir.ps1

Co-authored-by: Paulo F. Oliveira <paulo.ferraz.oliveira@gmail.com>

* add github action combo to test escript

* force install

* use os homedir for escript install path

Co-authored-by: Paulo F. Oliveira <paulo.ferraz.oliveira@gmail.com>
  • Loading branch information
btkostner and paulo-ferraz-oliveira committed Nov 22, 2022
1 parent c373088 commit b980a5a
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ jobs:
otp-version: '24'
os: 'ubuntu-latest'
disable_problem_matchers: true
- elixir-version: 'v1.13'
otp-version: '24'
escript_packages: 'hex protobuf'
escript_script: 'protoc-gen-elixir --version'
os: 'ubuntu-latest'
steps:
- uses: actions/checkout@v3
- name: Use erlef/setup-beam
Expand Down Expand Up @@ -184,6 +189,11 @@ jobs:
cd test-projects/gleam_gleam
gleam test
if: ${{ matrix.combo.gleam-version && matrix.combo.otp-version && !matrix.combo.rebar3-version }}
- name: Run escript
run: |
mix escript.install --force ${{matrix.combo.escript_packages}}
${{matrix.combo.escript_script}}
if: ${{matrix.combo.escript_packages && matrix.combo.escript_script}}
environment_variables:
name: Environment variables
runs-on: ${{matrix.combo.os}}
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ jobs:
otp-version: '24'
rebar3-version: '3.16'
os: 'windows-latest'
- elixir-version: 'v1.13'
otp-version: '24'
escript_packages: 'hex protobuf'
escript_script: 'protoc-gen-elixir --version'
os: 'windows-latest'
steps:
- uses: actions/checkout@v3
- name: Use erlef/setup-beam
Expand Down Expand Up @@ -82,6 +87,11 @@ jobs:
cd test-projects/erlang_rebar3
rebar3 ct
if: ${{matrix.combo.rebar3-version}}
- name: Run escript
run: |
mix escript.install --force ${{matrix.combo.escript_packages}}
${{matrix.combo.escript_script}}
if: ${{matrix.combo.escript_packages && matrix.combo.escript_script}}
environment_variables:
name: Environment variables
runs-on: ${{matrix.combo.os}}
Expand Down
2 changes: 2 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7193,6 +7193,7 @@ module.exports = {

const core = __nccwpck_require__(2186)
const { exec } = __nccwpck_require__(1514)
const os = __nccwpck_require__(2037)
const path = __nccwpck_require__(1017)
const semver = __nccwpck_require__(1383)
const https = __nccwpck_require__(5687)
Expand Down Expand Up @@ -7269,6 +7270,7 @@ async function maybeInstallElixir(elixirSpec, otpVersion) {
`##[add-matcher]${path.join(matchersPath, 'elixir-matchers.json')}`,
)
}
core.addPath(`${os.homedir()}/.mix/escripts`)
core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/elixir/bin`)
console.log('##[endgroup]')

Expand Down
3 changes: 3 additions & 0 deletions dist/install-elixir.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ $ProgressPreference="Continue"
Write-Output "Installed Elixir version follows"
& "${DIR_FOR_BIN}/bin/elixir" "-v" | Write-Output

$ProgressPreference="Continue"
New-Item "%UserProfile%/.mix/escripts" -ItemType Directory | Out-Null

"INSTALL_DIR_FOR_ELIXIR=${Env:RUNNER_TEMP}/${DIR_FOR_BIN}" | Out-File -FilePath ${Env:GITHUB_ENV} -Encoding utf8 -Append
2 changes: 2 additions & 0 deletions dist/install-elixir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ unzip -q -o -d "${DIR_FOR_BIN}" "${FILE_OUTPUT}"
echo "Installed Elixir version follows"
${DIR_FOR_BIN}/bin/elixir -v

mkdir -p "${HOME}/.mix/escripts"

echo "INSTALL_DIR_FOR_ELIXIR=${RUNNER_TEMP}/${DIR_FOR_BIN}" >> "${GITHUB_ENV}"
3 changes: 3 additions & 0 deletions src/install-elixir.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ $ProgressPreference="Continue"
Write-Output "Installed Elixir version follows"
& "${DIR_FOR_BIN}/bin/elixir" "-v" | Write-Output

$ProgressPreference="Continue"
New-Item "%UserProfile%/.mix/escripts" -ItemType Directory | Out-Null

"INSTALL_DIR_FOR_ELIXIR=${Env:RUNNER_TEMP}/${DIR_FOR_BIN}" | Out-File -FilePath ${Env:GITHUB_ENV} -Encoding utf8 -Append
2 changes: 2 additions & 0 deletions src/install-elixir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ unzip -q -o -d "${DIR_FOR_BIN}" "${FILE_OUTPUT}"
echo "Installed Elixir version follows"
${DIR_FOR_BIN}/bin/elixir -v

mkdir -p "${HOME}/.mix/escripts"

echo "INSTALL_DIR_FOR_ELIXIR=${RUNNER_TEMP}/${DIR_FOR_BIN}" >> "${GITHUB_ENV}"
2 changes: 2 additions & 0 deletions src/setup-beam.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const core = require('@actions/core')
const { exec } = require('@actions/exec')
const os = require('os')
const path = require('path')
const semver = require('semver')
const https = require('https')
Expand Down Expand Up @@ -76,6 +77,7 @@ async function maybeInstallElixir(elixirSpec, otpVersion) {
`##[add-matcher]${path.join(matchersPath, 'elixir-matchers.json')}`,
)
}
core.addPath(`${os.homedir()}/.mix/escripts`)
core.addPath(`${process.env.RUNNER_TEMP}/.setup-beam/elixir/bin`)
console.log('##[endgroup]')

Expand Down

0 comments on commit b980a5a

Please sign in to comment.