Skip to content

Commit

Permalink
adding basic ioncube input parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
MuriloChianfa committed Dec 7, 2023
1 parent 7de7062 commit 7d4dd37
Show file tree
Hide file tree
Showing 25 changed files with 393 additions and 3,066 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@ __tests__/runner/*
.idea
.vscode
*.code-workspace

# Custom
encrypted
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{

Check warning on line 1 in .prettierrc.json

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.
"printWidth": 80,
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": false,
Expand Down
4 changes: 0 additions & 4 deletions CODEOWNERS

This file was deleted.

82 changes: 13 additions & 69 deletions __tests__/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,84 +13,28 @@ const setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
// Mock the action's main function
const runMock = jest.spyOn(main, 'run')

// Other utilities
const timeRegex = /^\d{2}:\d{2}:\d{2}/

describe('action', () => {
beforeEach(() => {
jest.clearAllMocks()
})

it('sets the time output', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
return '500'
default:
return ''
}
})

await main.run()
expect(runMock).toHaveReturned()

// Verify that all of the core library functions were called correctly
expect(debugMock).toHaveBeenNthCalledWith(1, 'Waiting 500 milliseconds ...')
expect(debugMock).toHaveBeenNthCalledWith(
2,
expect.stringMatching(timeRegex)
)
expect(debugMock).toHaveBeenNthCalledWith(
3,
expect.stringMatching(timeRegex)
)
expect(setOutputMock).toHaveBeenNthCalledWith(
1,
'time',
expect.stringMatching(timeRegex)
)
})

it('sets a failed status', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
return 'this is not a number'
default:
return ''
}
})

it('run succefully with default args', async () => {
await main.run()
expect(runMock).toHaveReturned()

// Verify that all of the core library functions were called correctly
expect(setFailedMock).toHaveBeenNthCalledWith(
1,
'milliseconds not a number'
)
})

it('fails if no input is provided', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
throw new Error('Input required and not supplied: milliseconds')
default:
return ''
}
})
// Verify that all of the core library functions were called correctly with default values
expect(debugMock).toHaveBeenNthCalledWith(1, 'Encoding files using template: laravel')
expect(debugMock).toHaveBeenNthCalledWith(2, 'Using encoder version: current')
expect(debugMock).toHaveBeenNthCalledWith(3, 'Using PHP target version: 8.2')
expect(debugMock).toHaveBeenNthCalledWith(4, 'Using target architecture: x86-64')
expect(debugMock).toHaveBeenNthCalledWith(5, 'Using input files: .')
expect(debugMock).toHaveBeenNthCalledWith(6, 'Using output path: encrypted')

await main.run()
expect(runMock).toHaveReturned()
// No errors
expect(debugMock).toHaveBeenNthCalledWith(7, 0)
expect(debugMock).toHaveBeenNthCalledWith(8, '')
expect(debugMock).toHaveBeenNthCalledWith(9, '')

// Verify that all of the core library functions were called correctly
expect(setFailedMock).toHaveBeenNthCalledWith(
1,
'Input required and not supplied: milliseconds'
)
expect(setOutputMock).toHaveBeenCalledWith('status', 'Project encoded with success')
})
})
24 changes: 0 additions & 24 deletions __tests__/wait.test.js

This file was deleted.

68 changes: 58 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,66 @@
name: 'The name of your action here'
description: 'Provide a description here'
author: 'Your name or organization here'
name: 'ioncube-encoder-action'
description: 'Github action for integrate your project encode with ioncube into your CI/CD pipeline.'
author: 'MuriloChianfa'

# Define your inputs here.
inputs:
milliseconds:
description: 'Your input description here'
template:
description: 'The template to choose the best parameters for type of projects'
required: true
default: '1000'
default: laravel
type: choice
options:
- laravel
- php
trial:
description: 'Encode file with trial version of ioncube'
required: true
default: false
type: boolean

input:
description: 'The input path or files to encode'
required: true
default: ''
type: string
output:
description: 'The output path or files encoded'
required: true
default: 'encrypted'
type: string

encoder-version:
description: 'Ioncube encoder version'
required: true
default: 'current'
type: choice
options:
- current
- legacy
- obsolete

php-target-version:
description: 'PHP encoded files target version'
required: true
default: '8.2'
type: choice
options:
- '8.2'
- '8.1'
- '8.0'

arch:
description: 'architecture of target environment runner'
required: true
default: 64
type: choice
options:
- 86
- 64

# Define your outputs here.
outputs:
time:
description: 'Your output description here'
status:
description: 'The message of encode proccess'
type: string

runs:
using: node20
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7d4dd37

Please sign in to comment.