Skip to content

Commit 2053b5f

Browse files
committed
Implement the business logic for this Action
With this, we finally expose the download functionality via the Action. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 9215996 commit 2053b5f

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

__tests__/main.test.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,22 @@ async function runAction(
2020
})
2121
}
2222

23-
// shows how the runner will run a javascript action with env / stdout protocol
24-
test('test this Action locally', async () => {
25-
expect(await runAction()).toEqual(0)
26-
})
23+
if (process.env.RUN_NETWORK_TESTS !== 'true') {
24+
test('skipping tests requiring network access', async () => {
25+
console.log(
26+
`If you want to run tests that access the network, set:\nexport RUN_NETWORK_TESTS=true`
27+
)
28+
})
29+
} else {
30+
// shows how the runner will run a javascript action with env / stdout protocol
31+
test('cannot download 32-bit minimal SDK', async () => {
32+
expect(
33+
await runAction({
34+
env: {
35+
INPUT_FLAVOR: 'minimal',
36+
INPUT_ARCHITECTURE: 'i686'
37+
}
38+
})
39+
).toEqual(1)
40+
})
41+
}

action.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@ name: 'Setup Git for Windows SDK'
22
description: 'Set up an environment to develop Git for Windows'
33
author: 'Johannes Schindelin'
44
inputs:
5-
milliseconds: # change this
6-
required: true
7-
description: 'input description here'
8-
default: 'default value if applicable'
5+
flavor:
6+
required: false
7+
description: 'The subset (if any) of the SDK: minimal, makepkg-git, build-installers, or full'
8+
default: 'minimal'
9+
architecture:
10+
required: false
11+
description: 'The architecture of the SDK: x86_64 or i686'
12+
default: 'x86_64'
13+
path:
14+
required: false
15+
description: 'Where to write the SDK files'
16+
default: ''
917
runs:
1018
using: 'node12'
1119
main: 'dist/index.js'

main.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import * as core from '@actions/core'
2+
import {get} from './src/downloader'
23

34
async function run(): Promise<void> {
45
try {
5-
core.debug('Running the Action')
6+
const flavor = core.getInput('flavor')
7+
const architecture = core.getInput('architecture')
8+
9+
const {artifactName, download} = await get(flavor, architecture)
10+
const outputDirectory = core.getInput('path') || `C:/${artifactName}`
11+
12+
core.info(`Downloading ${artifactName}`)
13+
await download(outputDirectory, true)
614
} catch (error) {
715
core.setFailed(error.message)
816
}

0 commit comments

Comments
 (0)