Skip to content

Commit

Permalink
Enable lockfile by default and fix warning
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 545927412
Change-Id: I34e8531b8e396ccdfe0eecbee22cb68f76f969fc
  • Loading branch information
SalmaSamy authored and copybara-github committed Jul 6, 2023
1 parent 9836a80 commit 8ba6618
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public class BazelRepositoryModule extends BlazeModule {
private final AtomicBoolean ignoreDevDeps = new AtomicBoolean(false);
private CheckDirectDepsMode checkDirectDepsMode = CheckDirectDepsMode.WARNING;
private BazelCompatibilityMode bazelCompatibilityMode = BazelCompatibilityMode.ERROR;
private LockfileMode bazelLockfileMode = LockfileMode.OFF;
private LockfileMode bazelLockfileMode = LockfileMode.UPDATE;
private List<String> allowedYankedVersions = ImmutableList.of();
private SingleExtensionEvalFunction singleExtensionEvalFunction;
private final ExecutorService repoFetchingWorkerThreadPool =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@GenerateTypeAdapter
public abstract class LockFileModuleExtension implements Postable {

@SuppressWarnings("AutoValueImmutableFields")
@SuppressWarnings("mutable")
public abstract byte[] getBzlTransitiveDigest();

public abstract ImmutableMap<String, RepoSpec> getGeneratedRepoSpecs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ public Converter() {

@Option(
name = "lockfile_mode",
defaultValue = "off", // TODO(salmasamy) later will be changed to 'update'
converter = LockfileMode.Converter.class,
defaultValue = "update",
documentationCategory = OptionDocumentationCategory.BZLMOD,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
help =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected ImmutableList<Injected> extraPrecomputedValues() throws Exception {
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES, CheckDirectDepsMode.WARNING),
PrecomputedValue.injected(
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE, BazelCompatibilityMode.ERROR),
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.OFF),
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE),
PrecomputedValue.injected(YankedVersionsUtil.ALLOWED_YANKED_VERSIONS, ImmutableList.of()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected ImmutableList<Injected> extraPrecomputedValues() {
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES, CheckDirectDepsMode.WARNING),
PrecomputedValue.injected(
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE, BazelCompatibilityMode.ERROR),
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.OFF));
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ protected void useRuleClassProvider(ConfiguredRuleClassProvider ruleClassProvide
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE,
BazelCompatibilityMode.ERROR),
PrecomputedValue.injected(
BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.OFF)))
BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE)))
.build(ruleClassProvider, fileSystem);
useConfiguration();
skyframeExecutor = createSkyframeExecutor(pkgFactory);
Expand Down Expand Up @@ -304,7 +304,7 @@ private void reinitializeSkyframeExecutor() {
PrecomputedValue.injected(
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE,
BazelCompatibilityMode.WARNING),
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.OFF)));
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE)));
}

/** Resets the SkyframeExecutor, as if a clean had been executed. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,14 @@ public void setup() throws Exception {
PrecomputedValue.STARLARK_SEMANTICS.set(
differencer,
StarlarkSemantics.builder().setBool(BuildLanguageOptions.ENABLE_BZLMOD, true).build());
BazelLockFileFunction.LOCKFILE_MODE.set(differencer, LockfileMode.UPDATE);
ModuleFileFunction.IGNORE_DEV_DEPS.set(differencer, false);
ModuleFileFunction.REGISTRIES.set(differencer, ImmutableList.of());
ModuleFileFunction.MODULE_OVERRIDES.set(differencer, ImmutableMap.of());
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES.set(
differencer, CheckDirectDepsMode.OFF);
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE.set(
differencer, BazelCompatibilityMode.ERROR);
BazelLockFileFunction.LOCKFILE_MODE.set(differencer, LockfileMode.OFF);
BazelLockFileFunction.LOCKFILE_MODE.set(differencer, LockfileMode.UPDATE);
YankedVersionsUtil.ALLOWED_YANKED_VERSIONS.set(differencer, ImmutableList.of());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public SkyValue compute(SkyKey skyKey, Environment env)
differencer, BazelCompatibilityMode.ERROR);
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES.set(
differencer, CheckDirectDepsMode.ERROR);
BazelLockFileFunction.LOCKFILE_MODE.set(differencer, LockfileMode.OFF);
BazelLockFileFunction.LOCKFILE_MODE.set(differencer, LockfileMode.UPDATE);
RepositoryDelegatorFunction.REPOSITORY_OVERRIDES.set(differencer, ImmutableMap.of());
RepositoryDelegatorFunction.DEPENDENCY_FOR_UNCONDITIONAL_FETCHING.set(
differencer, RepositoryDelegatorFunction.DONT_FETCH_UNCONDITIONALLY);
Expand Down Expand Up @@ -285,10 +285,9 @@ public void moduleWithFlags() throws Exception {
ModuleFileFunction.MODULE_OVERRIDES.set(differencer, ImmutableMap.of("my_dep_1", override));
YankedVersionsUtil.ALLOWED_YANKED_VERSIONS.set(differencer, yankedVersions);
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES.set(
differencer, CheckDirectDepsMode.ERROR);
differencer, CheckDirectDepsMode.WARNING);
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE.set(
differencer, BazelCompatibilityMode.ERROR);
BazelLockFileFunction.LOCKFILE_MODE.set(differencer, LockfileMode.OFF);
differencer, BazelCompatibilityMode.WARNING);

UpdateLockFileKey key =
UpdateLockFileKey.create("moduleHash", depGraph, rootValue.getOverrides());
Expand All @@ -310,9 +309,9 @@ public void moduleWithFlags() throws Exception {
assertThat(value.getFlags().cmdModuleOverrides()).isEqualTo(moduleOverride);
assertThat(value.getFlags().allowedYankedVersions()).isEqualTo(yankedVersions);
assertThat(value.getFlags().directDependenciesMode())
.isEqualTo(CheckDirectDepsMode.ERROR.toString());
.isEqualTo(CheckDirectDepsMode.WARNING.toString());
assertThat(value.getFlags().compatibilityMode())
.isEqualTo(BazelCompatibilityMode.ERROR.toString());
.isEqualTo(BazelCompatibilityMode.WARNING.toString());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void setup() throws Exception {
differencer, CheckDirectDepsMode.OFF);
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE.set(
differencer, BazelCompatibilityMode.ERROR);
BazelLockFileFunction.LOCKFILE_MODE.set(differencer, LockfileMode.OFF);
BazelLockFileFunction.LOCKFILE_MODE.set(differencer, LockfileMode.UPDATE);
YankedVersionsUtil.ALLOWED_YANKED_VERSIONS.set(differencer, ImmutableList.of());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void setup() throws Exception {
differencer, CheckDirectDepsMode.WARNING);
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE.set(
differencer, BazelCompatibilityMode.ERROR);
BazelLockFileFunction.LOCKFILE_MODE.set(differencer, LockfileMode.OFF);
BazelLockFileFunction.LOCKFILE_MODE.set(differencer, LockfileMode.UPDATE);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ protected SkyframeExecutor createSkyframeExecutor(ConfiguredRuleClassProvider ru
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE,
BazelCompatibilityMode.ERROR),
PrecomputedValue.injected(
BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.OFF)))
BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE)))
.build(ruleClassProvider, fileSystem);
SkyframeExecutor skyframeExecutor =
BazelSkyframeExecutorConstants.newBazelSkyframeExecutorBuilder()
Expand Down Expand Up @@ -422,7 +422,8 @@ protected SkyframeExecutor createSkyframeExecutor(ConfiguredRuleClassProvider ru
PrecomputedValue.injected(
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE,
BazelCompatibilityMode.ERROR))
.add(PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.OFF))
.add(
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE))
.build());
SkyframeExecutorTestHelper.process(skyframeExecutor);
return skyframeExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected ImmutableList<Injected> extraPrecomputedValues() {
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES, CheckDirectDepsMode.WARNING),
PrecomputedValue.injected(
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE, BazelCompatibilityMode.ERROR),
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.OFF));
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE));
}

private void writeRulesBzl(String type) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ public void setupDelegator() throws Exception {
SkyFunctions.MODULE_FILE,
new ModuleFileFunction(registryFactory, rootPath, ImmutableMap.of()))
.put(SkyFunctions.BAZEL_DEP_GRAPH, new BazelDepGraphFunction())
.put(SkyFunctions.BAZEL_LOCK_FILE, new BazelLockFileFunction(rootDirectory))
.put(SkyFunctions.BAZEL_MODULE_RESOLUTION, new BazelModuleResolutionFunction())
.put(
BzlmodRepoRuleValue.BZLMOD_REPO_RULE,
Expand Down Expand Up @@ -279,7 +280,7 @@ public void setupDelegator() throws Exception {
differencer, CheckDirectDepsMode.WARNING);
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE.set(
differencer, BazelCompatibilityMode.ERROR);
BazelLockFileFunction.LOCKFILE_MODE.set(differencer, LockfileMode.OFF);
BazelLockFileFunction.LOCKFILE_MODE.set(differencer, LockfileMode.UPDATE);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected ImmutableList<Injected> extraPrecomputedValues() {
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES, CheckDirectDepsMode.WARNING),
PrecomputedValue.injected(
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE, BazelCompatibilityMode.ERROR),
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.OFF));
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE));
}

private static ModuleInfo protoFromBinaryFileWriteAction(Action action) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected ImmutableList<Injected> extraPrecomputedValues() {
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES, CheckDirectDepsMode.WARNING),
PrecomputedValue.injected(
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE, BazelCompatibilityMode.ERROR),
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.OFF));
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE));
}

@Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ protected ImmutableList<Injected> extraPrecomputedValues() {
PrecomputedValue.injected(YankedVersionsUtil.ALLOWED_YANKED_VERSIONS, ImmutableList.of()),
PrecomputedValue.injected(
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE, BazelCompatibilityMode.ERROR),
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.OFF));
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE));
}

// Helpers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected ImmutableList<PrecomputedValue.Injected> extraPrecomputedValues() thro
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES, CheckDirectDepsMode.WARNING),
PrecomputedValue.injected(
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE, BazelCompatibilityMode.ERROR),
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.OFF));
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ protected ImmutableList<Injected> extraPrecomputedValues() {
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES, CheckDirectDepsMode.WARNING),
PrecomputedValue.injected(
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE, BazelCompatibilityMode.ERROR),
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.OFF));
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected ImmutableList<Injected> extraPrecomputedValues() {
BazelModuleResolutionFunction.CHECK_DIRECT_DEPENDENCIES, CheckDirectDepsMode.WARNING),
PrecomputedValue.injected(
BazelModuleResolutionFunction.BAZEL_COMPATIBILITY_MODE, BazelCompatibilityMode.ERROR),
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.OFF));
PrecomputedValue.injected(BazelLockFileFunction.LOCKFILE_MODE, LockfileMode.UPDATE));
}

@Test
Expand Down

0 comments on commit 8ba6618

Please sign in to comment.