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

Support regex matching when parsing CI configuration file #111

Merged
merged 4 commits into from
Feb 25, 2025

Conversation

jo-basevi
Copy link
Collaborator

Support regex matching for tag/branches when parsing config/ci.json file. This is to allow using regex dev-.* patterns to specify test configuration for all dev branches, e.g.

{
    # ...
    "qa": {
        "dev-.*": { 
            "markers": "dev_config"
        },
        "default": {
           "markers": "config or dev_config"
       }
   },
   "default": { 
        # ....
    }
}

I added a python script for parsing the file so I could just use the standard python regex library for string matching. This meant it was also easier to add tests.

The order for finding a key's (e.g. "markers") value now is:

  1. Exact match for branch/tag name in test type (e.g. qa)
  2. Then first branch name matched with regex pattern for branch name in test type. This means a top-down ordering of regex patterns so would require more specific branch regex to be higher up in the list, e.g. dev-1deg-.* before dev-.*
  3. Default for the test type (e.g. 'qa')
  4. Top-level default

To avoid the composite action modifying the caller workflow environment, I've set update-environment: false in setup-python action, and called the python executable directly using the output of the action (see https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#using-update-environment-flag).

Similarly to avoid checking out the model-config-tests repository to obtain the parse-file.py file of the correct version, I am using github.action_path to access the files in the .github/actions/pares-ci-config directory (see https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context).

References #99

@jo-basevi jo-basevi marked this pull request as ready for review February 24, 2025 02:51
@jo-basevi jo-basevi self-assigned this Feb 24, 2025
@CodeGat CodeGat self-requested a review February 25, 2025 00:00
@jo-basevi jo-basevi merged commit 4d281eb into main Feb 25, 2025
@jo-basevi jo-basevi deleted the 99-Add-regex-matching-to-parse-ci-config branch February 25, 2025 22:14
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.

2 participants