Skip to content

Commit

Permalink
implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
MCKanpolat committed Nov 25, 2020
1 parent e849b57 commit df2f42d
Show file tree
Hide file tree
Showing 12 changed files with 11,895 additions and 3,214 deletions.
103 changes: 0 additions & 103 deletions README.md

This file was deleted.

41 changes: 19 additions & 22 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
import {wait} from '../src/wait'
import * as process from 'process'
import * as cp from 'child_process'
import * as path from 'path'
import {increment} from '../src/versionBuilder'

test('throws invalid number', async () => {
const input = parseInt('foo', 10)
await expect(wait(input)).rejects.toThrow('milliseconds not a number')
test('increment minor version', () => {
const nextVersion = increment('1.0.0', '', ['minor'])
console.log(nextVersion.version)
expect(nextVersion.version).toEqual('1.1.0')
})

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)
test('increment major version', () => {
const nextVersion = increment('1.0.0', '', ['major'])
console.log(nextVersion.version)
expect(nextVersion.version).toEqual('2.0.0')
})

// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
process.env['INPUT_MILLISECONDS'] = '500'
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())
test('increment patch version', () => {
const nextVersion = increment('1.0.0', '', ['patch'])
console.log(nextVersion.version)
expect(nextVersion.version).toEqual('1.0.1')
})

test('increment pre patch version', () => {
const nextVersion = increment('1.0.0', 'beta', ['prepatch'])
console.log(nextVersion.version)
expect(nextVersion.version).toEqual('1.0.1-beta.0')
})
14 changes: 7 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: 'Your name here'
description: 'Provide a description here'
author: 'Your name or organization here'
name: 'Auto Increment Semver Action'
description: 'Generates a new version using Pull Request Labels with Semver'
author: 'Mehmet Can Kanpolat'
inputs:
milliseconds: # change this
required: true
description: 'input description here'
default: 'default value if applicable'
identifier:
required: false
description: 'identifier for version (beta,alpha..)'
default: ''
runs:
using: 'node12'
main: 'dist/index.js'
Loading

0 comments on commit df2f42d

Please sign in to comment.