From 9ccd2c001aaa265db08d8b0c0b77cc8093443b4b Mon Sep 17 00:00:00 2001 From: MuriloChianfa Date: Thu, 7 Dec 2023 06:19:56 -0300 Subject: [PATCH] fixing tests on pipeline --- .eslintignore | 1 + .github/workflows/ci.yml | 4 ++-- .prettierignore | 3 ++- .prettierrc.json | 2 +- __tests__/main.test.js | 25 ++++++++++++++++++++----- dist/index.js | 4 ++-- src/evaluation.js | 5 ++++- src/inputs/encoder-version.js | 3 ++- src/inputs/php-target-version.js | 3 ++- 9 files changed, 36 insertions(+), 14 deletions(-) diff --git a/.eslintignore b/.eslintignore index 9ff5c1c..b796a7e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,3 +2,4 @@ lib/ dist/ node_modules/ coverage/ +encrypted/ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dca9ec6..32cee1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,8 +55,8 @@ jobs: id: test-action uses: ./ with: - milliseconds: 1000 + template: 'laravel' - name: Print Output id: output - run: echo "${{ steps.test-action.outputs.time }}" + run: echo "${{ steps.test-action.outputs.status }}" diff --git a/.prettierignore b/.prettierignore index 64f046d..b0beda5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,4 @@ dist/ node_modules/ -coverage/ \ No newline at end of file +coverage/ +encrypted/ \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json index c173f6b..a378146 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,5 +1,5 @@ { - "printWidth": 120, + "printWidth": 80, "tabWidth": 2, "useTabs": false, "semi": false, diff --git a/__tests__/main.test.js b/__tests__/main.test.js index 9864aa8..4e715ba 100644 --- a/__tests__/main.test.js +++ b/__tests__/main.test.js @@ -23,10 +23,22 @@ describe('action', () => { expect(runMock).toHaveReturned() // 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( + 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') @@ -35,6 +47,9 @@ describe('action', () => { expect(debugMock).toHaveBeenNthCalledWith(8, '') expect(debugMock).toHaveBeenNthCalledWith(9, '') - expect(setOutputMock).toHaveBeenCalledWith('status', 'Project encoded with success') + expect(setOutputMock).toHaveBeenCalledWith( + 'status', + 'Project encoded with success' + ) }, 20000) }) diff --git a/dist/index.js b/dist/index.js index 5b6457a..4be8377 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7,7 +7,7 @@ var __webpack_exports__ = {}; /** * The entrypoint for the action. */ -const { run } = require('./main') +import { main } from './main'; -run() +main.run() diff --git a/src/evaluation.js b/src/evaluation.js index 18b58c4..9e7472d 100644 --- a/src/evaluation.js +++ b/src/evaluation.js @@ -13,7 +13,10 @@ module.exports = async function evaluation() { const cwd = process.cwd() if (!fs.existsSync('ioncube_encoder_evaluation')) { - await download('https://www.ioncube.com/eval_linux', `${cwd}/ioncube_encoder_evaluation.tar.gz`) + await download( + 'https://www.ioncube.com/eval_linux', + `${cwd}/ioncube_encoder_evaluation.tar.gz` + ) await tar.extract({ file: `${cwd}/ioncube_encoder_evaluation.tar.gz` }) if (fs.existsSync(`${cwd}/ioncube_encoder_evaluation.tar.gz`)) { diff --git a/src/inputs/encoder-version.js b/src/inputs/encoder-version.js index da226fd..8e95c24 100644 --- a/src/inputs/encoder-version.js +++ b/src/inputs/encoder-version.js @@ -5,7 +5,8 @@ const core = require('@actions/core') * @returns {string} Returns a validated encoder-version input. */ module.exports = function validateEncoderVersion(standard = 'current') { - let encoderVersion = core.getInput('encoder-version', { required: true }) ?? standard + let encoderVersion = + core.getInput('encoder-version', { required: true }) ?? standard core.debug(`Using encoder version: ${encoderVersion}`) diff --git a/src/inputs/php-target-version.js b/src/inputs/php-target-version.js index 86e10f5..7586f33 100644 --- a/src/inputs/php-target-version.js +++ b/src/inputs/php-target-version.js @@ -5,7 +5,8 @@ const core = require('@actions/core') * @returns {string} Returns a validated php-target-version input. */ module.exports = function validatePhpTargetVersion(standard = '8.2') { - let phpTargetVersion = core.getInput('php-target-version', { required: true }) ?? standard + let phpTargetVersion = + core.getInput('php-target-version', { required: true }) ?? standard core.debug(`Using PHP target version: ${phpTargetVersion}`)