Skip to content

Commit edfea6b

Browse files
committed
feat: added support for installing SDKs with sdks input parameter
1 parent f779706 commit edfea6b

File tree

21 files changed

+812
-100
lines changed

21 files changed

+812
-100
lines changed

.devcontainer/devcontainer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
"image": "mcr.microsoft.com/devcontainers/universal:2",
33
"customizations": {
44
"vscode": {
5-
"settings": {
6-
"jest.runMode": "on-demand"
7-
},
85
"extensions": [
96
"eamodio.gitlens",
107
"ms-vscode.vscode-typescript-next",

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ jobs:
381381
with: {
382382
'swift-version': 'latest',
383383
'check-latest': '${{ needs.ci.outputs.check_latest }}',
384-
'visual-studio-components': 'Microsoft.VisualStudio.Component.Windows11SDK.22000'
384+
'visual-studio-components': 'Microsoft.VisualStudio.Component.Windows11SDK.22000',
385+
'sdks': 'static-sdk'
385386
}
386387
}
387388
]

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"jest.jestCommandLine": "npm run test -- ",
3+
"jest.runMode": "on-demand",
34
"files.exclude": {
45
"**/node_modules": true
56
},

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This action supports the following functionalities:
1212

1313
- Works on Linux, macOS and Windows across all architectures.
1414
- Supports [installing latest major/minor/patch](#specifying-version).
15+
- Supports installing official Swift SDKs from cross platform developments.
1516
- Provides snapshots as soon as published in `swift.org`.
1617
- Verifies toolchain snapshots before installation (`gpg` for Linux and Windows, `pkgutil` for macOS) .
1718
- Allows development snapshots by enabling `development` flag and optional version.
@@ -43,6 +44,14 @@ Or use the latest development snapshots by enabling the `development` flag:
4344
development: true
4445
```
4546

47+
Install additional SDKs as part of toolchain setup, i.e. install static Linux SDK:
48+
49+
```yml
50+
- uses: SwiftyLab/setup-swift@latest
51+
with:
52+
sdks: static-sdk
53+
```
54+
4655
After the environment is configured you can run swift and xcode commands using the standard [`run`](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsrun) step:
4756

4857
```yml

__tests__/snapshot/linux.test.ts

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,162 @@ describe('fetch linux tool data based on options', () => {
304304
expect(tool.dir).toBe(name)
305305
expect(tool.branch).toBe('swiftwasm')
306306
})
307+
308+
it('fetches ubuntu 22.04 swift tool with Linux SDK', async () => {
309+
setos({os: 'linux', dist: 'Ubuntu', release: '22.04'})
310+
jest.spyOn(os, 'arch').mockReturnValue('x64')
311+
const version = ToolchainVersion.create('6.1.1', false, ['static-sdk'])
312+
const tool = await Platform.toolchain(version)
313+
expect(tool).toBeTruthy()
314+
const lTool = tool as LinuxToolchainSnapshot
315+
expect(lTool.download).toBe('swift-6.1.1-RELEASE-ubuntu22.04.tar.gz')
316+
expect(lTool.dir).toBe('swift-6.1.1-RELEASE')
317+
expect(lTool.platform).toBe('ubuntu2204')
318+
expect(lTool.branch).toBe('swift-6.1.1-release')
319+
expect(lTool.download_signature).toBe(
320+
'swift-6.1.1-RELEASE-ubuntu22.04.tar.gz.sig'
321+
)
322+
expect(lTool.preventCaching).toBe(false)
323+
if (!tool) {
324+
return
325+
}
326+
327+
const sdkSnapshots = await version.sdkSnapshots(tool)
328+
expect(sdkSnapshots.length).toBe(1)
329+
const sdkSnapshot = sdkSnapshots[0]
330+
expect(sdkSnapshot.platform).toBe('static-sdk')
331+
expect(sdkSnapshot.dir).toBe('swift-6.1.1-RELEASE')
332+
expect(sdkSnapshot.branch).toBe('swift-6.1.1-release')
333+
expect(sdkSnapshot.download).toBe(
334+
'swift-6.1.1-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz'
335+
)
336+
expect(sdkSnapshot.checksum).toBe(
337+
'8a69753e181e40c202465f03bcafcc898070a86817ca0f39fc808f76638e90c2'
338+
)
339+
})
340+
341+
it('fetches ubuntu 22.04 named swift tool with Linux SDK', async () => {
342+
setos({os: 'linux', dist: 'Ubuntu', release: '22.04'})
343+
jest.spyOn(os, 'arch').mockReturnValue('x64')
344+
const name = 'swift-6.0-DEVELOPMENT-SNAPSHOT-2024-09-17-a'
345+
const version = ToolchainVersion.create(name, false, ['static-sdk'])
346+
const tool = await Platform.toolchain(version)
347+
expect(tool).toBeTruthy()
348+
const lTool = tool as LinuxToolchainSnapshot
349+
expect(lTool.download).toBe(
350+
'swift-6.0-DEVELOPMENT-SNAPSHOT-2024-09-17-a-ubuntu22.04.tar.gz'
351+
)
352+
expect(lTool.dir).toBe('swift-6.0-DEVELOPMENT-SNAPSHOT-2024-09-17-a')
353+
expect(lTool.platform).toBe('ubuntu2204')
354+
expect(lTool.branch).toBe('swift-6.0-branch')
355+
expect(lTool.download_signature).toBe(
356+
'swift-6.0-DEVELOPMENT-SNAPSHOT-2024-09-17-a-ubuntu22.04.tar.gz.sig'
357+
)
358+
expect(lTool.preventCaching).toBe(false)
359+
if (!tool) {
360+
return
361+
}
362+
363+
const sdkSnapshots = await version.sdkSnapshots(tool)
364+
expect(sdkSnapshots.length).toBe(1)
365+
const sdkSnapshot = sdkSnapshots[0]
366+
expect(sdkSnapshot.platform).toBe('static-sdk')
367+
expect(sdkSnapshot.dir).toBe('swift-6.0-DEVELOPMENT-SNAPSHOT-2024-09-17-a')
368+
expect(sdkSnapshot.branch).toBe('swift-6.0-branch')
369+
expect(sdkSnapshot.download).toBe(
370+
'swift-6.0-DEVELOPMENT-SNAPSHOT-2024-09-17-a_static-linux-0.0.1.artifactbundle.tar.gz'
371+
)
372+
expect(sdkSnapshot.checksum).toBe(
373+
'83a88650cd0675552ce2cf8159c31966fde73418f49493c1644073fffe8be9f4'
374+
)
375+
})
376+
377+
it('fetches ubuntu 22.04 named swift tool with WASM SDK', async () => {
378+
setos({os: 'linux', dist: 'Ubuntu', release: '22.04'})
379+
jest.spyOn(os, 'arch').mockReturnValue('x64')
380+
const name = 'swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-01-a'
381+
const version = ToolchainVersion.create(name, false, ['wasm-sdk'])
382+
const tool = await Platform.toolchain(version)
383+
expect(tool).toBeTruthy()
384+
const lTool = tool as LinuxToolchainSnapshot
385+
expect(lTool.download).toBe(
386+
'swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-01-a-ubuntu22.04.tar.gz'
387+
)
388+
expect(lTool.dir).toBe('swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-01-a')
389+
expect(lTool.platform).toBe('ubuntu2204')
390+
expect(lTool.branch).toBe('swift-6.2-branch')
391+
expect(lTool.download_signature).toBe(
392+
'swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-01-a-ubuntu22.04.tar.gz.sig'
393+
)
394+
expect(lTool.preventCaching).toBe(false)
395+
if (!tool) {
396+
return
397+
}
398+
399+
const sdkSnapshots = await version.sdkSnapshots(tool)
400+
expect(sdkSnapshots.length).toBe(1)
401+
const sdkSnapshot = sdkSnapshots[0]
402+
expect(sdkSnapshot.platform).toBe('wasm-sdk')
403+
expect(sdkSnapshot.dir).toBe('swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-01-a')
404+
expect(sdkSnapshot.branch).toBe('swift-6.2-branch')
405+
expect(sdkSnapshot.download).toBe(
406+
'swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-01-a_wasm.artifactbundle.tar.gz'
407+
)
408+
expect(sdkSnapshot.checksum).toBe(
409+
'40f3c780d4a8f3d369c203615330e1b00441b6f8b7023535bebc16bf4dd5f84a'
410+
)
411+
})
412+
413+
it('fetches ubuntu 22.04 named swift tool with Linux and WASM SDK', async () => {
414+
setos({os: 'linux', dist: 'Ubuntu', release: '22.04'})
415+
jest.spyOn(os, 'arch').mockReturnValue('x64')
416+
const name = 'swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-01-a'
417+
const version = ToolchainVersion.create(name, false, [
418+
'static-sdk',
419+
'wasm-sdk'
420+
])
421+
const tool = await Platform.toolchain(version)
422+
expect(tool).toBeTruthy()
423+
const lTool = tool as LinuxToolchainSnapshot
424+
expect(lTool.download).toBe(
425+
'swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-01-a-ubuntu22.04.tar.gz'
426+
)
427+
expect(lTool.dir).toBe('swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-01-a')
428+
expect(lTool.platform).toBe('ubuntu2204')
429+
expect(lTool.branch).toBe('swift-6.2-branch')
430+
expect(lTool.download_signature).toBe(
431+
'swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-01-a-ubuntu22.04.tar.gz.sig'
432+
)
433+
expect(lTool.preventCaching).toBe(false)
434+
if (!tool) {
435+
return
436+
}
437+
438+
const sdkSnapshots = await version.sdkSnapshots(tool)
439+
expect(sdkSnapshots.length).toBe(2)
440+
for (let i = 0; i < 2; i++) {
441+
const sdkSnapshot = sdkSnapshots[i]
442+
expect(sdkSnapshot.dir).toBe(
443+
'swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-01-a'
444+
)
445+
expect(sdkSnapshot.branch).toBe('swift-6.2-branch')
446+
if (i == 0) {
447+
expect(sdkSnapshot.platform).toBe('static-sdk')
448+
expect(sdkSnapshot.download).toBe(
449+
'swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-01-a_static-linux-0.0.1.artifactbundle.tar.gz'
450+
)
451+
expect(sdkSnapshot.checksum).toBe(
452+
'9e4065031461c00a88912e94d0c7d847e701a28667f58facad49dc636de77b6f'
453+
)
454+
} else {
455+
expect(sdkSnapshot.platform).toBe('wasm-sdk')
456+
expect(sdkSnapshot.download).toBe(
457+
'swift-6.2-DEVELOPMENT-SNAPSHOT-2025-08-01-a_wasm.artifactbundle.tar.gz'
458+
)
459+
expect(sdkSnapshot.checksum).toBe(
460+
'40f3c780d4a8f3d369c203615330e1b00441b6f8b7023535bebc16bf4dd5f84a'
461+
)
462+
}
463+
}
464+
})
307465
})

action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ inputs:
5454
i.e. Enable this option for installing static SDK: https://www.swift.org/documentation/articles/static-linux-getting-started.html
5555
required: false
5656
default: 'false'
57+
sdks:
58+
description: >-
59+
Semi-colon separated list of Swift SDKs to install along with the main toolchain.
60+
Available SDKs are based on platforms available for the specified version.
61+
Examples: "static-sdk", "static-sdk;wasm-sdk".
62+
required: false
63+
default: ''
5764
outputs:
5865
swift-version:
5966
description: The actual Swift version that was configured.

0 commit comments

Comments
 (0)