-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(config): support reading from local file if it exists #394
Conversation
This change will also fix #16 |
Any news about this? This is actually needed when labeler.yml is auto-generated in build time. |
@lrstanley I created a PR for your PR, that updates the branch and uses async |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, @lrstanley!
Thanks for your contribution!
I left a few comments, otherwise your solution looks great.
Signed-off-by: Liam Stanley <me@liamstanley.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, @lrstanley! Thanks for your changes. Could you also provide us with the test case for this functionality?
Hey, @lrstanley! |
I don't see any existing mock/testing functionality for the actual reads from the API, and if I write a test, it should probably cover the case if a file doesn't exist (or similar), which means it'd try and read from the remote. Not sure best practice on how to implement that. Do the octokit libraries provide ways of mocking those calls? |
@lrstanley as for tests - you may utilize the following approach. |
I think we can add two tests here:
Here is an example of the first test case: it('uses local configuration file if it exists', async () => {
const configFile = 'only_pdfs.yml';
const configFilePath = path.join(__dirname, 'fixtures', configFile);
configureInput({
'configuration-path': configFilePath
});
await run();
expect(reposMock).toHaveBeenCalledTimes(0);
}); |
@lrstanley thank you for the contribution! |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [actions/labeler](https://togithub.com/actions/labeler) | action | minor | `v4.2.0` -> `v4.3.0` | --- ### ⚠ Dependency Lookup Warnings ⚠ Warnings were logged while processing this repo. Please check the logs for more information. --- ### Release Notes <details> <summary>actions/labeler (actions/labeler)</summary> ### [`v4.3.0`](https://togithub.com/actions/labeler/releases/tag/v4.3.0) [Compare Source](https://togithub.com/actions/labeler/compare/v4.2.0...v4.3.0) #### What's Changed In scope of this release, the ability to specify pull request number(s) was added by [@​credfeto](https://togithub.com/credfeto) in [https://github.com/actions/labeler/pull/349](https://togithub.com/actions/labeler/pull/349). Support for reading from the configuration file presented on the runner was added by [@​lrstanley](https://togithub.com/lrstanley) in [https://github.com/actions/labeler/pull/394](https://togithub.com/actions/labeler/pull/394). It allows you to use a configuration file generated during workflow run or uploaded from a separate repository. Please refer to the [action documentation](https://togithub.com/actions/labeler#inputs) for more information. This release also includes the following changes: - Improved Error message for missing config file by [@​Gornoka](https://togithub.com/Gornoka) in [https://github.com/actions/labeler/pull/475](https://togithub.com/actions/labeler/pull/475) - Early exit when no files are changed by [@​nathanhammond](https://togithub.com/nathanhammond) in [https://github.com/actions/labeler/pull/456](https://togithub.com/actions/labeler/pull/456) - Add examples to match all repo files by [@​MaksimZhukov](https://togithub.com/MaksimZhukov) in [https://github.com/actions/labeler/pull/600](https://togithub.com/actions/labeler/pull/600) - Fix a typo in the example about using the action outputs by [@​MaksimZhukov](https://togithub.com/MaksimZhukov) in [https://github.com/actions/labeler/pull/606](https://togithub.com/actions/labeler/pull/606) - Bump eslint from 8.43.0 to 8.44.0 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/actions/labeler/pull/601](https://togithub.com/actions/labeler/pull/601) - Bump [@​typescript-eslint/parser](https://togithub.com/typescript-eslint/parser) from 5.60.1 to 5.61.0 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/actions/labeler/pull/602](https://togithub.com/actions/labeler/pull/602) - Bump [@​typescript-eslint/eslint-plugin](https://togithub.com/typescript-eslint/eslint-plugin) from 5.60.1 to 5.61.0 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/actions/labeler/pull/604](https://togithub.com/actions/labeler/pull/604) - Bump tough-cookie from 4.1.2 to 4.1.3 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/actions/labeler/pull/609](https://togithub.com/actions/labeler/pull/609) - Bump [@​octokit/plugin-retry](https://togithub.com/octokit/plugin-retry) from 5.0.4 to 5.0.5 by [@​MaksimZhukov](https://togithub.com/MaksimZhukov) in [https://github.com/actions/labeler/pull/610](https://togithub.com/actions/labeler/pull/610) #### New Contributors - [@​credfeto](https://togithub.com/credfeto) made their first contribution in [https://github.com/actions/labeler/pull/349](https://togithub.com/actions/labeler/pull/349) - [@​lrstanley](https://togithub.com/lrstanley) made their first contribution in [https://github.com/actions/labeler/pull/394](https://togithub.com/actions/labeler/pull/394) - [@​nathanhammond](https://togithub.com/nathanhammond) made their first contribution in [https://github.com/actions/labeler/pull/456](https://togithub.com/actions/labeler/pull/456) **Full Changelog**: actions/labeler@v4...v4.3.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/owntracks/android). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi41LjMiLCJ1cGRhdGVkSW5WZXIiOiIzNi41LjMiLCJ0YXJnZXRCcmFuY2giOiJtYXN0ZXIifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [actions/labeler](https://togithub.com/actions/labeler) | action | minor | `v4.2.0` -> `v4.3.0` | --- ### ⚠ Dependency Lookup Warnings ⚠ Warnings were logged while processing this repo. Please check the logs for more information. --- ### Release Notes <details> <summary>actions/labeler (actions/labeler)</summary> ### [`v4.3.0`](https://togithub.com/actions/labeler/releases/tag/v4.3.0) [Compare Source](https://togithub.com/actions/labeler/compare/v4.2.0...v4.3.0) #### What's Changed In scope of this release, the ability to specify pull request number(s) was added by [@​credfeto](https://togithub.com/credfeto) in [https://github.com/actions/labeler/pull/349](https://togithub.com/actions/labeler/pull/349). Support for reading from the configuration file presented on the runner was added by [@​lrstanley](https://togithub.com/lrstanley) in [https://github.com/actions/labeler/pull/394](https://togithub.com/actions/labeler/pull/394). It allows you to use a configuration file generated during workflow run or uploaded from a separate repository. Please refer to the [action documentation](https://togithub.com/actions/labeler#inputs) for more information. This release also includes the following changes: - Improved Error message for missing config file by [@​Gornoka](https://togithub.com/Gornoka) in [https://github.com/actions/labeler/pull/475](https://togithub.com/actions/labeler/pull/475) - Early exit when no files are changed by [@​nathanhammond](https://togithub.com/nathanhammond) in [https://github.com/actions/labeler/pull/456](https://togithub.com/actions/labeler/pull/456) - Add examples to match all repo files by [@​MaksimZhukov](https://togithub.com/MaksimZhukov) in [https://github.com/actions/labeler/pull/600](https://togithub.com/actions/labeler/pull/600) - Fix a typo in the example about using the action outputs by [@​MaksimZhukov](https://togithub.com/MaksimZhukov) in [https://github.com/actions/labeler/pull/606](https://togithub.com/actions/labeler/pull/606) - Bump eslint from 8.43.0 to 8.44.0 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/actions/labeler/pull/601](https://togithub.com/actions/labeler/pull/601) - Bump [@​typescript-eslint/parser](https://togithub.com/typescript-eslint/parser) from 5.60.1 to 5.61.0 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/actions/labeler/pull/602](https://togithub.com/actions/labeler/pull/602) - Bump [@​typescript-eslint/eslint-plugin](https://togithub.com/typescript-eslint/eslint-plugin) from 5.60.1 to 5.61.0 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/actions/labeler/pull/604](https://togithub.com/actions/labeler/pull/604) - Bump tough-cookie from 4.1.2 to 4.1.3 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/actions/labeler/pull/609](https://togithub.com/actions/labeler/pull/609) - Bump [@​octokit/plugin-retry](https://togithub.com/octokit/plugin-retry) from 5.0.4 to 5.0.5 by [@​MaksimZhukov](https://togithub.com/MaksimZhukov) in [https://github.com/actions/labeler/pull/610](https://togithub.com/actions/labeler/pull/610) #### New Contributors - [@​credfeto](https://togithub.com/credfeto) made their first contribution in [https://github.com/actions/labeler/pull/349](https://togithub.com/actions/labeler/pull/349) - [@​lrstanley](https://togithub.com/lrstanley) made their first contribution in [https://github.com/actions/labeler/pull/394](https://togithub.com/actions/labeler/pull/394) - [@​nathanhammond](https://togithub.com/nathanhammond) made their first contribution in [https://github.com/actions/labeler/pull/456](https://togithub.com/actions/labeler/pull/456) **Full Changelog**: actions/labeler@v4...v4.3.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/owntracks/android). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi41LjMiLCJ1cGRhdGVkSW5WZXIiOiIzNi41LjMiLCJ0YXJnZXRCcmFuY2giOiJtYXN0ZXIifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [actions/labeler](https://togithub.com/actions/labeler) | action | minor | `v4.2.0` -> `v4.3.0` | --- ### ⚠ Dependency Lookup Warnings ⚠ Warnings were logged while processing this repo. Please check the logs for more information. --- ### Release Notes <details> <summary>actions/labeler (actions/labeler)</summary> ### [`v4.3.0`](https://togithub.com/actions/labeler/releases/tag/v4.3.0) [Compare Source](https://togithub.com/actions/labeler/compare/v4.2.0...v4.3.0) #### What's Changed In scope of this release, the ability to specify pull request number(s) was added by [@​credfeto](https://togithub.com/credfeto) in [https://github.com/actions/labeler/pull/349](https://togithub.com/actions/labeler/pull/349). Support for reading from the configuration file presented on the runner was added by [@​lrstanley](https://togithub.com/lrstanley) in [https://github.com/actions/labeler/pull/394](https://togithub.com/actions/labeler/pull/394). It allows you to use a configuration file generated during workflow run or uploaded from a separate repository. Please refer to the [action documentation](https://togithub.com/actions/labeler#inputs) for more information. This release also includes the following changes: - Improved Error message for missing config file by [@​Gornoka](https://togithub.com/Gornoka) in [https://github.com/actions/labeler/pull/475](https://togithub.com/actions/labeler/pull/475) - Early exit when no files are changed by [@​nathanhammond](https://togithub.com/nathanhammond) in [https://github.com/actions/labeler/pull/456](https://togithub.com/actions/labeler/pull/456) - Add examples to match all repo files by [@​MaksimZhukov](https://togithub.com/MaksimZhukov) in [https://github.com/actions/labeler/pull/600](https://togithub.com/actions/labeler/pull/600) - Fix a typo in the example about using the action outputs by [@​MaksimZhukov](https://togithub.com/MaksimZhukov) in [https://github.com/actions/labeler/pull/606](https://togithub.com/actions/labeler/pull/606) - Bump eslint from 8.43.0 to 8.44.0 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/actions/labeler/pull/601](https://togithub.com/actions/labeler/pull/601) - Bump [@​typescript-eslint/parser](https://togithub.com/typescript-eslint/parser) from 5.60.1 to 5.61.0 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/actions/labeler/pull/602](https://togithub.com/actions/labeler/pull/602) - Bump [@​typescript-eslint/eslint-plugin](https://togithub.com/typescript-eslint/eslint-plugin) from 5.60.1 to 5.61.0 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/actions/labeler/pull/604](https://togithub.com/actions/labeler/pull/604) - Bump tough-cookie from 4.1.2 to 4.1.3 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/actions/labeler/pull/609](https://togithub.com/actions/labeler/pull/609) - Bump [@​octokit/plugin-retry](https://togithub.com/octokit/plugin-retry) from 5.0.4 to 5.0.5 by [@​MaksimZhukov](https://togithub.com/MaksimZhukov) in [https://github.com/actions/labeler/pull/610](https://togithub.com/actions/labeler/pull/610) #### New Contributors - [@​credfeto](https://togithub.com/credfeto) made their first contribution in [https://github.com/actions/labeler/pull/349](https://togithub.com/actions/labeler/pull/349) - [@​lrstanley](https://togithub.com/lrstanley) made their first contribution in [https://github.com/actions/labeler/pull/394](https://togithub.com/actions/labeler/pull/394) - [@​nathanhammond](https://togithub.com/nathanhammond) made their first contribution in [https://github.com/actions/labeler/pull/456](https://togithub.com/actions/labeler/pull/456) **Full Changelog**: actions/labeler@v4...v4.3.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/owntracks/android). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi41LjMiLCJ1cGRhdGVkSW5WZXIiOiIzNi41LjMiLCJ0YXJnZXRCcmFuY2giOiJtYXN0ZXIifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Currently, actions/labeler can only read the configuration from the source repository, due to it using the context and API to fetch the configuration file. This PR adds support for first checking to see if a file matching the provided path exists locally, before it makes a call to the API to get the file.
The primary benefit for this, is it works well with reusable workflows, as all you have to do is grab the file from a central location, before running this on the target repository.