-
-
Notifications
You must be signed in to change notification settings - Fork 408
[breaking] Allow setting extra paths for build-cache #2612
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8b364d8
Small refactoring of compileCore function
cmaglie 8687f9d
Added possibility to set extra build-cache dirs for cores
cmaglie 1b6d3ed
[breaking] --build-cache-path now saves under 'cores' subdir instead …
cmaglie 8acaade
Added integration tests
cmaglie 264f5b4
Updated docs and fixed semantics of GetBuildCacheExtraPaths method
cmaglie d10c92c
Updated json-schema for configuration
cmaglie 686e75e
Update rpc/cc/arduino/cli/commands/v1/compile.proto
cmaglie 8797c63
Start integration test from a clean state
cmaglie 94b1983
Do not force build-cache path creation if not needed
cmaglie 8bdda04
Update internal/cli/configuration/build_cache.go
cmaglie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
internal/integrationtest/compile_4/core_caching_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
// This file is part of arduino-cli. | ||
// | ||
// Copyright 2023 ARDUINO SA (http://www.arduino.cc/) | ||
// | ||
// This software is released under the GNU General Public License version 3, | ||
// which covers the main part of arduino-cli. | ||
// The terms of this license can be found at: | ||
// https://www.gnu.org/licenses/gpl-3.0.en.html | ||
// | ||
// You can be released from the requirements of the above licenses by purchasing | ||
// a commercial license. Buying such a license is mandatory if you want to | ||
// modify or otherwise use the software for commercial activities involving the | ||
// Arduino software without disclosing the source code of your own applications. | ||
// To purchase a commercial license, send an email to [email protected]. | ||
|
||
package compile_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/arduino/arduino-cli/internal/integrationtest" | ||
"github.com/arduino/go-paths-helper" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestBuildCacheCoreWithExtraDirs(t *testing.T) { | ||
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) | ||
t.Cleanup(env.CleanUp) | ||
|
||
// Install Arduino AVR Boards | ||
_, _, err := cli.Run("core", "install", "arduino:[email protected]") | ||
require.NoError(t, err) | ||
|
||
// Main core cache | ||
defaultCache := paths.TempDir().Join("arduino") | ||
cache1, err := paths.MkTempDir("", "core_cache") | ||
require.NoError(t, err) | ||
t.Cleanup(func() { cache1.RemoveAll() }) | ||
cache2, err := paths.MkTempDir("", "extra_core_cache") | ||
require.NoError(t, err) | ||
t.Cleanup(func() { cache2.RemoveAll() }) | ||
|
||
sketch, err := paths.New("testdata", "BareMinimum").Abs() | ||
require.NoError(t, err) | ||
|
||
{ | ||
// Clean cache | ||
require.NoError(t, defaultCache.RemoveAll()) | ||
|
||
// Compile sketch with empty cache | ||
out, _, err := cli.Run("compile", "-v", "-b", "arduino:avr:uno", sketch.String()) | ||
require.NoError(t, err) | ||
require.Contains(t, string(out), "Archiving built core (caching) in: "+defaultCache.String()) | ||
|
||
// Check that the core cache is re-used | ||
out, _, err = cli.Run("compile", "-v", "-b", "arduino:avr:uno", sketch.String()) | ||
require.NoError(t, err) | ||
require.Contains(t, string(out), "Using precompiled core: "+defaultCache.String()) | ||
} | ||
|
||
{ | ||
env := cli.GetDefaultEnv() | ||
env["ARDUINO_BUILD_CACHE_PATH"] = cache1.String() | ||
|
||
// Compile sketch with empty cache user-defined core cache | ||
out, _, err := cli.RunWithCustomEnv(env, "compile", "-v", "-b", "arduino:avr:uno", sketch.String()) | ||
require.NoError(t, err) | ||
require.Contains(t, string(out), "Archiving built core (caching) in: "+cache1.String()) | ||
|
||
// Check that the core cache is re-used with user-defined core cache | ||
out, _, err = cli.RunWithCustomEnv(env, "compile", "-v", "-b", "arduino:avr:uno", sketch.String()) | ||
require.NoError(t, err) | ||
require.Contains(t, string(out), "Using precompiled core: "+cache1.String()) | ||
|
||
// Clean run should rebuild and save in user-defined core cache | ||
out, _, err = cli.RunWithCustomEnv(env, "compile", "-v", "-b", "arduino:avr:uno", "--clean", sketch.String()) | ||
require.NoError(t, err) | ||
require.Contains(t, string(out), "Archiving built core (caching) in: "+cache1.String()) | ||
} | ||
|
||
{ | ||
env := cli.GetDefaultEnv() | ||
env["ARDUINO_BUILD_CACHE_EXTRA_PATHS"] = cache1.String() | ||
|
||
// Both extra and default cache are full, should use the default one | ||
out, _, err := cli.RunWithCustomEnv(env, "compile", "-v", "-b", "arduino:avr:uno", sketch.String()) | ||
require.NoError(t, err) | ||
require.Contains(t, string(out), "Using precompiled core: "+defaultCache.String()) | ||
|
||
// Clean run, should rebuild and save in default cache | ||
out, _, err = cli.RunWithCustomEnv(env, "compile", "-v", "-b", "arduino:avr:uno", "--clean", sketch.String()) | ||
require.NoError(t, err) | ||
require.Contains(t, string(out), "Archiving built core (caching) in: "+defaultCache.String()) | ||
|
||
// Clean default cache | ||
require.NoError(t, defaultCache.RemoveAll()) | ||
|
||
// Now, extra is full and default is empty, should use extra | ||
out, _, err = cli.RunWithCustomEnv(env, "compile", "-v", "-b", "arduino:avr:uno", sketch.String()) | ||
require.NoError(t, err) | ||
require.Contains(t, string(out), "Using precompiled core: "+cache1.String()) | ||
} | ||
|
||
{ | ||
env := cli.GetDefaultEnv() | ||
env["ARDUINO_BUILD_CACHE_EXTRA_PATHS"] = cache1.String() // Populated | ||
env["ARDUINO_BUILD_CACHE_PATH"] = cache2.String() // Empty | ||
|
||
// Extra cache is full, should use the cache1 (extra) | ||
out, _, err := cli.RunWithCustomEnv(env, "compile", "-v", "-b", "arduino:avr:uno", sketch.String()) | ||
require.NoError(t, err) | ||
require.Contains(t, string(out), "Using precompiled core: "+cache1.String()) | ||
|
||
// Clean run, should rebuild and save in cache2 (user defined default cache) | ||
out, _, err = cli.RunWithCustomEnv(env, "compile", "-v", "-b", "arduino:avr:uno", "--clean", sketch.String()) | ||
require.NoError(t, err) | ||
require.Contains(t, string(out), "Archiving built core (caching) in: "+cache2.String()) | ||
|
||
// Both caches are full, should use the cache2 (user defined default) | ||
out, _, err = cli.RunWithCustomEnv(env, "compile", "-v", "-b", "arduino:avr:uno", sketch.String()) | ||
require.NoError(t, err) | ||
require.Contains(t, string(out), "Using precompiled core: "+cache2.String()) | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
internal/integrationtest/compile_4/testdata/BareMinimum/BareMinimum.ino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
void setup() {} | ||
void loop() {} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.