Skip to content

Commit

Permalink
Merge pull request #114 from DeLaGuardo/clj-msi
Browse files Browse the repository at this point in the history
Use clj-msi to install ClojureCLI on Windows
  • Loading branch information
DeLaGuardo authored Nov 14, 2024
2 parents 0747838 + 6104f54 commit 94d767d
Show file tree
Hide file tree
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
Expand Up @@ -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)"
Expand All @@ -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)"
Expand All @@ -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: ./
Expand All @@ -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: ./
Expand All @@ -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: ./
Expand Down Expand Up @@ -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: ./
Expand All @@ -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: ./
Expand All @@ -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: ./
Expand All @@ -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: ./
Expand All @@ -240,7 +240,7 @@ jobs:
test-cljstyle:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
os: [ubuntu-latest]

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

Expand All @@ -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: ./
Expand All @@ -264,7 +264,6 @@ jobs:
run: cljstyle version

test-zprint:

strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
Expand All @@ -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: ./
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions __tests__/entrypoint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down
24 changes: 19 additions & 5 deletions __tests__/tdeps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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(() => {
Expand All @@ -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)
})

Expand All @@ -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')
Expand Down Expand Up @@ -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')
Expand All @@ -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()
Expand All @@ -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')
Expand Down
Loading

0 comments on commit 94d767d

Please sign in to comment.