Skip to content

Commit

Permalink
Fix as per broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ferraz-oliveira committed Mar 29, 2021
1 parent a1371c6 commit 4690169
Show file tree
Hide file tree
Showing 18 changed files with 129 additions and 109 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,21 @@ jobs:
run: erl -version
- name: Output Elixir version
run: echo "Elixir ${{steps.setup-elixir.outputs.elixir-version}}"
if: ${{matrix.pair.elixir-version}}
- name: Run Mix project tests
run: |-
cd test-projects/mix
mix deps.get
mix test
if: ${{matrix.pair.elixir-version}}
- name: Run rebar3 project tests
run: |
cd test-projects/rebar3
rebar3 as test do xref,dialyzer,ct,cover
if: ${{matrix.pair.rebar3-version}}
- name: Output rebar3 version
run: echo "rebar3 ${{steps.setup-elixir.outputs.rebar3-version}}"
if: ${{matrix.pair.rebar3-version}}
- name: Check rebar3 version
run: rebar3 version
if: ${{matrix.pair.rebar3-version}}
8 changes: 4 additions & 4 deletions __tests__/setup-beam.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ async function test() {
vsn = await setupElixir.getOTPVersion('^19.3', 'ubuntu-18.04')
deepStrictEqual(vsn, 'OTP-19.3.6')

vsn = await setupElixir.getElixirVersion('v1.10.x', '23')
vsn = await setupElixir.getElixirVersion('v1.10.x', 'OTP-23')
deepStrictEqual(vsn, ['v1.10.4', '23'])

vsn = await setupElixir.getElixirVersion('^v1.10', '23')
deepStrictEqual(vsn, ['v1.10.4', '23'])
vsn = await setupElixir.getElixirVersion('^v1.10', 'OTP-23')
deepStrictEqual(vsn, ['v1.11.3', '23'])

vsn = await setupElixir.getElixirVersion('v1.11.0-rc.0', '23')
vsn = await setupElixir.getElixirVersion('v1.11.0-rc.0', 'OTP-23')
deepStrictEqual(vsn, ['v1.11.0-rc.0', '23'])

vsn = await setupElixir.getRebar3Version('3.x')
Expand Down
7 changes: 6 additions & 1 deletion dist/.github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
name: >
Pre-release integration tests
(Erlang/OTP ${{matrix.pair.otp-version}},
Elixir ${{matrix.pair.elixir-version},
Elixir ${{matrix.pair.elixir-version}},
rebar3 ${{matrix.pair.rebar3-version}})
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -70,16 +70,21 @@ jobs:
run: erl -version
- name: Output Elixir version
run: echo "Elixir ${{steps.setup-elixir.outputs.elixir-version}}"
if: ${{matrix.pair.elixir-version}}
- name: Run Mix project tests
run: |-
cd test-projects/mix
mix deps.get
mix test
if: ${{matrix.pair.elixir-version}}
- name: Run rebar3 project tests
run: |
cd test-projects/rebar3
rebar3 as test do xref,dialyzer,ct,cover
if: ${{matrix.pair.rebar3-version}}
- name: Output rebar3 version
run: echo "rebar3 ${{steps.setup-elixir.outputs.rebar3-version}}"
if: ${{matrix.pair.rebar3-version}}
- name: Check rebar3 version
run: rebar3 version
if: ${{matrix.pair.rebar3-version}}
7 changes: 6 additions & 1 deletion dist/.github1/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
name: >
Pre-release integration tests
(Erlang/OTP ${{matrix.pair.otp-version}},
Elixir ${{matrix.pair.elixir-version},
Elixir ${{matrix.pair.elixir-version}},
rebar3 ${{matrix.pair.rebar3-version}})
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -70,16 +70,21 @@ jobs:
run: erl -version
- name: Output Elixir version
run: echo "Elixir ${{steps.setup-elixir.outputs.elixir-version}}"
if: ${{matrix.pair.elixir-version}}
- name: Run Mix project tests
run: |-
cd test-projects/mix
mix deps.get
mix test
if: ${{matrix.pair.elixir-version}}
- name: Run rebar3 project tests
run: |
cd test-projects/rebar3
rebar3 as test do xref,dialyzer,ct,cover
if: ${{matrix.pair.rebar3-version}}
- name: Output rebar3 version
run: echo "rebar3 ${{steps.setup-elixir.outputs.rebar3-version}}"
if: ${{matrix.pair.rebar3-version}}
- name: Check rebar3 version
run: rebar3 version
if: ${{matrix.pair.rebar3-version}}
51 changes: 26 additions & 25 deletions dist/__tests__/setup-elixir.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ async function test() {
vsn = await setupElixir.getOTPVersion('^19.3', 'ubuntu-18.04')
deepStrictEqual(vsn, 'OTP-19.3.6')

vsn = await setupElixir.getElixirVersion('v1.10.x', '23')
vsn = await setupElixir.getElixirVersion('v1.10.x', 'OTP-23')
deepStrictEqual(vsn, ['v1.10.4', '23'])

vsn = await setupElixir.getElixirVersion('^v1.10', '23')
deepStrictEqual(vsn, ['v1.10.4', '23'])
vsn = await setupElixir.getElixirVersion('^v1.10', 'OTP-23')
deepStrictEqual(vsn, ['v1.11.3', '23'])

vsn = await setupElixir.getElixirVersion('v1.11.0-rc.0', '23')
vsn = await setupElixir.getElixirVersion('v1.11.0-rc.0', 'OTP-23')
deepStrictEqual(vsn, ['v1.11.0-rc.0', '23'])

vsn = await setupElixir.getRebar3Version('3.x')
Expand Down Expand Up @@ -3930,12 +3930,12 @@ const path = __nccwpck_require__(5622)
/**
* Install Erlang/OTP.
*
* @param {string} version
* @param {string} osVersion
* @param {string} version
*/
async function installOTP(version, osVersion) {
async function installOTP(osVersion, version) {
checkPlatform()
await exec(__nccwpck_require__.ab + "install-otp1", [version, osVersion])
await exec(__nccwpck_require__.ab + "install-otp1", [osVersion, version])
}

/**
Expand Down Expand Up @@ -4009,7 +4009,7 @@ async function main() {

// Elixir - optional
const elixirSpec = getElixirSpecFromInput()
if (elixirSpec != undefined) {
if (elixirSpec) {
const [elixirVersion, otpMajor] = await getElixirVersion(
elixirSpec,
otpVersion,
Expand All @@ -4024,27 +4024,28 @@ async function main() {

// rebar3 - optional
const rebar3Spec = getRebar3SpecFromInput()
if (rebar3Spec != undefined) {
if (rebar3Spec) {
const rebar3Version = await getRebar3Version(rebar3Spec)
console.log(`##[group]Installing rebar3 ${rebar3Version}`)
await installer.installRebar3(rebar3Version)
console.log(`##[endgroup]`)
core.setOutput('rebar3-version', otpVersion)
}

process.env.PATH = `${process.env.RUNNER_TEMP}/.setup-elixir/otp/bin`
process.env.PATH += `:${process.env.RUNNER_TEMP}/.setup-elixir/elixir/bin`
process.env.PATH += `:${process.env.RUNNER_TEMP}/.setup-elixir/rebar3/bin`
process.env.PATH += `:${process.env.PATH}`

// mix - optional
let installHex = core.getInput('install-hex')
installHex = installHex == null ? 'true' : installHex
if (installRebar === 'true') await exec('mix local.rebar --force')
if (elixirSpec) {
process.env.PATH += `:${process.env.RUNNER_TEMP}/.setup-elixir/otp/bin`
process.env.PATH += `:${process.env.RUNNER_TEMP}/.setup-elixir/elixir/bin`
process.env.PATH += `:${process.env.RUNNER_TEMP}/.setup-elixir/rebar3/bin`

let installRebar = core.getInput('install-rebar')
installRebar = installRebar == null ? 'true' : installRebar
installRebar && await exec('mix local.rebar --force')

let installRebar = core.getInput('install-rebar')
installRebar = installRebar == null ? 'true' : installRebar
if (installHex === 'true') await exec('mix local.hex --force')
let installHex = core.getInput('install-hex')
installHex = installHex == null ? 'true' : installHex
installHex && await exec('mix local.hex --force')
}
}

function getOTPSpecFromInput() {
Expand All @@ -4059,15 +4060,15 @@ function getElixirSpecFromInput() {
if (process.env.CI_TEST_ENV === 'test') {
return process.env.CI_TEST_ELIXIR_VSN;
} else {
core.getInput('elixir-version', {required: false}) || undefined;
return core.getInput('elixir-version', {required: false});
}
}

function getRebar3SpecFromInput() {
if (process.env.CI_TEST_ENV === 'test') {
return process.env.CI_TEST_REBAR3_VSN;
} else {
return core.getInput('rebar3-version', {required: false}) || undefined;
return core.getInput('rebar3-version', {required: false});
}
}

Expand Down Expand Up @@ -4098,8 +4099,8 @@ async function getElixirVersion(spec, otpVersion) {
const gitRef = version ? `v${version}` : spec
const otpMatch = otpVersion.match(/^OTP-([\.\d]+)/)

if (otpMatch != null && versions.get(gitRef).includes(otpMatch[0])) {
return [gitRef, otpMatch[0]]
if (otpMatch && versions.get(gitRef).includes(otpMatch[1])) {
return [gitRef, otpMatch[1]]
} else {
return [gitRef, null]
}
Expand Down Expand Up @@ -4178,7 +4179,7 @@ async function getRebar3Version(spec) {
}

function get(url, testFile) {
if (process.env.NODE_ENV === 'test' && testFile !== undefined) {
if (process.env.NODE_ENV === 'test' && testFile) {
return readFile(__nccwpck_require__.ab + "__tests__1/" + testFile)
.then((buf) => buf.toString())
}
Expand Down
8 changes: 4 additions & 4 deletions dist/__tests__1/setup-elixir.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ async function test() {
vsn = await setupElixir.getOTPVersion('^19.3', 'ubuntu-18.04')
deepStrictEqual(vsn, 'OTP-19.3.6')

vsn = await setupElixir.getElixirVersion('v1.10.x', '23')
vsn = await setupElixir.getElixirVersion('v1.10.x', 'OTP-23')
deepStrictEqual(vsn, ['v1.10.4', '23'])

vsn = await setupElixir.getElixirVersion('^v1.10', '23')
deepStrictEqual(vsn, ['v1.10.4', '23'])
vsn = await setupElixir.getElixirVersion('^v1.10', 'OTP-23')
deepStrictEqual(vsn, ['v1.11.3', '23'])

vsn = await setupElixir.getElixirVersion('v1.11.0-rc.0', '23')
vsn = await setupElixir.getElixirVersion('v1.11.0-rc.0', 'OTP-23')
deepStrictEqual(vsn, ['v1.11.0-rc.0', '23'])

vsn = await setupElixir.getRebar3Version('3.x')
Expand Down
43 changes: 22 additions & 21 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3884,12 +3884,12 @@ const path = __nccwpck_require__(5622)
/**
* Install Erlang/OTP.
*
* @param {string} version
* @param {string} osVersion
* @param {string} version
*/
async function installOTP(version, osVersion) {
async function installOTP(osVersion, version) {
checkPlatform()
await exec(__nccwpck_require__.ab + "install-otp", [version, osVersion])
await exec(__nccwpck_require__.ab + "install-otp", [osVersion, version])
}

/**
Expand Down Expand Up @@ -3963,7 +3963,7 @@ async function main() {

// Elixir - optional
const elixirSpec = getElixirSpecFromInput()
if (elixirSpec != undefined) {
if (elixirSpec) {
const [elixirVersion, otpMajor] = await getElixirVersion(
elixirSpec,
otpVersion,
Expand All @@ -3978,27 +3978,28 @@ async function main() {

// rebar3 - optional
const rebar3Spec = getRebar3SpecFromInput()
if (rebar3Spec != undefined) {
if (rebar3Spec) {
const rebar3Version = await getRebar3Version(rebar3Spec)
console.log(`##[group]Installing rebar3 ${rebar3Version}`)
await installer.installRebar3(rebar3Version)
console.log(`##[endgroup]`)
core.setOutput('rebar3-version', otpVersion)
}

process.env.PATH = `${process.env.RUNNER_TEMP}/.setup-elixir/otp/bin`
process.env.PATH += `:${process.env.RUNNER_TEMP}/.setup-elixir/elixir/bin`
process.env.PATH += `:${process.env.RUNNER_TEMP}/.setup-elixir/rebar3/bin`
process.env.PATH += `:${process.env.PATH}`

// mix - optional
let installHex = core.getInput('install-hex')
installHex = installHex == null ? 'true' : installHex
if (installRebar === 'true') await exec('mix local.rebar --force')
if (elixirSpec) {
process.env.PATH += `:${process.env.RUNNER_TEMP}/.setup-elixir/otp/bin`
process.env.PATH += `:${process.env.RUNNER_TEMP}/.setup-elixir/elixir/bin`
process.env.PATH += `:${process.env.RUNNER_TEMP}/.setup-elixir/rebar3/bin`

let installRebar = core.getInput('install-rebar')
installRebar = installRebar == null ? 'true' : installRebar
if (installHex === 'true') await exec('mix local.hex --force')
let installRebar = core.getInput('install-rebar')
installRebar = installRebar == null ? 'true' : installRebar
installRebar && await exec('mix local.rebar --force')

let installHex = core.getInput('install-hex')
installHex = installHex == null ? 'true' : installHex
installHex && await exec('mix local.hex --force')
}
}

function getOTPSpecFromInput() {
Expand All @@ -4013,15 +4014,15 @@ function getElixirSpecFromInput() {
if (process.env.CI_TEST_ENV === 'test') {
return process.env.CI_TEST_ELIXIR_VSN;
} else {
core.getInput('elixir-version', {required: false}) || undefined;
return core.getInput('elixir-version', {required: false});
}
}

function getRebar3SpecFromInput() {
if (process.env.CI_TEST_ENV === 'test') {
return process.env.CI_TEST_REBAR3_VSN;
} else {
return core.getInput('rebar3-version', {required: false}) || undefined;
return core.getInput('rebar3-version', {required: false});
}
}

Expand Down Expand Up @@ -4052,8 +4053,8 @@ async function getElixirVersion(spec, otpVersion) {
const gitRef = version ? `v${version}` : spec
const otpMatch = otpVersion.match(/^OTP-([\.\d]+)/)

if (otpMatch != null && versions.get(gitRef).includes(otpMatch[0])) {
return [gitRef, otpMatch[0]]
if (otpMatch && versions.get(gitRef).includes(otpMatch[1])) {
return [gitRef, otpMatch[1]]
} else {
return [gitRef, null]
}
Expand Down Expand Up @@ -4132,7 +4133,7 @@ async function getRebar3Version(spec) {
}

function get(url, testFile) {
if (process.env.NODE_ENV === 'test' && testFile !== undefined) {
if (process.env.NODE_ENV === 'test' && testFile) {
return readFile(__nccwpck_require__.ab + "__tests__/" + testFile)
.then((buf) => buf.toString())
}
Expand Down
13 changes: 3 additions & 10 deletions dist/install-elixir
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ set -eo pipefail

cd "$RUNNER_TEMP"

<<<<<<< HEAD
wget -q https://repo.hex.pm/builds/elixir/${1}${2}.zip
unzip -d .setup-beam/elixir ${1}${2}.zip
rm ${1}${2}.zip
echo "$(pwd)/.setup-beam/elixir/bin" >> $GITHUB_PATH
=======
wget -q https://repo.hex.pm/builds/elixir/"${1}""${2}".zip
unzip -d .setup-elixir/elixir "${1}""${2}".zip
rm "${1}""${2}".zip
wget -q "https://repo.hex.pm/builds/elixir/${1}${2}.zip"
unzip -d .setup-elixir/elixir "${1}${2}.zip"
rm -f "${1}${2}.zip"
echo "$(pwd)/.setup-elixir/elixir/bin" >> "$GITHUB_PATH"
>>>>>>> Merge setup-erlang in
6 changes: 3 additions & 3 deletions dist/install-elixir1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -eo pipefail

cd "$RUNNER_TEMP"

wget -q https://repo.hex.pm/builds/elixir/"${1}""${2}".zip
unzip -d .setup-elixir/elixir "${1}""${2}".zip
rm "${1}""${2}".zip
wget -q "https://repo.hex.pm/builds/elixir/${1}${2}.zip"
unzip -d .setup-elixir/elixir "${1}${2}.zip"
rm -f "${1}${2}.zip"
echo "$(pwd)/.setup-elixir/elixir/bin" >> "$GITHUB_PATH"
9 changes: 6 additions & 3 deletions dist/install-otp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ set -eo pipefail

cd "$RUNNER_TEMP"

wget -q -O otp.tar.gz https://repo.hex.pm/builds/otp/"${2}"/"${1}".tar.gz
OS=${1}
OTP=${2}

wget -q -O otp.tar.gz "https://repo.hex.pm/builds/otp/${OS}/${OTP}.tar.gz"
mkdir -p .setup-elixir/otp
tar zxf otp.tar.gz -C .setup-elixir/otp --strip-components=1
rm otp.tar.gz
.setup-elixir/otp/Install -minimal "$(pwd)"/.setup-elixir/otp
rm -f otp.tar.gz
.setup-elixir/otp/Install -minimal "$(pwd)/.setup-elixir/otp"
echo "$(pwd)/.setup-elixir/otp/bin" >> "$GITHUB_PATH"
Loading

0 comments on commit 4690169

Please sign in to comment.