IvanFon / super-labeler-action

A superpowered issue and pull request labeler for Github Actions.
GNU General Public License v3.0
22 stars 12 forks source link

Feat: allow local run #22

Open jbinda opened 4 years ago

jbinda commented 4 years ago

closes #10

I have provide some refactor that allow to run action locally. Do not modify README.md yet however the steps to run locally are as follow:

  1. use yarn dev:init to copy example .env file and configs from example folder ( pass -o if you want to override already existing files in root directory having the same name )
  2. go to .env and pass your github token (see the comment inside env on how to get it) as well as test repo name and owner in below pattern
owner/repo-name
  1. keep GH_ACTION_LOCAL_TEST=true to not proceed any action on mentioned repo. Comment this line to allow modification of result on repo

  2. configure event.pr.json and event.issue.json to mock issue / pr payload

  3. run yarn dev:issue to simulate action on issue

  4. run yarn dev:pr to simulate action on pr

CHANGES

BREAKING_CHANGES: I have noticed that there was a problem to pass token from local .env when its name was 'github-token' in action.yml. After I have change it to GITHUB_TOKEN it start to work

CONCLUSION Let me know what you think ( probably naming etc is not 100% accurate) however lets focus on the approach first.

With above setup we can mock events and see results without pushing the code to repo and manually modifying the issue/pr in test repo. I'm also working with extend logging system and will target this PR when finish

jayu commented 4 years ago

To not introduce breaking change I would suggest to config data directly from env during the local run Github actions require uppercased values https://github.com/actions/toolkit/blob/905c2aa21671e57683c7113418f7bc4eaed964be/packages/core/src/core.ts#L67

jbinda commented 4 years ago

To not introduce breaking change I would suggest to config data directly from env during the local run Github actions require uppercased values https://github.com/actions/toolkit/blob/905c2aa21671e57683c7113418f7bc4eaed964be/packages/core/src/core.ts#L67

Hmm ok I was using it like INPUT_GITHUB_TOKEN in my .env file. The problem was in attempt to pull it because I thought that it needs to be aligned with actions.yml

NOT WORKING

const GITHUB_TOKEN = core.getInput('github-token', {
  required: true,
});

After changing to this is works fine and we do need to modify action.yml as you pointed. Thanks ! WORKING

const GITHUB_TOKEN = core.getInput('GITHUB_TOKEN', {
  required: true,
});

However I wonder if we still do not want to include that breaking change to align name patter - WDYT ?

TGTGamer commented 3 years ago

Implemented in #24

Tested and confirmed working