From 1593ef820b4de4662c7dcee2be891606c4eaf99a Mon Sep 17 00:00:00 2001 From: Mikolaj Gasior Date: Wed, 25 Oct 2023 21:34:36 +0200 Subject: [PATCH] Add stub of validate-inputs --- .github/tests/validate-inputs/action.yml | 14 ++++++++++ .github/workflows/test-validate-inputs.yml | 32 ++++++++++++++++++++++ validate-inputs/action.yml | 7 +++++ validate-inputs/dist/index.js | 17 ++++++++++++ validate-inputs/package-lock.json | 13 +++++++++ validate-inputs/package.json | 12 ++++++++ validate-inputs/src/index.js | 6 ++++ 7 files changed, 101 insertions(+) create mode 100644 .github/tests/validate-inputs/action.yml create mode 100644 .github/workflows/test-validate-inputs.yml create mode 100644 validate-inputs/action.yml create mode 100644 validate-inputs/dist/index.js create mode 100644 validate-inputs/package-lock.json create mode 100644 validate-inputs/package.json create mode 100644 validate-inputs/src/index.js diff --git a/.github/tests/validate-inputs/action.yml b/.github/tests/validate-inputs/action.yml new file mode 100644 index 0000000..d71f91c --- /dev/null +++ b/.github/tests/validate-inputs/action.yml @@ -0,0 +1,14 @@ +--- +name: Test action for validate-inputs +description: | + Uses validate-inputs action for checking inputs and throws + an error when any of them is invalid. +inputs: + number: + description: Should be a number + required: true +runs: + using: 'composite' + steps: + - name: Runs validate-inputs + uses: ./validate-inputs diff --git a/.github/workflows/test-validate-inputs.yml b/.github/workflows/test-validate-inputs.yml new file mode 100644 index 0000000..2d96930 --- /dev/null +++ b/.github/workflows/test-validate-inputs.yml @@ -0,0 +1,32 @@ +--- +name: Test validate-inputs action + +on: + pull_request: + branches: + - main + push: + branches: + - main + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + main: + name: Test validate-inputs action + runs-on: ubuntu-20.04 + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Call action with invalid input + uses: ./.github/tests/validate-inputs + with: + number: 'aa' + + - name: Call action with valid input + uses: ./.github/tests/validate-inputs + with: + number: '123' \ No newline at end of file diff --git a/validate-inputs/action.yml b/validate-inputs/action.yml new file mode 100644 index 0000000..dc6d998 --- /dev/null +++ b/validate-inputs/action.yml @@ -0,0 +1,7 @@ +--- +name: Validate inputs +description: | + This action uses regular expressions to validate inputs +runs: + using: 'node20' + main: 'dist/index.js' diff --git a/validate-inputs/dist/index.js b/validate-inputs/dist/index.js new file mode 100644 index 0000000..b5d438d --- /dev/null +++ b/validate-inputs/dist/index.js @@ -0,0 +1,17 @@ +/******/ (() => { // webpackBootstrap +/******/ /* webpack/runtime/compat */ +/******/ +/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +try { + console.log(process.env); + +} catch (error) { + core.setFailed(error.message); +} + +module.exports = __webpack_exports__; +/******/ })() +; \ No newline at end of file diff --git a/validate-inputs/package-lock.json b/validate-inputs/package-lock.json new file mode 100644 index 0000000..cf2a175 --- /dev/null +++ b/validate-inputs/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "validate-inputs", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "validate-inputs", + "version": "1.0.0", + "license": "ISC" + } + } +} diff --git a/validate-inputs/package.json b/validate-inputs/package.json new file mode 100644 index 0000000..df5752a --- /dev/null +++ b/validate-inputs/package.json @@ -0,0 +1,12 @@ +{ + "name": "validate-inputs", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC" +} diff --git a/validate-inputs/src/index.js b/validate-inputs/src/index.js new file mode 100644 index 0000000..1e4406b --- /dev/null +++ b/validate-inputs/src/index.js @@ -0,0 +1,6 @@ +try { + console.log(process.env); + +} catch (error) { + core.setFailed(error.message); +}