Skip to content

acc: Do env var substitution in EnvMatrix values#2678

Merged
denik merged 16 commits intomainfrom
denik/acc-variables-in-envmatrix
Apr 8, 2025
Merged

acc: Do env var substitution in EnvMatrix values#2678
denik merged 16 commits intomainfrom
denik/acc-variables-in-envmatrix

Conversation

@denik
Copy link
Copy Markdown
Contributor

@denik denik commented Apr 8, 2025

Changes

When a $VAR reference is used in value of EnvMatrix, it'll be replaced with its value if there is such variable previously defined.

Why

It's useful to define variables in terms of other variables. For example you can define "$MYCLI=$CLI --someparam". I'm using it to define CLI command that either runs from bundle root or another directory.

Tests

Unit tests + acceptance test.

@denik denik temporarily deployed to test-trigger-is April 8, 2025 13:21 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is April 8, 2025 13:32 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is April 8, 2025 14:18 — with GitHub Actions Inactive
@denik denik enabled auto-merge April 8, 2025 14:43
@denik denik added this pull request to the merge queue Apr 8, 2025
Merged via the queue into main with commit 85fa1bf Apr 8, 2025
9 checks passed
@denik denik deleted the denik/acc-variables-in-envmatrix branch April 8, 2025 14:51
parts := strings.SplitN(e, "=", 2)
if len(parts) == 2 {
key, val := parts[0], parts[1]
re := regexp.MustCompile(`\$` + key + `\b`)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect you need \b to avoid replacing $FOO first and failing to replace $FOOBAR second.

Could you include a comment clarifying this? I was puzzled until I realized this is for overlapping names.

kanterov pushed a commit that referenced this pull request Apr 8, 2025
## Changes
When a $VAR reference is used in value of EnvMatrix, it'll be replaced
with its value if there is such variable previously defined.

## Why
It's useful to define variables in terms of other variables. For example
you can define "$MYCLI=$CLI --someparam". I'm using it to define CLI
command that either runs from bundle root or another directory.

## Tests
Unit tests + acceptance test.
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