Test boot.exe on windows

This commit is contained in:
Kirill Chernyshov 2022-07-18 12:00:22 +02:00
parent 0481a417df
commit 28aba54040
No known key found for this signature in database
GPG Key ID: 83C196363AF97C4C
9 changed files with 102 additions and 63 deletions

View File

@ -8,9 +8,9 @@ jobs:
test-tools-deps:
strategy:
matrix:
operating-system: [ubuntu-latest, macOS-latest]
os: [ubuntu-latest, macOS-latest]
runs-on: ${{ matrix.operating-system }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
@ -95,9 +95,9 @@ jobs:
test-leiningen:
strategy:
matrix:
operating-system: [ubuntu-latest, macOS-latest, windows-latest]
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.operating-system }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
@ -122,9 +122,9 @@ jobs:
test-boot:
strategy:
matrix:
operating-system: [ubuntu-latest, macOS-latest]
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.operating-system }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
@ -134,7 +134,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
java-version: '11'
- name: Install boot
# uses: DeLaGuardo/setup-clojure@master
@ -149,9 +149,9 @@ jobs:
test-bb:
strategy:
matrix:
operating-system: [ubuntu-latest, macOS-latest, windows-latest]
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.operating-system }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
@ -176,9 +176,9 @@ jobs:
test-clj-kondo:
strategy:
matrix:
operating-system: [ubuntu-latest, macOS-latest, windows-latest]
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.operating-system }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
@ -203,9 +203,9 @@ jobs:
test-cljstyle:
strategy:
matrix:
operating-system: [ubuntu-latest, macOS-latest]
os: [ubuntu-latest, macOS-latest]
runs-on: ${{ matrix.operating-system }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
@ -231,9 +231,9 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest, macOS-latest, windows-latest]
os: [ubuntu-latest, macOS-latest, windows-latest]
runs-on: ${{ matrix.operating-system }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout

View File

@ -2,15 +2,16 @@
This action sets up Clojure tools environment for using in GitHub Actions.
* Clojure CLI
* Leiningen
* boot-clj
* Babashka
* Clj-kondo
* cljstyle
* zprint
* [Clojure CLI](https://clojure.org/guides/deps_and_cli)
* [leiningen](https://leiningen.org/)
* [boot-clj](https://boot-clj.github.io/)
* [babashka](https://babashka.org/)
* [clj-kondo](https://github.com/clj-kondo/clj-kondo)
* [cljstyle](https://github.com/greglook/cljstyle)
* [deps.clj](https://github.com/borkdude/deps.clj)
* [zprint](https://github.com/kkinnear/zprint)
All three major tools available for MacOS and ubuntu based runners, Leiningen and Clojure CLI also available on Windows
All three major tools (Clojure CLI, leiningen and boot-clj) available for MacOS, Ubuntu and Windows based runners. Please look at [Smoke Test Workflow file](https://github.com/DeLaGuardo/setup-clojure/blob/master/.github/workflows/smoke-tests.yml) for compatibility matrix.
# Usage
@ -35,6 +36,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
# It is important to install java before installing clojure tools which needs java
# exclusions: babashka, clj-kondo and cljstyle
- name: Prepare java
uses: actions/setup-java@v3
with:
@ -42,18 +45,19 @@ jobs:
java-version: '8'
- name: Install clojure tools
uses: DeLaGuardo/setup-clojure@7.0
uses: DeLaGuardo/setup-clojure@8.1
with:
# Install just one or all simultaneously
# The value must indicate a particular version of the tool, or use 'latest'
# to always provision the latest version
cli: 1.10.1.693 # Clojure CLI based on tools.deps
lein: 2.9.1 # Leiningen
boot: 2.8.3 # Boot.clj
bb: 0.7.8 # Babashka
clj-kondo: 2022.05.31 # Clj-kondo
cljstyle: 0.15.0 # cljstyle
cmd-exe-workaround: 'latest' # Replace `clojure` with `deps.clj` on Windows
cli: 1.10.1.693 # Clojure CLI based on tools.deps
lein: 2.9.1 # Leiningen
boot: 2.8.3 # Boot.clj
bb: 0.7.8 # Babashka
clj-kondo: 2022.05.31 # Clj-kondo
cljstyle: 0.15.0 # cljstyle
cmd-exe-workaround: 'latest' # Replaces `clojure` with `deps.clj` on Windows
zprint: 1.2.3 # zprint
- name: Execute clojure code on Linux and MacOS
if: ${{ matrix.os != 'windows-latest' }}
@ -69,8 +73,6 @@ jobs:
run: lein -v
- name: Get boot version
# Boot is not yet available for windows
if: ${{ matrix.os != 'windows-latest' }}
run: boot -V
- name: Get babashka version

View File

@ -63,18 +63,6 @@ describe('setup-clojure', () => {
expect(boot.setup).toHaveBeenCalledWith('1.2.3', 'token abc')
})
it('throws on Boot setup in Windows', async () => {
inputs['boot'] = '1.2.3'
inputs['github-token'] = 'abc'
utils.isWindows.mockReturnValue(true)
await run()
expect(core.setFailed).toHaveBeenCalledWith(
'Boot on windows is not supported yet.'
)
})
it('sets up Clojure CLI tools from deprecated `tools-deps` option', async () => {
inputs['tools-deps'] = '1.2.3'

BIN
dist/JavaVersion.class vendored Normal file

Binary file not shown.

25
dist/index.js vendored
View File

@ -176,7 +176,7 @@ function setup(version, githubAuth) {
core.info(`Boot found in cache ${toolPath}`);
}
else {
const bootBootstrapFile = yield tc.downloadTool(`https://github.com/boot-clj/boot-bin/releases/download/latest/boot.sh`, undefined, githubAuth);
const bootBootstrapFile = yield tc.downloadTool(`https://github.com/boot-clj/boot-bin/releases/download/latest/boot.${utils.isWindows() ? 'exe' : 'sh'}`, undefined, githubAuth);
const tempDir = path.join(getTempDirectory(), `temp_${Math.floor(Math.random() * 2000000000)}`);
const bootDir = yield installBoot(bootBootstrapFile, tempDir, version);
core.debug(`Boot installed to ${bootDir}`);
@ -198,8 +198,10 @@ function installBoot(binScript, destinationFolder, version) {
if (binStats.isFile()) {
const binDir = path.join(destinationFolder, 'boot', 'bin');
yield io.mkdirP(binDir);
yield io.mv(bin, path.join(binDir, `boot`));
yield fs.chmod(path.join(binDir, `boot`), '0755');
yield io.mv(bin, path.join(binDir, `boot${utils.isWindows() ? '.exe' : ''}`));
if (!utils.isWindows()) {
yield fs.chmod(path.join(binDir, `boot`), '0755');
}
let env = {};
if (version === 'latest') {
env = {
@ -218,7 +220,19 @@ function installBoot(binScript, destinationFolder, version) {
if (process.env['JAVA_CMD']) {
env['JAVA_CMD'] = process.env['JAVA_CMD'];
}
yield exec.exec(`./boot ${version === 'latest' ? '-u' : '-V'}`, [], {
if (utils.isWindows()) {
let java_version = '';
yield exec.exec(`java -cp dist JavaVersion`, [], {
listeners: {
stdout: (data) => {
java_version += data.toString();
}
}
});
yield exec.exec(`reg add "HKLM\\SOFTWARE\\JavaSoft\\Java Runtime Environment" /v CurrentVersion /d ${java_version.trim()} /f`);
yield exec.exec(`reg add "HKLM\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\${java_version.trim()}" /v JavaHome /d "${process.env['JAVA_HOME']}" /f`);
}
yield exec.exec(`./boot${utils.isWindows() ? '.exe' : ''} ${version === 'latest' ? '-u' : '-V'}`, [], {
cwd: path.join(destinationFolder, 'boot', 'bin'),
env
});
@ -637,9 +651,6 @@ function run() {
}
const IS_WINDOWS = utils.isWindows();
if (BOOT_VERSION) {
if (IS_WINDOWS) {
throw new Error('Boot on windows is not supported yet.');
}
tools.push(boot.setup(BOOT_VERSION, githubAuth));
}
if (CLI_VERSION) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

5
dist/javaVersion.java vendored Normal file
View File

@ -0,0 +1,5 @@
class JavaVersion {
public static void main(String[] args) {
System.out.println(System.getProperty("java.version"));
}
}

View File

@ -40,7 +40,9 @@ export async function setup(
core.info(`Boot found in cache ${toolPath}`)
} else {
const bootBootstrapFile = await tc.downloadTool(
`https://github.com/boot-clj/boot-bin/releases/download/latest/boot.sh`,
`https://github.com/boot-clj/boot-bin/releases/download/latest/boot.${
utils.isWindows() ? 'exe' : 'sh'
}`,
undefined,
githubAuth
)
@ -78,8 +80,14 @@ async function installBoot(
await io.mkdirP(binDir)
await io.mv(bin, path.join(binDir, `boot`))
await fs.chmod(path.join(binDir, `boot`), '0755')
await io.mv(
bin,
path.join(binDir, `boot${utils.isWindows() ? '.exe' : ''}`)
)
if (!utils.isWindows()) {
await fs.chmod(path.join(binDir, `boot`), '0755')
}
let env: {[key: string]: string} = {}
if (version === 'latest') {
@ -100,10 +108,38 @@ async function installBoot(
env['JAVA_CMD'] = process.env['JAVA_CMD']
}
await exec.exec(`./boot ${version === 'latest' ? '-u' : '-V'}`, [], {
cwd: path.join(destinationFolder, 'boot', 'bin'),
env
})
if (utils.isWindows()) {
let java_version = ''
await exec.exec(`java -cp dist JavaVersion`, [], {
listeners: {
stdout: (data: Buffer) => {
java_version += data.toString()
}
}
})
await exec.exec(
`reg add "HKLM\\SOFTWARE\\JavaSoft\\Java Runtime Environment" /v CurrentVersion /d ${java_version.trim()} /f`
)
await exec.exec(
`reg add "HKLM\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\${java_version.trim()}" /v JavaHome /d "${
process.env['JAVA_HOME']
}" /f`
)
}
await exec.exec(
`./boot${utils.isWindows() ? '.exe' : ''} ${
version === 'latest' ? '-u' : '-V'
}`,
[],
{
cwd: path.join(destinationFolder, 'boot', 'bin'),
env
}
)
return path.join(destinationFolder, 'boot')
} else {

View File

@ -32,9 +32,6 @@ export async function run(): Promise<void> {
const IS_WINDOWS = utils.isWindows()
if (BOOT_VERSION) {
if (IS_WINDOWS) {
throw new Error('Boot on windows is not supported yet.')
}
tools.push(boot.setup(BOOT_VERSION, githubAuth))
}