Skip to content

Commit

Permalink
[Feat] Base version of action
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwjn committed Aug 15, 2023
1 parent 4f79b5b commit 2d55381
Show file tree
Hide file tree
Showing 6 changed files with 8,457 additions and 719 deletions.
24 changes: 7 additions & 17 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
import {wait} from '../src/wait'
import * as process from 'process'
import * as cp from 'child_process'
import * as path from 'path'
import {expect, test} from '@jest/globals'
import {test} from '@jest/globals'

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'
// process.env['INPUT_GITHUB_TOKEN'] = ''
// process.env['INPUT_REPO'] = ''
// process.env['INPUT_CURRENT_TAG'] = ''
// process.env['INPUT_PREVIOUS_TAG'] = ''

const np = process.execPath
const ip = path.join(__dirname, '..', 'lib', 'main.js')
const options: cp.ExecFileSyncOptions = {
env: process.env
}

console.log(cp.execFileSync(np, [ip], options).toString())
})
27 changes: 19 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
name: 'Your name here'
description: 'Provide a description here'
author: 'Your name or organization here'
name: Get merged pull requests
description: Compare 2 tags and retrieve all pull requests merged between them
author: Van Ons
inputs:
milliseconds: # change this
github_token:
description: The GitHub token to use.
required: true
description: 'input description here'
default: 'default value if applicable'
repo:
description: 'The repository to use. Defaults to current repository. Expected format: owner/repo'
required: false
current_tag:
description: The current tag to use. Defaults to current/latest tag.
required: false
previous_tag:
description: The previous tag to use. Defaults to one tag before the current tag.
required: false
outputs:
pull_requests:
description: The pull requests merged between the 2 tags.
runs:
using: 'node16'
main: 'dist/index.js'
using: node16
main: dist/index.js
Loading

0 comments on commit 2d55381

Please sign in to comment.