From 8944e35101d770416fefca2b2aee885642a9e491 Mon Sep 17 00:00:00 2001 From: Alex Couture-Beil Date: Mon, 21 Nov 2022 11:02:20 -0800 Subject: [PATCH] feature-flag EARTHLY_CI arg Signed-off-by: Alex Couture-Beil --- CHANGELOG.md | 2 +- features/features.go | 1 + tests/ci-arg.earth | 2 +- variables/builtin.go | 5 ++++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35a204faa42..58b2bb5f739 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ All notable changes to [Earthly](https://github.com/earthly/earthly) will be doc - Added support for a custom `.netrc` file path using the standard `NETRC` environmental variable. [#2426](https://github.com/earthly/earthly/pull/2426) - Ability to run multiple Earthly installations at a time via `EARTHLY_INSTALLATION_NAME` environment variable, or the `--installation-name` CLI flag. The installation name defaults to `earthly` if not specified. Different installations use different configurations, different buildkit Daemons, different cache volumes, and different ports. -- New `EARTHLY_CI` builtin arg, which is set to `true` when earthly is run with the `--ci` flag. [#2398](https://github.com/earthly/earthly/pull/2398) +- New `EARTHLY_CI` builtin arg, which is set to `true` when earthly is run with the `--ci` flag, this ARG must be enabled with the `VERSION --ci-arg` feature flag.. [#2398](https://github.com/earthly/earthly/pull/2398) ### Changed diff --git a/features/features.go b/features/features.go index fcc3fceb2b2..d7b5d6a2fed 100644 --- a/features/features.go +++ b/features/features.go @@ -43,6 +43,7 @@ type Features struct { WaitBlock bool `long:"wait-block" description:"enable WITH/END feature, also allows RUN --push mixed with non-push commands"` UseProjectSecrets bool `long:"use-project-secrets" description:"enable project-based secret resolution"` UsePipelines bool `long:"use-pipelines" description:"enable the PIPELINE and TRIGGER commands"` + EarthlyCIArg bool `long:"ci-arg" description:"include EARTHLY_CI arg"` NoUseRegistryForWithDocker bool `long:"no-use-registry-for-with-docker" description:"disable use-registry-for-with-docker"` diff --git a/tests/ci-arg.earth b/tests/ci-arg.earth index b41034c0534..43d8ea0e3f8 100644 --- a/tests/ci-arg.earth +++ b/tests/ci-arg.earth @@ -1,4 +1,4 @@ -VERSION 0.6 +VERSION --ci-arg 0.6 FROM alpine:3.15 ci-test: diff --git a/variables/builtin.go b/variables/builtin.go index fd42944d766..89f246577bf 100644 --- a/variables/builtin.go +++ b/variables/builtin.go @@ -25,7 +25,6 @@ type DefaultArgs struct { // BuiltinArgs returns a scope containing the builtin args. func BuiltinArgs(target domain.Target, platr *platutil.Resolver, gitMeta *gitutil.GitMetadata, defaultArgs DefaultArgs, ftrs *features.Features, push bool, ci bool) *Scope { ret := NewScope() - ret.AddInactive(arg.EarthlyCI, fmt.Sprintf("%t", ci)) ret.AddInactive(arg.EarthlyTarget, target.StringCanonical()) ret.AddInactive(arg.EarthlyTargetProject, target.ProjectCanonical()) targetNoTag := target @@ -48,6 +47,10 @@ func BuiltinArgs(target domain.Target, platr *platutil.Resolver, gitMeta *gituti ret.AddInactive(arg.EarthlyBuildSha, defaultArgs.EarthlyBuildSha) } + if ftrs.EarthlyCIArg { + ret.AddInactive(arg.EarthlyCI, fmt.Sprintf("%t", ci)) + } + if ftrs.EarthlyLocallyArg { SetLocally(ret, false) }