-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #281 from Bedrock-OSS/develop
Merge develop for 1.2.0 Update
- Loading branch information
Showing
125 changed files
with
1,379 additions
and
780 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -7,3 +7,4 @@ docs/scraper/__pycache__/ | |
docs/node_modules | ||
docs/docs/.vitepress/dist | ||
test/local_test.go | ||
test/test_results |
This file contains 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 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,23 @@ | ||
--- | ||
title: Experiments | ||
--- | ||
|
||
# Experiments | ||
|
||
Experiments are new experimental features of Regolith to be released in the future versions, once proven to be stable and useful. The experiments can be enabled with the `--experiments` flag. | ||
|
||
## Currently Available Experiments | ||
|
||
### `size_time_check` | ||
|
||
The `size_time_check` is an experiment that aims to speed up `regolith run` and `regolith watch` commands. It achieves this by checking the size and modification time of the files before moving them between working and output directories. If the source file is the same size and has the same modification time as the destination file, the target file will remain untouched (Regolith assumes that the files are the same). | ||
|
||
The `size_time_check` should greatly speed up the exports of large projects. | ||
|
||
The downside of this approach is that on the first run, the export will be slower, but on subsequent runs, the export will be much faster. This means that the `size_time_check` is not recommended for CI where Regolith is run only once. | ||
|
||
Usage: | ||
``` | ||
regolith run --experiments size_time_check | ||
regolith watch --experiments size_time_check | ||
``` |
This file contains 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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 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,60 @@ | ||
package regolith | ||
|
||
import ( | ||
"runtime" | ||
|
||
"github.com/Bedrock-OSS/go-burrito/burrito" | ||
"github.com/stirante/go-simple-eval/eval" | ||
"github.com/stirante/go-simple-eval/eval/utils" | ||
) | ||
|
||
// EvalCondition evaluates a condition expression with the given context. | ||
func EvalCondition(expression string, ctx RunContext) (bool, error) { | ||
Logger.Debugf("Evaluating condition: %s", expression) | ||
t := prepareScope(ctx) | ||
Logger.Debugf("Evaluation scope: %s", utils.ToString(t)) | ||
e, err := eval.Eval(expression, t) | ||
if err != nil { | ||
return false, burrito.WrapErrorf(err, "Failed to evaluate condition: %s", expression) | ||
} | ||
Logger.Debugf("Condition evaluated to: %s", utils.ToString(e)) | ||
return utils.ToBoolean(e), nil | ||
} | ||
|
||
// EvalString evaluates an expression with the given context and returns the | ||
// result as a string. | ||
func EvalString(expression string, ctx RunContext) (string, error) { | ||
Logger.Debugf("Evaluating expression: %s", expression) | ||
t := prepareScope(ctx) | ||
Logger.Debugf("Evaluation scope: %s", utils.ToString(t)) | ||
e, err := eval.Eval(expression, t) | ||
if err != nil { | ||
return "", burrito.WrapErrorf(err, "Failed to evaluate condition: %s", expression) | ||
} | ||
Logger.Debugf("Expression evaluated to: %s", utils.ToString(e)) | ||
if v, ok := e.(string); ok { | ||
return v, nil | ||
} | ||
return "", burrito.WrapErrorf(err, "Expression evaluated to non-string value: %s", expression) | ||
} | ||
|
||
func prepareScope(ctx RunContext) map[string]interface{} { | ||
semverString, err := utils.ParseSemverString(Version) | ||
if err != nil { | ||
semverString = utils.Semver{} | ||
} | ||
projectData := map[string]interface{}{ | ||
"name": ctx.Config.Name, | ||
"author": ctx.Config.Author, | ||
} | ||
return map[string]interface{}{ | ||
"os": runtime.GOOS, | ||
"arch": runtime.GOARCH, | ||
"debug": burrito.PrintStackTrace, | ||
"version": semverString, | ||
"profile": ctx.Profile, | ||
"filterLocation": ctx.AbsoluteLocation, | ||
"settings": ctx.Settings, | ||
"project": projectData, | ||
} | ||
} |
Oops, something went wrong.