Skip to content

Commit

Permalink
Use clj-msi to install ClojureCLI on Windows
Browse files Browse the repository at this point in the history
DeLaGuardo committed Nov 14, 2024

Verified

This commit was signed with the committer’s verified signature.
DeLaGuardo Kirill Chernyshov
1 parent 0747838 commit 6104f54
Showing 12 changed files with 280 additions and 214 deletions.
57 changes: 28 additions & 29 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
@@ -19,13 +19,13 @@ jobs:
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
distribution: "zulu"
java-version: "8"

- name: Install clojure tools-deps
uses: ./
with:
tools-deps: 1.10.1.693
tools-deps: 1.11.4.1474

- name: Execute clojure code
run: clojure -e "(+ 1 1)"
@@ -44,13 +44,13 @@ jobs:
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
distribution: "zulu"
java-version: "8"

- name: Install Clojure CLI
uses: ./
with:
cli: 1.11.1.1409
cli: 1.11.4.1474

- name: Execute clojure code
run: clojure -e "(+ 1 1)"
@@ -69,8 +69,8 @@ jobs:
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
distribution: "zulu"
java-version: "8"

- name: Install Clojure CLI
uses: ./
@@ -94,8 +94,8 @@ jobs:
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
distribution: "zulu"
java-version: "8"

- name: Install leiningen
uses: ./
@@ -115,8 +115,8 @@ jobs:
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
distribution: "zulu"
java-version: "8"

- name: Install leiningen
uses: ./
@@ -147,8 +147,8 @@ jobs:
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
distribution: "zulu"
java-version: "11"

- name: Install boot
uses: ./
@@ -173,8 +173,8 @@ jobs:
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
distribution: "zulu"
java-version: "8"

- name: Install babashka
uses: ./
@@ -199,8 +199,8 @@ jobs:
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
distribution: "zulu"
java-version: "8"

- name: Install clj-kondo
uses: ./
@@ -225,8 +225,8 @@ jobs:
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
distribution: "zulu"
java-version: "8"

- name: Install cljfmt
uses: ./
@@ -240,7 +240,7 @@ jobs:
test-cljstyle:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}

@@ -251,8 +251,8 @@ jobs:
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
distribution: "zulu"
java-version: "8"

- name: Install cljstyle
uses: ./
@@ -264,7 +264,6 @@ jobs:
run: cljstyle version

test-zprint:

strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
@@ -278,8 +277,8 @@ jobs:
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
distribution: "zulu"
java-version: "8"

- name: Install zprint
uses: ./
@@ -300,13 +299,13 @@ jobs:
- name: Prepare java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
distribution: "zulu"
java-version: "8"

- name: Install all the tools
uses: ./
with:
cli: 1.11.1.1149
cli: 1.11.4.1474
lein: 2.11.0
boot: 2.8.3
bb: 0.8.157
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ jobs:
java-version: '8'

- name: Install clojure tools
uses: DeLaGuardo/setup-clojure@12.5
uses: DeLaGuardo/setup-clojure@13.0
with:
# Install just one or all simultaneously
# The value must indicate a particular version of the tool, or use 'latest'
@@ -58,7 +58,6 @@ jobs:
clj-kondo: 2022.05.31 # Clj-kondo
cljfmt: 0.10.2 # cljfmt
cljstyle: 0.16.626 # cljstyle
cmd-exe-workaround: 'latest' # Replaces `clojure` with `deps.clj` on Windows
zprint: 1.2.3 # zprint

# Optional step:
@@ -95,8 +94,8 @@ jobs:
run: cljfmt --version

- name: Get cljstyle version
# cljstyle is not yet available for windows
if: ${{ matrix.os != 'windows-latest' }}
# cljstyle is not yet available for windows and mac os
if: ${{ matrix.os == 'ubuntu-latest' }}
run: cljstyle version

- name: Get zprint version
12 changes: 10 additions & 2 deletions __tests__/entrypoint.test.ts
Original file line number Diff line number Diff line change
@@ -74,7 +74,11 @@ describe('setup-clojure', () => {

await main()

expect(cli.setup).toHaveBeenCalledWith('1.2.3', 'Bearer auth token')
expect(cli.setup).toHaveBeenCalledWith(
'1.2.3',
'auth token',
'Bearer auth token'
)
})

it('sets up Clojure CLI tools', async () => {
@@ -83,7 +87,11 @@ describe('setup-clojure', () => {

await main()

expect(cli.setup).toHaveBeenCalledWith('1.2.3', 'Bearer auth token')
expect(cli.setup).toHaveBeenCalledWith(
'1.2.3',
'auth token',
'Bearer auth token'
)
})

it('sets up Babashka', async () => {
24 changes: 19 additions & 5 deletions __tests__/tdeps.test.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,9 @@ import * as _io from '@actions/io'
import * as _tc from '@actions/tool-cache'
import * as _http from '@actions/http-client'
import * as _os from 'os'
import * as _crypto from 'crypto'
import * as _fs from '../src/fs'
import * as _utils from '../src/utils'
import {join} from 'path'
import {VERSION} from '../src/version'

@@ -33,6 +35,13 @@ const fs: jest.Mocked<typeof _fs> = _fs as never
jest.mock('os')
const os: jest.Mocked<typeof _os> = _os as never

jest.mock('../src/utils', () => ({
...jest.requireActual('../src/utils'),
getTempDir: jest.fn(),
isMacOS: jest.fn()
}))
const utils: jest.Mocked<typeof _utils> = _utils as never

jest.mock('@actions/http-client', () => {
return {
HttpClient: jest.fn().mockImplementation(() => {
@@ -49,12 +58,17 @@ jest.mock('@actions/http-client', () => {
}
})

jest.mock('crypto')
const crypto: jest.Mocked<typeof _crypto> = _crypto as never

describe('tdeps tests', () => {
beforeAll(async () => {
process.env['RUNNER_TOOL_CACHE'] = toolPath
process.env['RUNNER_TEMP'] = tempPath
os.arch.mockReturnValue('x64')
os.platform.mockReturnValue('linux')
utils.getTempDir.mockReturnValue(tempPath)
crypto.randomUUID.mockReturnValue('123-123-123-123-123')
jest.spyOn(global.Math, 'random').mockReturnValue(1)
})

@@ -75,11 +89,11 @@ describe('tdeps tests', () => {
tc.downloadTool.mockResolvedValueOnce(downloadPath)
tc.cacheDir.mockResolvedValueOnce(cachePath)

await tdeps.setup('1.10.1.469', 'auth token')
await tdeps.setup('1.10.1.469', 'auth token', 'Bearer auth token')

expect(tc.downloadTool).toHaveBeenCalledWith(
'https://download.clojure.org/install/linux-install-1.10.1.469.sh',
undefined,
join(tempPath, '123-123-123-123-123', 'linux-install-1.10.1.469.sh'),
'auth token'
)
expect(io.mkdirP).toHaveBeenCalledWith('/tmp/usr/local/opt/ClojureTools')
@@ -110,7 +124,7 @@ describe('tdeps tests', () => {

expect(tc.downloadTool).toHaveBeenCalledWith(
'https://download.clojure.org/install/linux-install-1.2.3.sh',
undefined,
join(tempPath, '123-123-123-123-123', 'linux-install-1.2.3.sh'),
'auth token'
)
expect(io.mkdirP).toHaveBeenCalledWith('/tmp/usr/local/opt/ClojureTools')
@@ -134,7 +148,7 @@ describe('tdeps tests', () => {
})

it('Supports macOS', async () => {
os.platform.mockReturnValue('darwin')
utils.isMacOS.mockReturnValue(true)

fs.readFile.mockResolvedValueOnce('install -D')
fs.writeFile.mockResolvedValueOnce()
@@ -146,7 +160,7 @@ describe('tdeps tests', () => {

expect(tc.downloadTool).toHaveBeenCalledWith(
'https://download.clojure.org/install/linux-install-1.2.3.sh',
undefined,
join(tempPath, '123-123-123-123-123', 'linux-install-1.2.3.sh'),
'foo'
)
expect(io.mkdirP).toHaveBeenCalledWith('/tmp/usr/local/opt/ClojureTools')
Loading

0 comments on commit 6104f54

Please sign in to comment.