Skip to content

Commit 94d767d

Browse files
authored
Merge pull request #114 from DeLaGuardo/clj-msi
Use clj-msi to install ClojureCLI on Windows
2 parents 0747838 + 6104f54 commit 94d767d

File tree

12 files changed

+280
-214
lines changed

12 files changed

+280
-214
lines changed

.github/workflows/smoke-tests.yml

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ jobs:
1919
- name: Prepare java
2020
uses: actions/setup-java@v3
2121
with:
22-
distribution: 'zulu'
23-
java-version: '8'
22+
distribution: "zulu"
23+
java-version: "8"
2424

2525
- name: Install clojure tools-deps
2626
uses: ./
2727
with:
28-
tools-deps: 1.10.1.693
28+
tools-deps: 1.11.4.1474
2929

3030
- name: Execute clojure code
3131
run: clojure -e "(+ 1 1)"
@@ -44,13 +44,13 @@ jobs:
4444
- name: Prepare java
4545
uses: actions/setup-java@v3
4646
with:
47-
distribution: 'zulu'
48-
java-version: '8'
47+
distribution: "zulu"
48+
java-version: "8"
4949

5050
- name: Install Clojure CLI
5151
uses: ./
5252
with:
53-
cli: 1.11.1.1409
53+
cli: 1.11.4.1474
5454

5555
- name: Execute clojure code
5656
run: clojure -e "(+ 1 1)"
@@ -69,8 +69,8 @@ jobs:
6969
- name: Prepare java
7070
uses: actions/setup-java@v3
7171
with:
72-
distribution: 'zulu'
73-
java-version: '8'
72+
distribution: "zulu"
73+
java-version: "8"
7474

7575
- name: Install Clojure CLI
7676
uses: ./
@@ -94,8 +94,8 @@ jobs:
9494
- name: Prepare java
9595
uses: actions/setup-java@v3
9696
with:
97-
distribution: 'zulu'
98-
java-version: '8'
97+
distribution: "zulu"
98+
java-version: "8"
9999

100100
- name: Install leiningen
101101
uses: ./
@@ -115,8 +115,8 @@ jobs:
115115
- name: Prepare java
116116
uses: actions/setup-java@v3
117117
with:
118-
distribution: 'zulu'
119-
java-version: '8'
118+
distribution: "zulu"
119+
java-version: "8"
120120

121121
- name: Install leiningen
122122
uses: ./
@@ -147,8 +147,8 @@ jobs:
147147
- name: Prepare java
148148
uses: actions/setup-java@v3
149149
with:
150-
distribution: 'zulu'
151-
java-version: '11'
150+
distribution: "zulu"
151+
java-version: "11"
152152

153153
- name: Install boot
154154
uses: ./
@@ -173,8 +173,8 @@ jobs:
173173
- name: Prepare java
174174
uses: actions/setup-java@v3
175175
with:
176-
distribution: 'zulu'
177-
java-version: '8'
176+
distribution: "zulu"
177+
java-version: "8"
178178

179179
- name: Install babashka
180180
uses: ./
@@ -199,8 +199,8 @@ jobs:
199199
- name: Prepare java
200200
uses: actions/setup-java@v3
201201
with:
202-
distribution: 'zulu'
203-
java-version: '8'
202+
distribution: "zulu"
203+
java-version: "8"
204204

205205
- name: Install clj-kondo
206206
uses: ./
@@ -225,8 +225,8 @@ jobs:
225225
- name: Prepare java
226226
uses: actions/setup-java@v3
227227
with:
228-
distribution: 'zulu'
229-
java-version: '8'
228+
distribution: "zulu"
229+
java-version: "8"
230230

231231
- name: Install cljfmt
232232
uses: ./
@@ -240,7 +240,7 @@ jobs:
240240
test-cljstyle:
241241
strategy:
242242
matrix:
243-
os: [ubuntu-latest, macOS-latest]
243+
os: [ubuntu-latest]
244244

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

@@ -251,8 +251,8 @@ jobs:
251251
- name: Prepare java
252252
uses: actions/setup-java@v3
253253
with:
254-
distribution: 'zulu'
255-
java-version: '8'
254+
distribution: "zulu"
255+
java-version: "8"
256256

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

266266
test-zprint:
267-
268267
strategy:
269268
matrix:
270269
os: [ubuntu-latest, macOS-latest, windows-latest]
@@ -278,8 +277,8 @@ jobs:
278277
- name: Prepare java
279278
uses: actions/setup-java@v3
280279
with:
281-
distribution: 'zulu'
282-
java-version: '8'
280+
distribution: "zulu"
281+
java-version: "8"
283282

284283
- name: Install zprint
285284
uses: ./
@@ -300,13 +299,13 @@ jobs:
300299
- name: Prepare java
301300
uses: actions/setup-java@v3
302301
with:
303-
distribution: 'zulu'
304-
java-version: '8'
302+
distribution: "zulu"
303+
java-version: "8"
305304

306305
- name: Install all the tools
307306
uses: ./
308307
with:
309-
cli: 1.11.1.1149
308+
cli: 1.11.4.1474
310309
lein: 2.11.0
311310
boot: 2.8.3
312311
bb: 0.8.157

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
java-version: '8'
4747

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

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

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

102101
- name: Get zprint version

__tests__/entrypoint.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ describe('setup-clojure', () => {
7474

7575
await main()
7676

77-
expect(cli.setup).toHaveBeenCalledWith('1.2.3', 'Bearer auth token')
77+
expect(cli.setup).toHaveBeenCalledWith(
78+
'1.2.3',
79+
'auth token',
80+
'Bearer auth token'
81+
)
7882
})
7983

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

8488
await main()
8589

86-
expect(cli.setup).toHaveBeenCalledWith('1.2.3', 'Bearer auth token')
90+
expect(cli.setup).toHaveBeenCalledWith(
91+
'1.2.3',
92+
'auth token',
93+
'Bearer auth token'
94+
)
8795
})
8896

8997
it('sets up Babashka', async () => {

__tests__/tdeps.test.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import * as _io from '@actions/io'
44
import * as _tc from '@actions/tool-cache'
55
import * as _http from '@actions/http-client'
66
import * as _os from 'os'
7+
import * as _crypto from 'crypto'
78
import * as _fs from '../src/fs'
9+
import * as _utils from '../src/utils'
810
import {join} from 'path'
911
import {VERSION} from '../src/version'
1012

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

38+
jest.mock('../src/utils', () => ({
39+
...jest.requireActual('../src/utils'),
40+
getTempDir: jest.fn(),
41+
isMacOS: jest.fn()
42+
}))
43+
const utils: jest.Mocked<typeof _utils> = _utils as never
44+
3645
jest.mock('@actions/http-client', () => {
3746
return {
3847
HttpClient: jest.fn().mockImplementation(() => {
@@ -49,12 +58,17 @@ jest.mock('@actions/http-client', () => {
4958
}
5059
})
5160

61+
jest.mock('crypto')
62+
const crypto: jest.Mocked<typeof _crypto> = _crypto as never
63+
5264
describe('tdeps tests', () => {
5365
beforeAll(async () => {
5466
process.env['RUNNER_TOOL_CACHE'] = toolPath
5567
process.env['RUNNER_TEMP'] = tempPath
5668
os.arch.mockReturnValue('x64')
5769
os.platform.mockReturnValue('linux')
70+
utils.getTempDir.mockReturnValue(tempPath)
71+
crypto.randomUUID.mockReturnValue('123-123-123-123-123')
5872
jest.spyOn(global.Math, 'random').mockReturnValue(1)
5973
})
6074

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

78-
await tdeps.setup('1.10.1.469', 'auth token')
92+
await tdeps.setup('1.10.1.469', 'auth token', 'Bearer auth token')
7993

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

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

136150
it('Supports macOS', async () => {
137-
os.platform.mockReturnValue('darwin')
151+
utils.isMacOS.mockReturnValue(true)
138152

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

147161
expect(tc.downloadTool).toHaveBeenCalledWith(
148162
'https://download.clojure.org/install/linux-install-1.2.3.sh',
149-
undefined,
163+
join(tempPath, '123-123-123-123-123', 'linux-install-1.2.3.sh'),
150164
'foo'
151165
)
152166
expect(io.mkdirP).toHaveBeenCalledWith('/tmp/usr/local/opt/ClojureTools')

0 commit comments

Comments
 (0)