Skip to content

Commit

Permalink
upgrading versions for action
Browse files Browse the repository at this point in the history
  • Loading branch information
MuriloChianfa committed Sep 1, 2024
1 parent ff2debd commit fbe4b6a
Show file tree
Hide file tree
Showing 16 changed files with 11,635 additions and 1,106 deletions.
41 changes: 0 additions & 41 deletions .devcontainer/devcontainer.json

This file was deleted.

1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ lib/
dist/
node_modules/
coverage/
encrypted/
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,13 @@ __tests__/runner/*
.idea
.vscode
*.code-workspace

# Custom
encrypted
eval_linux
ioncube_encoder_evaluation
ioncube_encoder_evaluation.tar.gz

# Devcontainer
.devcontainer
.devcontainer/*
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
node_modules/
coverage/
coverage/
encrypted/
3 changes: 0 additions & 3 deletions CODEOWNERS

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Explore a complete example of a workflow that utilizes this action in the <a hre
## Testing this package
```bash
npm run install
npm run lint
npm run test
npm run package
Expand Down
145 changes: 93 additions & 52 deletions __tests__/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,84 +13,125 @@ 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 ''
}
})

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(debugMock).toHaveBeenNthCalledWith(1, 'Waiting 500 milliseconds ...')
// Verify that all of the core library functions were called correctly with default values
expect(debugMock).toHaveBeenNthCalledWith(
1,
'Encoding files using template: php'
)
expect(debugMock).toHaveBeenNthCalledWith(
2,
expect.stringMatching(timeRegex)
'Using encoder version: current'
)
expect(debugMock).toHaveBeenNthCalledWith(
3,
expect.stringMatching(timeRegex)
'Using PHP target version: 8.2'
)
expect(setOutputMock).toHaveBeenNthCalledWith(
1,
'time',
expect.stringMatching(timeRegex)
expect(debugMock).toHaveBeenNthCalledWith(
4,
'Using target architecture: x86-64'
)
expect(debugMock).toHaveBeenNthCalledWith(5, 'Using input files: .')
expect(debugMock).toHaveBeenNthCalledWith(6, 'Using output path: encrypted')
expect(debugMock).toHaveBeenNthCalledWith(7, 'Using reflection for: NONE')
expect(debugMock).toHaveBeenNthCalledWith(8, 'Encrypting files: NONE')
expect(debugMock).toHaveBeenNthCalledWith(9, 'Encoding into ASCII format')
expect(debugMock).toHaveBeenNthCalledWith(10, 'Using optimization: more')
expect(debugMock).toHaveBeenNthCalledWith(11, 'Now allow doc comments')
expect(debugMock).toHaveBeenNthCalledWith(
12,
'Checking for loader in environment'
)
expect(debugMock).toHaveBeenNthCalledWith(13, 'Adding preamble file: NONE')
expect(debugMock).toHaveBeenNthCalledWith(14, 'Using passphrase: NONE')
expect(debugMock).toHaveBeenNthCalledWith(15, 'Using license check: auto')
expect(debugMock).toHaveBeenNthCalledWith(
16,
'Using license file in runtime path: NONE'
)
expect(debugMock).toHaveBeenNthCalledWith(
17,
'Using callback file in runtime path: NONE'
)
})

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 ''
}
})

await main.run()
expect(runMock).toHaveReturned()
// No errors
expect(debugMock).toHaveBeenNthCalledWith(18, 0)
expect(debugMock).toHaveBeenNthCalledWith(19, '')
expect(debugMock).toHaveBeenNthCalledWith(20, '')

// Verify that all of the core library functions were called correctly
expect(setFailedMock).toHaveBeenNthCalledWith(
1,
'milliseconds not a number'
expect(setOutputMock).toHaveBeenCalledWith(
'status',
'Project encoded with success'
)
})
}, 20000)

it('fails if no input is provided', async () => {
// Set the action's inputs as return values from core.getInput()
it('run succefully with laravel template', async () => {
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
throw new Error('Input required and not supplied: milliseconds')
default:
return ''
}
if (name === 'template') return 'laravel'
})

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

// Verify that all of the core library functions were called correctly
expect(setFailedMock).toHaveBeenNthCalledWith(
// Verify that all of the core library functions were called correctly with default values
expect(debugMock).toHaveBeenNthCalledWith(
1,
'Input required and not supplied: milliseconds'
'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')
expect(debugMock).toHaveBeenNthCalledWith(7, 'Allowing reflection for all')
expect(debugMock).toHaveBeenNthCalledWith(
8,
'Encrypting files: *.blade.php'
)
expect(debugMock).toHaveBeenNthCalledWith(9, 'Encoding into binary format')
expect(debugMock).toHaveBeenNthCalledWith(10, 'Using optimization: max')
expect(debugMock).toHaveBeenNthCalledWith(11, 'Now allow doc comments')
expect(debugMock).toHaveBeenNthCalledWith(
12,
'Not checking for loader in environment'
)
expect(debugMock).toHaveBeenNthCalledWith(13, 'Adding preamble file: NONE')
expect(debugMock).toHaveBeenNthCalledWith(14, 'Using passphrase: CHANGEME')
expect(debugMock).toHaveBeenNthCalledWith(15, 'Using license check: script')
expect(debugMock).toHaveBeenNthCalledWith(
16,
'Using license file in runtime path: /opt/license'
)
expect(debugMock).toHaveBeenNthCalledWith(
17,
'Using callback file in runtime path: public/ioncube.php'
)

// No errors
expect(debugMock).toHaveBeenNthCalledWith(18, 0)
expect(debugMock).toHaveBeenNthCalledWith(19, '')
expect(debugMock).toHaveBeenNthCalledWith(20, '')

expect(setOutputMock).toHaveBeenCalledWith(
'status',
'Project encoded with success'
)
})
})
24 changes: 0 additions & 24 deletions __tests__/wait.test.js

This file was deleted.

Loading

0 comments on commit fbe4b6a

Please sign in to comment.