Skip to content

Commit

Permalink
(feat) Add Config Parsing + Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lasith-kg committed Jul 30, 2023
1 parent ab35d77 commit 9f91f17
Show file tree
Hide file tree
Showing 14 changed files with 691 additions and 158 deletions.
124 changes: 70 additions & 54 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,71 @@
{
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"i18n-text/no-en": "off",
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"camelcase": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
},
"env": {
"node": true,
"es6": true,
"jest/globals": true
}
}
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"i18n-text/no-en": "off",
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{"accessibility": "no-public"}
],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-comment": "error",
"camelcase": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": [
"error",
{"allowExpressions": true}
],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error",
"@typescript-eslint/quotes": [
"error",
"single",
{
"avoidEscape": true,
"allowTemplateLiterals": true
}
],
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["off"]
},
"env": {
"node": true,
"es6": true,
"jest/globals": true
}
}
14 changes: 11 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,26 @@ on: # rebuild any PRs and main branch changes
- 'releases/*'

jobs:
build: # make sure build/ci work properly
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
npm install
- run: |
npm run all
test: # make sure the action works on a clean machine without building
test:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- uses: actions/checkout@v3
- uses: ./
with:
milliseconds: 1000
dispatch-method: "workflow_dispatch"
repo: "${{ github.event.repository.name }}"
owner: "${{ github.repository_owner }}"
ref: "main"
workflow: "dispatch.yml"
token: "${{ secrets.GITHUB_TOKEN }}"
29 changes: 0 additions & 29 deletions __tests__/main.test.ts

This file was deleted.

39 changes: 33 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
name: 'Your name here'
description: 'Provide a description here'
author: 'Your name or organization here'
name: 'Dispatch Workflow'
description: 'A GitHub action to dispatch a remote GitHub workflow and optionally retrieve its information'
inputs:
milliseconds: # change this
dispatch-method:
required: true
description: 'input description here'
default: 'default value if applicable'
description: 'The method that will be used for dispatching GitHub workflows: repository_dispatch, workflow_dispatch.'
event-type:
required: false
description: 'If the selected method is repository_dispatch, what event type will be triggered in the remote repository.'
repo:
description: 'Repository of the action to dispatch.'
required: true
owner:
description: 'Owner of the given repository.'
required: true
ref:
description: 'The git reference for the workflow. The reference can be a branch or tag name.'
required: false
workflow:
description: 'Workflow to return an ID for. Can be the ID or the workflow filename.'
required: true
workflow-inputs:
description: 'A JSON object that contains extra information that will be provided to the workflow'
required: false
workflow-timeout-seconds:
description: 'Time until giving up waiting for the start of the workflow run.'
required: false
default: "300"
token:
description: 'GitHub API token for making API requests.'
required: true
export-run-id:
description: 'A flag to enable the discovery of the Run ID from the dispatched workflow.'
required: false
default: "false"
runs:
using: 'node16'
main: 'dist/index.js'
Loading

0 comments on commit 9f91f17

Please sign in to comment.