Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Remove formula tmp dir #875

Merged
merged 13 commits into from
Mar 10, 2021
Merged

Remove formula tmp dir #875

merged 13 commits into from
Mar 10, 2021

Conversation

kaduartur
Copy link
Contributor

Description

The need to copy the formula to a temporary folder has been removed, thus reducing the necessary IO when executing a formula.

How to verify it

This improvement should not change the functionality of the rit.

Changelog

Performance - remove tmp dir to formulas

Signed-off-by: Kadu Artur Prussek <[email protected]>
@kaduartur kaduartur added 🔨 improvement Improvement in features 🚧 WIP Work in Progress 🐎 Performance Indicate that an issue or PR is from the performance context labels Feb 26, 2021
@kaduartur kaduartur self-assigned this Feb 26, 2021
Signed-off-by: Kadu Artur Prussek <[email protected]>
Signed-off-by: Kadu Artur Prussek <[email protected]>
Signed-off-by: Kadu Artur Prussek <[email protected]>
@kaduartur kaduartur marked this pull request as ready for review March 1, 2021 21:15
@kaduartur kaduartur added ✔️ ready-for-review ready for review and removed 🚧 WIP Work in Progress labels Mar 1, 2021
@henriquemoraeszup
Copy link
Contributor

can you make an issue and link to your project?

@@ -166,20 +158,6 @@ func (pr PreRunManager) loadConfig(formulaPath string, def formula.Definition) (
return formulaConfig, nil
}

func (pr PreRunManager) createWorkDir(home, formulaPath string, def formula.Definition) (string, error) {
tDir := def.TmpWorkDirPath(home)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to remove this method from pkg/formula

Comment on lines 177 to 181
if got != nil || tt.out.err != nil {
assert.EqualError(t, tt.out.err, got.Error())
}

_ = os.Chdir(pwd)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we test for file creation on the correct dir? This is the purpose of this PR correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which file? this PR just stops copying the /bin folder of a formula to a tmp folder.

Comment on lines 151 to 155
local := NewRunner(in.inputResolver, in.preRun, in.fileManager, in.env, homeDir)
got := local.Run(in.def, api.Prompt, false, nil)

if tt.out.err != nil && got != nil && tt.out.err.Error() != got.Error() {
t.Errorf("Run(%s) got %v, want %v", tt.name, got, tt.out.err)
if tt.want != nil || got != nil {
assert.EqualError(t, got, tt.want.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@henriquemoraeszup henriquemoraeszup added waiting reply Waiting for an answer to a comment and removed ✔️ ready-for-review ready for review labels Mar 2, 2021
Copy link
Contributor

@henriquemoraeszup henriquemoraeszup left a comment

Choose a reason for hiding this comment

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

Just requesting since it was already approved

@kaduartur kaduartur linked an issue Mar 2, 2021 that may be closed by this pull request
4 tasks
Signed-off-by: Kadu Artur Prussek <[email protected]>
@kaduartur kaduartur added ✔️ ready-for-review ready for review and removed waiting reply Waiting for an answer to a comment labels Mar 3, 2021
brunasilvazup
brunasilvazup previously approved these changes Mar 3, 2021
@kaduartur
Copy link
Contributor Author

/merge qa

@henriquemoraeszup
Copy link
Contributor

It would be interesting to simulate an execution that creates a file and checks its creation on the correct folder

Signed-off-by: Kadu Artur Prussek <[email protected]>
Signed-off-by: Kadu Artur Prussek <[email protected]>
@kaduartur
Copy link
Contributor Author

The pwd of the formulas are correct, but if you create a formula with code that creates a file, on the first run the file will be created on the .rit folder. Subsequent runs creates on the user pwd

The formula has to create a file before its first build

I fixed this bug in this commit

@kaduartur kaduartur added ✔️ ready-for-review ready for review and removed waiting reply Waiting for an answer to a comment labels Mar 5, 2021
Comment on lines 179 to 180
fileCreted := filepath.Join(formulaPath, "test.txt")
assert.FileExists(t, fileCreted)
Copy link
Contributor

Choose a reason for hiding this comment

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

  • fileCreated

@@ -153,86 +153,6 @@ func TestPreRun(t *testing.T) {
err: errors.New("invalid character 'e' looking for beginning of value"),
},
},
{
name: "create work dir error",
Copy link
Contributor

Choose a reason for hiding this comment

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

code deletion ❤️

@henriquemoraeszup
Copy link
Contributor

/merge qa

@ritchie-bot
Copy link
Contributor

ritchie-bot bot commented Mar 5, 2021

🔥 Merge Conflict

@henriquemoraeszup
Copy link
Contributor

/merge qa

@ritchie-bot
Copy link
Contributor

ritchie-bot bot commented Mar 5, 2021

👌 Merged branch performance/remove_tmp_dir into qa

Signed-off-by: Kadu Artur Prussek <[email protected]>
brunasilvazup
brunasilvazup previously approved these changes Mar 8, 2021
@henriquemoraeszup
Copy link
Contributor

The implementation is breaking on Windows, just create a formula and run to see

Signed-off-by: Kadu Artur Prussek <[email protected]>
Signed-off-by: Kadu Artur Prussek <[email protected]>
@codecov-io
Copy link

Codecov Report

Merging #875 (f187be9) into master (dd9f47e) will decrease coverage by 0.67%.
The diff coverage is 54.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #875      +/-   ##
==========================================
- Coverage   85.31%   84.64%   -0.68%     
==========================================
  Files         113      112       -1     
  Lines        4039     4018      -21     
==========================================
- Hits         3446     3401      -45     
- Misses        413      433      +20     
- Partials      180      184       +4     
Impacted Files Coverage Δ
pkg/formula/formula.go 71.42% <ø> (-3.58%) ⬇️
pkg/formula/runner/local/pre_run.go 92.15% <ø> (-1.60%) ⬇️
pkg/formula/runner/local/runner.go 61.66% <25.00%> (-29.64%) ⬇️
pkg/formula/builder/make.go 84.61% <50.00%> (-15.39%) ⬇️
pkg/formula/runner/docker/runner.go 71.62% <60.00%> (-5.88%) ⬇️
pkg/formula/runner/docker/pre_run.go 84.00% <80.00%> (-2.05%) ⬇️
pkg/commands/builder.go 90.35% <100.00%> (-0.05%) ⬇️
pkg/formula/builder/shell.go 100.00% <100.00%> (ø)
pkg/slice/sliceutil/slice_util.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dd9f47e...f187be9. Read the comment docs.

@henriquemoraeszup
Copy link
Contributor

/merge qa

@ritchie-bot
Copy link
Contributor

ritchie-bot bot commented Mar 10, 2021

👌 Merged branch performance/remove_tmp_dir into qa

@henriquemoraeszup henriquemoraeszup merged commit 0ca725c into ZupIT:master Mar 10, 2021
kaduartur added a commit that referenced this pull request Mar 15, 2021
kaduartur added a commit that referenced this pull request Mar 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 improvement Improvement in features ✔️ ready-for-review ready for review 🐎 Performance Indicate that an issue or PR is from the performance context
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the necessity to copy formulas to tmp dir
6 participants