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

fix(executor/local): do not override env with machine details for local exec #522

Merged
merged 6 commits into from
Oct 9, 2023

Conversation

ecrupper
Copy link
Contributor

@ecrupper ecrupper commented Oct 6, 2023

This is the second of three changes that will enhance the vela exec pipeline command. These changes fall under the Worker section below.

The Issue

vela exec pipeline does not work with templates. It also does not work with custom environments if the user is trying to emulate any of the default environment variables, such as VELA_BUILD_COMMIT.

Server Changes

  1. Execute the local environment sourcing after the default env override. This will ensure that user-set values that would be found in the default environment will be properly interpreted by the compiler.
  2. Adjustments to getTemplate that allows the compiler to read both from local file tree as well as remote using a GitHub token.

Worker Changes

  1. Remove calls to merge environment with default environment found in executor/local/step.go. This call is unnecessary and will only overwrite user-supplied environment values found in the default env.

CLI Changes

  1. Support for --template, --template-file, --compiler.github.token, and --compiler.github.url flags to the exec pipeline command. This will allow users the option to leverage templates in local pipeline execution, both local and remote.
  2. Support for --env-file and --env-file-path to allow users to source environment variables from a file.

@ecrupper ecrupper requested a review from a team as a code owner October 6, 2023 15:17
@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Merging #522 (b895622) into main (be492bd) will decrease coverage by 0.02%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #522      +/-   ##
==========================================
- Coverage   83.44%   83.42%   -0.02%     
==========================================
  Files          69       69              
  Lines        5381     5371      -10     
==========================================
- Hits         4490     4481       -9     
  Misses        746      746              
+ Partials      145      144       -1     
Files Coverage Δ
executor/local/step.go 91.96% <100.00%> (+1.64%) ⬆️
executor/local/build.go 77.39% <0.00%> (-0.27%) ⬇️
executor/local/stage.go 85.13% <0.00%> (-1.17%) ⬇️

wass3rw3rk
wass3rw3rk previously approved these changes Oct 6, 2023
wass3rw3rk
wass3rw3rk previously approved these changes Oct 6, 2023
@@ -90,6 +91,7 @@ func (c *client) ExecStage(ctx context.Context, s *pipeline.Stage, m *sync.Map)
//
// https://pkg.go.dev/github.com/go-vela/worker/internal/step#Skip
if step.Skip(_step, c.build, c.repo) {
logrus.Infof("Skipping step %s due to ruleset", _step.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

disclaimer i havent tested the PR to see what the logging actually looks like mid-execution. but we usually print to stdout during pipeline execution, should we do that here to follow the pattern?

Copy link
Contributor Author

@ecrupper ecrupper Oct 9, 2023

Choose a reason for hiding this comment

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

It looks the same as all the start up debug logs:

vela exec pipeline 
DEBU[0000] validating pipeline configuration            
DEBU[0000] Creating registry clients from CLI configuration 
...
[step: init] > Preparing service images...
[step: init] > Preparing stage images...
[step: init] > Preparing step images...
DEBU[0000] streaming build logs                         
[step: init] $ docker image inspect golang:latest
sha256:2159148dcc081245165b2aa99fc5a94ca9818bece66839d8eb11c9335ae9e688
...
[step: docker-build] INFO[0000] Skipping push to container registry due to --no-push flag 
INFO[0004] Skipping step notify_slack due to ruleset 
[step: random] > Streaming container 'step_EastonCrupper_myvela_1_random'...

Think that's decent enough?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah sweet, the example is great. it views more like a log from the worker process controlling the execution flow, i like it!

@ecrupper ecrupper merged commit 26628ba into main Oct 9, 2023
11 of 12 checks passed
@ecrupper ecrupper deleted the enhance/executor/local-exec-env-fix branch October 9, 2023 16:30
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.

4 participants