Skip to content
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

Ft/regex repos w/dry run #47

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

alangonzalez
Copy link
Contributor

Adds REPO_ENABLE_REGEX to turn on regex filtering and then two options REPO_INCLUDE_REGEX to include maching repos and REPO_EXCLUDE_REGEX to exclude matching repos.

Also added a dry run option in .env, called DRY_RUN for the worker during enable operation. It's pretty basic, but allows me to check what would happen in a run. This is useful for regex testing without actually running anything. Maybe confusing for others, if they think dry_run applies to everything. It just applies to the npm run start (enable) worker.

Lastly, put a try/catch block in the worker to skip over errors. I have repos that are archived and they get an error since they can't take changes. I also run on existing repos that already have an action on them, so this skips them in a non-ideal way, but allows me to keep going on the full run without getting caught up in a single error on one repo.

Sorry for the comment on the commit, I didn't realize I didn't add one until after. So the changes only say generic reason.

@agonzalez-plume
Copy link
Contributor

FTW, Regex is case-insensitive through directly argument in the new Regex call. That may catch up some people. We could also make the regex syntax in the .env be the long form notation /.*/, then the regex call would take the options for global/case insensitive in the .env directly. May be better now that I'm thinking about it.

@NickLiffen
Copy link
Owner

Hey @alangonzalez 👋

Thanks for raising this pull request 💯

I would be more than happy to get some regex's in here to help you 👍

Firstly, can you help me understand some examples use cases where this would be useful, please?

I assume this would only apply during the yarn run getRepos or does this run on yarn run getOrgs as well?

Are you looking to run naming conventions on this? E.G find repos in the list that start with repoStart-repoEnd?

@agonzalez-plume
Copy link
Contributor

I only coded this for the 'npm run start' flow.

So I create a full list of repos for my orgs, no filtering, just the full list. Then during operation I run the following flow every once in a while to double check that I got the list of repos to run on correct and there aren't too many in a run. Here I am running on only repos starting with a-c & A-C. Like I said it's hardcoded to case-insensitive, this regex should probably be /^[a-c]/i

# Dry run
DRY_RUN=true

# Repo regex
REPO_ENABLE_REGEX=true
REPO_INCLUDE_REGEX=^[a-c]
#REPO_EXCLUDE_REGEX=.*

Then I run the npm run start 2>&1|grep DRY to see what repos will be modified. After the visual verification, I turn dry-run off and re-run.

I made the regex's flexible for anyone else who may want to include/exclude repos for whatever naming convention they have. It's also plausible to use the regex's for the repos.json and swap the lists in and out depending on what you want to run on, but I opt'd to keep the repos.json full length and not have lists around. Also possible is to have a filter flag in the repos.json on each repo that activates the whole entry for inclusion, but I wanted more flexibility in the runtime.

I mainly use the INCLUDE regex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants