Skip to content

Commit

Permalink
Merge pull request #6 from supplypike/pr1
Browse files Browse the repository at this point in the history
added tool caching functionality
  • Loading branch information
HarryGogonis committed Sep 25, 2020
2 parents 6d0dc2f + 29907af commit c868add
Show file tree
Hide file tree
Showing 13 changed files with 5,052 additions and 107 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ jobs:
- uses: actions/checkout@v2
- uses: ./
with:
milliseconds: 1000
uri: 'https://github.com/docker/compose/releases/download/1.27.4/docker-compose-Linux-x86_64'
name: 'docker-compose'
version: '1.27.4'
34 changes: 10 additions & 24 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
import {wait} from '../src/wait'
import * as process from 'process'
import * as cp from 'child_process'
import * as path from 'path'
import {Config} from '../src/config'
import {getTool} from '../src/tool'

test('throws invalid number', async () => {
const input = parseInt('foo', 10)
await expect(wait(input)).rejects.toThrow('milliseconds not a number')
})

test('wait 500 ms', async () => {
const start = new Date()
await wait(500)
const end = new Date()
var delta = Math.abs(end.getTime() - start.getTime())
expect(delta).toBeGreaterThan(450)
})

// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
process.env['INPUT_MILLISECONDS'] = '500'
const ip = path.join(__dirname, '..', 'lib', 'main.js')
const options: cp.ExecSyncOptions = {
env: process.env
test('dowloads and extracts tool', async () => {
const config: Config = {
uri:
'https://github.com/docker/compose/releases/download/1.27.4/docker-compose-Linux-x86_64',
name: 'docker-compose',
version: '1.27.4'
}
console.log(cp.execSync(`node ${ip}`, options).toString())

expect(await getTool(config)).toBeTruthy()
})
17 changes: 11 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: 'Your name here'
description: 'Provide a description here'
author: 'Your name or organization here'
name: 'setup-bin'
description: cache and install a binary to $PATH
author: supplypike
inputs:
milliseconds: # change this
uri:
required: true
description: 'input description here'
default: 'default value if applicable'
description: download link for binary
name:
required: true
description: name of binary
version:
required: true
description: version of binary
runs:
using: 'node12'
main: 'dist/index.js'
Loading

0 comments on commit c868add

Please sign in to comment.