Skip to content

Commit

Permalink
Pin stackage dependencies
Browse files Browse the repository at this point in the history
This should address some of the caching issues we run into.

As mentioned in this GitHub issue:
tweag/rules_haskell#1293, there are issues
with `stack` running intermittently locally, and with caching not really
working on any of the CI systems we use. It looks like the
`stack_snapshot_json` argument should help with that.

After working with it for a little while, it looks like we consistently
get sub-second `bazel test //...` when it should be a no-op! This is the
behavior we wanted, and it's here!

We'll have to see how this plays out on CI.

We also add a rule in the `Makefile` to help with regenerating that
pinned file when we make changes.
  • Loading branch information
joneshf committed Nov 13, 2020
1 parent d268fa8 commit c072d6e
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 5 deletions.
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ VERSION_BAZEL := 2.2.0
VERSION_IBAZEL := 0.12.3

PACKAGE_JSON := package.json
STACKAGE_SNAPSHOT := snapshot.yaml
STACKAGE_SNAPSHOT_PINNED := stackage_snapshot.json
WORKSPACE := WORKSPACE.bazel

# Based on https://stackoverflow.com/a/12099167/1549047.
ifeq ($(OS),Windows_NT)
Expand Down Expand Up @@ -49,11 +52,15 @@ $(IBAZEL): | $(BUILDDIR)
@touch $@
$(IBAZEL) version

$(PACKAGE_JSON): $(BAZEL)
$(PACKAGE_JSON): $(BAZEL) $(STACKAGE_SNAPSHOT_PINNED)
$(info Generating $@ file)
$(BAZEL) build //ci/npm:package.json
cp $(BAZEL_BINDIR)/ci/npm/package.json $@

$(STACKAGE_SNAPSHOT_PINNED): $(BAZEL) $(STACKAGE_SNAPSHOT) $(WORKSPACE)
$(info Generating $@ file)
$(BAZEL) run @stackage-unpinned//:pin

.PHONY: clean
clean:
$(info Removing $(BUILDDIR))
Expand All @@ -63,7 +70,7 @@ clean:
@git clean -X --force $(BINDIR)/*

.PHONY: coverage
coverage: $(BAZEL)
coverage: $(BAZEL) $(STACKAGE_SNAPSHOT_PINNED)
$(BAZEL) coverage $(BAZEL_CONFIG) //...

.PHONY: format
Expand All @@ -76,18 +83,21 @@ format: $(BAZEL)
$(BAZEL) run $(BAZEL_CONFIG) //pkg/cst:format-ormolu

.PHONY: lint
lint: $(BAZEL)
lint: $(BAZEL) $(STACKAGE_SNAPSHOT_PINNED)
$(BAZEL) test $(BAZEL_CONFIG) //:lint

.PHONY: npm-publish
npm-publish: $(PACKAGE_JSON)
$(info Publishing to npm)
npm publish

.PHONY: pin-stackage
pin-stackage: $(STACKAGE_SNAPSHOT_PINNED)

.PHONY: test
test: $(BAZEL)
test: $(BAZEL) $(STACKAGE_SNAPSHOT_PINNED)
$(BAZEL) test $(BAZEL_CONFIG) //...

.PHONY: watch
watch: $(IBAZEL)
watch: $(IBAZEL) $(STACKAGE_SNAPSHOT_PINNED)
$(IBAZEL) test $(BAZEL_CONFIG) //...
1 change: 1 addition & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ stack_snapshot(
"semigroups",
"text",
],
stack_snapshot_json = "//:stackage_snapshot.json",
tools = [
"@alex",
"@happy",
Expand Down
Loading

0 comments on commit c072d6e

Please sign in to comment.