From a53fe52f0930e572fb41fa70980958e31b2a87e8 Mon Sep 17 00:00:00 2001 From: joneshf Date: Tue, 24 Jul 2018 23:07:03 -0700 Subject: [PATCH 01/20] Add a Makefile We can make things easier on contributors if we setup a build system. We can also make CI easier if we use Make. --- .gitignore | 2 ++ Makefile | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index a7b9ebe..216ecdf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ ### Project specific ### *.cabal +.make +bin # Created by https://www.gitignore.io/api/vim,osx,linux,macos,emacs,windows,haskell,visualstudiocode diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0012009 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +BIN := bin +EMPTY := .make +GHCID := $(BIN)/ghcid +STACK := stack +STACK_WORK := .stack-work + +.DEFAULT_GOAL := build + +$(EMPTY): + mkdir $@ + +$(EMPTY)/stack-setup: | $(EMPTY) + $(STACK) setup + touch $@ + +$(GHCID): $(EMPTY)/stack-setup + $(STACK) install ghcid --local-bin-path $(BIN) + +.PHONY: build +build: $(EMPTY)/stack-setup + $(STACK) build --no-run-tests --test + +.PHONY: clean +clean: + rm -f $(BIN)/* + rm -f $(EMPTY)/* + rm -fr $(STACK_WORK) + +.PHONY: test +test: build + $(STACK) test + +.PHONY: watch +watch: $(GHCID) + $(GHCID) From b078be7bc5e105aef0a6eed82c218033bc3c8683 Mon Sep 17 00:00:00 2001 From: joneshf Date: Tue, 24 Jul 2018 23:23:36 -0700 Subject: [PATCH 02/20] Simplify CI We don't really need to have separate caches. We fallback to the stack-root cache as it should have built most stuff. We can remove it in a future commit. It will have cached under the new key. We also can call one command, and let Make figure everything out. --- .circleci/config.yml | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8c4ff6c..0f44288 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,38 +1,25 @@ version: 2 jobs: - build: + test: docker: - image: haskell:8.2.2 steps: - checkout - restore_cache: keys: + - v1-stack-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} + - v1-stack-{{ checksum "package.yaml" }}- + - v1-stack- - v1-stack-root-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} - v1-stack-root-{{ checksum "package.yaml" }}- - v1-stack-root- - name: Restoring stack root cache - - restore_cache: - keys: - - v1-stack-work-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} - - v1-stack-work-{{ checksum "package.yaml" }}- - - v1-stack-work- - name: Restoring stack work cache - - run: - name: Setup - command: stack setup - - run: - name: Build - command: stack build --no-run-tests --test + name: Restoring stack cache - run: name: Test - command: stack test + command: make test - save_cache: - key: v1-stack-root-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} - name: Caching stack root - paths: - - /root/.stack - - save_cache: - key: v1-stack-work-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} - name: Caching stack work + key: v1-stack-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} + name: Caching stack paths: - .stack-work + - /root/.stack From 103a65fbf9cbef65d7987c9c5952e90e7c3eb11c Mon Sep 17 00:00:00 2001 From: joneshf Date: Tue, 24 Jul 2018 23:39:50 -0700 Subject: [PATCH 03/20] Add a workflow Since we renamed the single job from `build` to `test`, we have to be explicit about what is supposed to happen. --- .circleci/config.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0f44288..37ceeae 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,3 +23,8 @@ jobs: paths: - .stack-work - /root/.stack +workflows: + version: 2 + base: + jobs: + - test From e1dfee67454de6bbd5eeb156c0224780067c9785 Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 09:08:44 -0700 Subject: [PATCH 04/20] Remove old cache keys We simplified the cache. These keys can go away now. --- .circleci/config.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 37ceeae..d78feee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,9 +10,6 @@ jobs: - v1-stack-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} - v1-stack-{{ checksum "package.yaml" }}- - v1-stack- - - v1-stack-root-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} - - v1-stack-root-{{ checksum "package.yaml" }}- - - v1-stack-root- name: Restoring stack cache - run: name: Test From d5d6d737698c331ac37b88f4e24361de7fbf1b6b Mon Sep 17 00:00:00 2001 From: joneshf Date: Fri, 27 Jul 2018 05:03:47 -0700 Subject: [PATCH 05/20] Add rules for uploading to hackage While it would be really nice to run this from CI, The only way to upload a package involves using account-wide credentials. We can either use a username/password, or an API token. Both of these credentials have the same privileges, and that's too much power to give to CI. For now, we run this from the local machine. Maybe we can think of another way that's a bit safer. --- .circleci/config.yml | 11 +++++++++++ Makefile | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d78feee..38111f6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,14 @@ version: 2 jobs: + sdist: + docker: + - image: haskell:8.2.2 + steps: + - checkout + - run: + name: Build sdist + command: make sdist + test: docker: - image: haskell:8.2.2 @@ -20,8 +29,10 @@ jobs: paths: - .stack-work - /root/.stack + workflows: version: 2 base: jobs: + - sdist - test diff --git a/Makefile b/Makefile index 0012009..735722d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,9 @@ +PROJECT_NAME := rollbar-hs + BIN := bin +CABAL := cabal +CABAL_FILE := $(PROJECT_NAME).cabal +DIST := dist EMPTY := .make GHCID := $(BIN)/ghcid STACK := stack @@ -6,30 +11,55 @@ STACK_WORK := .stack-work .DEFAULT_GOAL := build +$(BIN): + mkdir -p $@ + +$(DIST): + mkdir -p $@ + $(EMPTY): - mkdir $@ + mkdir -p $@ $(EMPTY)/stack-setup: | $(EMPTY) $(STACK) setup touch $@ -$(GHCID): $(EMPTY)/stack-setup +$(GHCID): $(EMPTY)/stack-setup | $(BIN) $(STACK) install ghcid --local-bin-path $(BIN) +$(CABAL_FILE): + # `stack` has no way to run `hpack` directly. + # We can run `hpack` indirectly with little overhead. + $(STACK) build --dry-run + .PHONY: build build: $(EMPTY)/stack-setup $(STACK) build --no-run-tests --test +.PHONY: cabal-check +cabal-check: $(CABAL_FILE) + $(CABAL) check + .PHONY: clean clean: - rm -f $(BIN)/* - rm -f $(EMPTY)/* + rm -f $(CABAL_FILE) + rm -fr $(BIN) + rm -fr $(DIST) + rm -fr $(EMPTY) rm -fr $(STACK_WORK) +.PHONY: sdist +sdist: cabal-check | $(DIST) + $(CABAL) sdist + .PHONY: test test: build $(STACK) test +.PHONY: upload-hackage +upload-hackage: sdist + @ $(CABAL) upload $(DIST)/$(PROJECT_NAME)-*.tar.gz + .PHONY: watch watch: $(GHCID) $(GHCID) From d5b10959b15746c87294ba4d41a367a69d6c1881 Mon Sep 17 00:00:00 2001 From: joneshf Date: Fri, 27 Jul 2018 05:06:41 -0700 Subject: [PATCH 06/20] Fix cabal check error --- package.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/package.yaml b/package.yaml index 84a0bd7..fdb69bd 100644 --- a/package.yaml +++ b/package.yaml @@ -1,6 +1,7 @@ author: Hardy Jones category: Web copyright: 2018 Hardy Jones +description: Core Rollbar data types and APIs. extra-source-files: - README.md github: joneshf/rollbar-hs From 73e6221fb6846b2b696516d8321704adb653e834 Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 09:22:00 -0700 Subject: [PATCH 07/20] Use the cache to circumvent building Since we use `stack` to run `hpack` to generate the cabal file, we need `stack` to have its cache all setup properly. We could eschew `hpack` to relax this requirement... --- .circleci/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 38111f6..cfc1c3f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,6 +5,12 @@ jobs: - image: haskell:8.2.2 steps: - checkout + - restore_cache: + keys: + - v1-stack-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} + - v1-stack-{{ checksum "package.yaml" }}- + - v1-stack- + name: Restoring stack cache - run: name: Build sdist command: make sdist From 1abae7fc5f43a89d7623e04c4116a19bea7d110d Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 10:10:11 -0700 Subject: [PATCH 08/20] Cleanup `Makefile` Makes most variables able to be overridden. Simpleifies some rules. Quiets most of the output. --- Makefile | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 735722d..79dc7fb 100644 --- a/Makefile +++ b/Makefile @@ -1,40 +1,36 @@ -PROJECT_NAME := rollbar-hs +BIN ?= bin +CABAL ?= cabal +DIST ?= dist +EMPTY ?= .make +PROJECT_NAME ?= rollbar-hs +STACK ?= stack +STACK_WORK ?= .stack-work +VERBOSITY ?= warn -BIN := bin -CABAL := cabal CABAL_FILE := $(PROJECT_NAME).cabal -DIST := dist -EMPTY := .make GHCID := $(BIN)/ghcid -STACK := stack -STACK_WORK := .stack-work +STACK_FLAGS := --verbosity $(VERBOSITY) .DEFAULT_GOAL := build -$(BIN): - mkdir -p $@ - -$(DIST): - mkdir -p $@ - -$(EMPTY): +$(BIN) $(DIST) $(EMPTY): mkdir -p $@ $(EMPTY)/stack-setup: | $(EMPTY) - $(STACK) setup + $(STACK) $(STACK_FLAGS) setup touch $@ $(GHCID): $(EMPTY)/stack-setup | $(BIN) - $(STACK) install ghcid --local-bin-path $(BIN) + $(STACK) $(STACK_FLAGS) install ghcid --local-bin-path $(BIN) -$(CABAL_FILE): +$(CABAL_FILE): package.yaml # `stack` has no way to run `hpack` directly. # We can run `hpack` indirectly with little overhead. - $(STACK) build --dry-run + $(STACK) $(STACK_FLAGS) build --dry-run .PHONY: build build: $(EMPTY)/stack-setup - $(STACK) build --no-run-tests --test + $(STACK) $(STACK_FLAGS) build --no-run-tests --test .PHONY: cabal-check cabal-check: $(CABAL_FILE) @@ -54,7 +50,7 @@ sdist: cabal-check | $(DIST) .PHONY: test test: build - $(STACK) test + $(STACK) $(STACK_FLAGS) test .PHONY: upload-hackage upload-hackage: sdist From 3b0f694ff3eb00f8e3ff8a6014f0944483666189 Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 10:12:43 -0700 Subject: [PATCH 09/20] Really fix the cabal check I had an older version of `cabal`. It didn't check that the `description` was longer than the `synopsis`. The `cabal` on CI is newer. It would be nice if everything used the same programs. Might look into using a specific `docker` image or `nix` for this. --- package.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.yaml b/package.yaml index fdb69bd..a0ea4df 100644 --- a/package.yaml +++ b/package.yaml @@ -1,7 +1,9 @@ author: Hardy Jones category: Web copyright: 2018 Hardy Jones -description: Core Rollbar data types and APIs. +description: | + Provides a type-safe encoding of the Rollbar API. + Also provides functions to communicate with the Rollbar API. extra-source-files: - README.md github: joneshf/rollbar-hs From 5deb32b2c07c2e82f2289cae51e3ac6c763756cd Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 12:19:06 -0700 Subject: [PATCH 10/20] Separate the compile stage from testing Might be overkill for this small of a workflow. Good to get practice with circleci and Make. --- .circleci/config.yml | 44 +++++++++++++++++++++++++++++++------------- Makefile | 31 +++++++++++++++++++------------ 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cfc1c3f..aa2817e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,30 @@ version: 2 jobs: + compile: + docker: + - image: haskell:8.2.2 + steps: + - checkout + - restore_cache: + keys: + - v1-stack-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} + - v1-stack-{{ checksum "package.yaml" }}- + - v1-stack- + name: Restoring stack cache + - run: + name: Compile + command: make build + - presist_to_workspace: + root: dist + paths: + - '*' + - save_cache: + key: v1-stack-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} + name: Caching stack + paths: + - .stack-work + - /root/.stack + sdist: docker: - image: haskell:8.2.2 @@ -20,25 +45,18 @@ jobs: - image: haskell:8.2.2 steps: - checkout - - restore_cache: - keys: - - v1-stack-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} - - v1-stack-{{ checksum "package.yaml" }}- - - v1-stack- - name: Restoring stack cache + - attach_workspace: + at: dist - run: name: Test command: make test - - save_cache: - key: v1-stack-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} - name: Caching stack - paths: - - .stack-work - - /root/.stack workflows: version: 2 base: jobs: + - compile - sdist - - test + - test: + requires: + - compile diff --git a/Makefile b/Makefile index 79dc7fb..e8eb0b4 100644 --- a/Makefile +++ b/Makefile @@ -8,14 +8,31 @@ STACK_WORK ?= .stack-work VERBOSITY ?= warn CABAL_FILE := $(PROJECT_NAME).cabal +DOC_TEST := $(DIST)/build/doc-test/doc-test GHCID := $(BIN)/ghcid STACK_FLAGS := --verbosity $(VERBOSITY) -.DEFAULT_GOAL := build +.DEFAULT_GOAL := $(EMPTY)/build $(BIN) $(DIST) $(EMPTY): mkdir -p $@ +$(CABAL_FILE): package.yaml + # `stack` has no way to run `hpack` directly. + # We can run `hpack` indirectly with little overhead. + $(STACK) $(STACK_FLAGS) build --dry-run + +$(DOC_TEST): $(EMPTY)/build golden/**/*.json + $@ + +$(EMPTY)/build: $(EMPTY)/stack-setup README.md Setup.hs package.yaml stack.yaml src/**/*.hs test/**/*.hs | $(DIST) + $(STACK) $(STACK_FLAGS) build --no-run-tests --test + cp -R $$($(STACK) $(STACK_FLAGS) path --dist-dir)/build $(DIST)/build + touch $@ + +$(EMPTY)/doc-test: $(EMPTY)/build + touch $@ + $(EMPTY)/stack-setup: | $(EMPTY) $(STACK) $(STACK_FLAGS) setup touch $@ @@ -23,15 +40,6 @@ $(EMPTY)/stack-setup: | $(EMPTY) $(GHCID): $(EMPTY)/stack-setup | $(BIN) $(STACK) $(STACK_FLAGS) install ghcid --local-bin-path $(BIN) -$(CABAL_FILE): package.yaml - # `stack` has no way to run `hpack` directly. - # We can run `hpack` indirectly with little overhead. - $(STACK) $(STACK_FLAGS) build --dry-run - -.PHONY: build -build: $(EMPTY)/stack-setup - $(STACK) $(STACK_FLAGS) build --no-run-tests --test - .PHONY: cabal-check cabal-check: $(CABAL_FILE) $(CABAL) check @@ -49,8 +57,7 @@ sdist: cabal-check | $(DIST) $(CABAL) sdist .PHONY: test -test: build - $(STACK) $(STACK_FLAGS) test +test: $(DOC_TEST) .PHONY: upload-hackage upload-hackage: sdist From aeaf909528af6cba25b9f34c7878f2618cfe83fe Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 12:24:42 -0700 Subject: [PATCH 11/20] Typo --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index aa2817e..346a92d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,7 +14,7 @@ jobs: - run: name: Compile command: make build - - presist_to_workspace: + - persist_to_workspace: root: dist paths: - '*' From 2fca1f2892896fe97a9b2288779247b2096b453b Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 12:26:42 -0700 Subject: [PATCH 12/20] Add back build target Even though we changed the structure of the targets, we can still make it easier on everyone if we keep the build target. --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e8eb0b4..10bb979 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ DOC_TEST := $(DIST)/build/doc-test/doc-test GHCID := $(BIN)/ghcid STACK_FLAGS := --verbosity $(VERBOSITY) -.DEFAULT_GOAL := $(EMPTY)/build +.DEFAULT_GOAL := build $(BIN) $(DIST) $(EMPTY): mkdir -p $@ @@ -40,6 +40,9 @@ $(EMPTY)/stack-setup: | $(EMPTY) $(GHCID): $(EMPTY)/stack-setup | $(BIN) $(STACK) $(STACK_FLAGS) install ghcid --local-bin-path $(BIN) +.PHONT: build +build: $(EMPTY)/build + .PHONY: cabal-check cabal-check: $(CABAL_FILE) $(CABAL) check From c1a34f3b86e074c9595771ed13ff4eace1af01c4 Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 12:32:17 -0700 Subject: [PATCH 13/20] Persist the make cache If we don't do this, the test job will try to rebuild everything. That defeats the purpose. Probably, we've got our Make dependencies/targets setup improprerly. --- .circleci/config.yml | 4 ++++ Makefile | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 346a92d..c0b66f6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,6 +14,10 @@ jobs: - run: name: Compile command: make build + - persist_to_workspace: + root: .make + paths: + - '*' - persist_to_workspace: root: dist paths: diff --git a/Makefile b/Makefile index 10bb979..ea3976d 100644 --- a/Makefile +++ b/Makefile @@ -30,9 +30,6 @@ $(EMPTY)/build: $(EMPTY)/stack-setup README.md Setup.hs package.yaml stack.yaml cp -R $$($(STACK) $(STACK_FLAGS) path --dist-dir)/build $(DIST)/build touch $@ -$(EMPTY)/doc-test: $(EMPTY)/build - touch $@ - $(EMPTY)/stack-setup: | $(EMPTY) $(STACK) $(STACK_FLAGS) setup touch $@ From b2703d5f2da79ac8c32784308a86ac4cc8f20cdb Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 12:39:26 -0700 Subject: [PATCH 14/20] Attach the make cache Doesn't matter if we're persisting it if we never re-attach it... --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index c0b66f6..9fa5b93 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -49,6 +49,8 @@ jobs: - image: haskell:8.2.2 steps: - checkout + - attach_workspace: + at: .make - attach_workspace: at: dist - run: From 19177f0fc5f660f73f34e8d543737155ba2c1c0c Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 12:50:11 -0700 Subject: [PATCH 15/20] Remove accidentally added dependency --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ea3976d..240be7b 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ $(CABAL_FILE): package.yaml # We can run `hpack` indirectly with little overhead. $(STACK) $(STACK_FLAGS) build --dry-run -$(DOC_TEST): $(EMPTY)/build golden/**/*.json +$(DOC_TEST): $(EMPTY)/build $@ $(EMPTY)/build: $(EMPTY)/stack-setup README.md Setup.hs package.yaml stack.yaml src/**/*.hs test/**/*.hs | $(DIST) From a317ba5fce4ba3318f5b76b9add24b06fe615514 Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 12:54:26 -0700 Subject: [PATCH 16/20] Try attaching from the wowrking directory It's unclear if this is the correct syntax. --- .circleci/config.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9fa5b93..ac75f53 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,13 +15,10 @@ jobs: name: Compile command: make build - persist_to_workspace: - root: .make + root: $CIRCLE_WORKING_DIRECTORY paths: - - '*' - - persist_to_workspace: - root: dist - paths: - - '*' + - .make + - dist - save_cache: key: v1-stack-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} name: Caching stack @@ -50,9 +47,7 @@ jobs: steps: - checkout - attach_workspace: - at: .make - - attach_workspace: - at: dist + at: $CIRCLE_WORKING_DIRECTORY - run: name: Test command: make test From c61934d560e82954cac018a2d15b593285016fe6 Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 12:57:56 -0700 Subject: [PATCH 17/20] Try using `.` Looks like environment variables aren't evaluated. Maybe there's another way to do it? --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ac75f53..e38f9ae 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,7 +15,7 @@ jobs: name: Compile command: make build - persist_to_workspace: - root: $CIRCLE_WORKING_DIRECTORY + root: . paths: - .make - dist @@ -47,7 +47,7 @@ jobs: steps: - checkout - attach_workspace: - at: $CIRCLE_WORKING_DIRECTORY + at: . - run: name: Test command: make test From b968bb53a49993dfd57c9c13d5b3ca1d49631648 Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 13:07:43 -0700 Subject: [PATCH 18/20] Split out test targets It looks like, when we switch jobs in CI the new checkout has newer timestamps than what's in the make cache. Rather than dealing with that anymore, we alter the targets. We can change `test` to ensure builds are up to date. Then we can leave the individual test targets to run whatever is there. In CI this means we can set the workflow to run the tests separately. --- .circleci/config.yml | 9 ++++----- Makefile | 13 +++++++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e38f9ae..617a11d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,6 @@ jobs: - persist_to_workspace: root: . paths: - - .make - dist - save_cache: key: v1-stack-{{ checksum "package.yaml" }}-{{ checksum "stack.yaml" }} @@ -41,7 +40,7 @@ jobs: name: Build sdist command: make sdist - test: + doc-test: docker: - image: haskell:8.2.2 steps: @@ -49,8 +48,8 @@ jobs: - attach_workspace: at: . - run: - name: Test - command: make test + name: Doc test + command: make test-doc-test workflows: version: 2 @@ -58,6 +57,6 @@ workflows: jobs: - compile - sdist - - test: + - doc-test: requires: - compile diff --git a/Makefile b/Makefile index 240be7b..f2ea6b6 100644 --- a/Makefile +++ b/Makefile @@ -22,12 +22,13 @@ $(CABAL_FILE): package.yaml # We can run `hpack` indirectly with little overhead. $(STACK) $(STACK_FLAGS) build --dry-run -$(DOC_TEST): $(EMPTY)/build - $@ +$(DOC_TEST): + rm -f $(EMPTY)/build + $(MAKE) $(EMPTY)/build $(EMPTY)/build: $(EMPTY)/stack-setup README.md Setup.hs package.yaml stack.yaml src/**/*.hs test/**/*.hs | $(DIST) $(STACK) $(STACK_FLAGS) build --no-run-tests --test - cp -R $$($(STACK) $(STACK_FLAGS) path --dist-dir)/build $(DIST)/build + cp -R $$($(STACK) $(STACK_FLAGS) path --dist-dir)/build $(DIST) touch $@ $(EMPTY)/stack-setup: | $(EMPTY) @@ -57,7 +58,11 @@ sdist: cabal-check | $(DIST) $(CABAL) sdist .PHONY: test -test: $(DOC_TEST) +test: $(EMPTY)/build test-doc-test + +.PHONY: test-doc-test +test-doc-test: $(DOC_TEST) + $< .PHONY: upload-hackage upload-hackage: sdist From eb811723914f57494b640ef26b8ec0398760ff8b Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 13:26:19 -0700 Subject: [PATCH 19/20] Add a command for GitHub status We want a check that the build succeeded on GitHub. Unfortunately, circleci doesn't give us a final result from a workflow. We hack around it by making one job that does nothing really. Hopefully they can provide a better interface for this in the future. --- .circleci/config.yml | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 617a11d..e2dc1d7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,6 +25,23 @@ jobs: - .stack-work - /root/.stack + doc-test: + docker: + - image: haskell:8.2.2 + steps: + - checkout + - attach_workspace: + at: . + - run: + name: Doc test + command: make test-doc-test + + for-github: + docker: + - image: alpine + steps: + - command: echo passed + sdist: docker: - image: haskell:8.2.2 @@ -40,22 +57,15 @@ jobs: name: Build sdist command: make sdist - doc-test: - docker: - - image: haskell:8.2.2 - steps: - - checkout - - attach_workspace: - at: . - - run: - name: Doc test - command: make test-doc-test - workflows: version: 2 base: jobs: - compile + - for-github: + requires: + - doc-test + - sdist - sdist - doc-test: requires: From 84612bc7f474190bb2485e4f15c0d344811062b1 Mon Sep 17 00:00:00 2001 From: joneshf Date: Sun, 29 Jul 2018 13:38:35 -0700 Subject: [PATCH 20/20] Fix step The validate command lies... --- .circleci/config.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e2dc1d7..389ff30 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,7 +40,9 @@ jobs: docker: - image: alpine steps: - - command: echo passed + - run: + name: Passed + command: echo passed sdist: docker: