From 1ab38e297a9e2f636bcc22ee85d3359191e06deb Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Wed, 6 Nov 2019 16:20:14 -0800 Subject: [PATCH] Try a different approach for embedding the git commit sha --- .dockerignore | 1 + .gitignore | 1 + Dockerfile | 21 +++------------------ script/publish | 3 ++- src/Semantic/Version.hs | 24 +++++------------------- 5 files changed, 12 insertions(+), 38 deletions(-) diff --git a/.dockerignore b/.dockerignore index 619162c4f..bdb208923 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,6 @@ Dockerfile /.licenses +/.git .ghc.environment.x86_64-darwin-8.6.5 /bin diff --git a/.gitignore b/.gitignore index 0a5922aab..47833ee4c 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ dist-repl tmp/ /bin/ +/src/Semantic/Version.hs.bak /semanticd/test/current /semanticd/test/rover-example-config/semantic.log /test/fixtures/*/examples diff --git a/Dockerfile b/Dockerfile index b25450e77..8249fa34e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,26 +22,11 @@ ENTRYPOINT ["/protobuf/bin/protoc", "-I/protobuf", "--plugin=protoc-gen-haskell= FROM haskell:8.6 as build WORKDIR /build -# Build just the dependencies so that this layer can be cached -COPY semantic.cabal . -COPY semantic-analysis semantic-analysis/ -COPY semantic-core semantic-core/ -COPY semantic-java semantic-java/ -COPY semantic-json semantic-json/ -COPY semantic-python semantic-python/ -COPY semantic-source semantic-source/ -COPY semantic-tags semantic-tags/ -COPY semantic-ast semantic-ast/ -COPY cabal.project . -RUN cabal v2-update && \ - cabal v2-configure --flags="release" --ghc-options="-D$GIT_COMMIT" -COPY cabal.project.local . -RUN cabal v2-build --only-dependencies - - # Build all of semantic COPY . . -RUN cabal v2-build semantic:exe:semantic +RUN cabal v2-update && \ + cabal v2-configure --flags="release" && \ + cabal v2-build semantic:exe:semantic # A fake `install` target until we can get `cabal v2-install` to work RUN cp $(find dist-newstyle/build/x86_64-linux -name semantic -type f -perm -u=x) /usr/local/bin/semantic diff --git a/script/publish b/script/publish index bbb6a2590..9c6286062 100755 --- a/script/publish +++ b/script/publish @@ -11,7 +11,8 @@ BUILD_SHA=$(git rev-parse HEAD 2>/dev/null) DOCKER_IMAGE=docker.pkg.github.com/github/semantic/semantic # Build -docker build -t $DOCKER_IMAGE --build-arg BUILD_SHA=$BUILD_SHA. +sed -i .bak "s/buildSHA =.*/buildSHA = \"$BUILD_SHA\"/" src/Semantic/Version.hs +docker build -t $DOCKER_IMAGE . # Make sure semantic is in the image. docker run --rm $DOCKER_IMAGE --version diff --git a/src/Semantic/Version.hs b/src/Semantic/Version.hs index 3174453f4..3a05699f2 100644 --- a/src/Semantic/Version.hs +++ b/src/Semantic/Version.hs @@ -1,30 +1,16 @@ -{-# LANGUAGE CPP #-} -#ifdef COMPUTE_GIT_SHA -{-# OPTIONS_GHC -fforce-recomp #-} -- So that gitHash is correct. -{-# LANGUAGE TemplateHaskell #-} -#endif module Semantic.Version ( buildSHA , buildVersion ) where import Data.Version (showVersion) -#ifdef COMPUTE_GIT_SHA -import Development.GitRev -#endif import Paths_semantic (version) --- The SHA1 hash of this build of semantic. --- If compiled as a development build, this will be @@. -buildSHA :: String -#if defined(GIT_COMMIT) -buildSHA = "GIT_COMMIT" -#elif defined(COMPUTE_GIT_SHA) -buildSHA = $(gitHash) -#else -buildSHA = "unspecified" -#endif - -- The version string of this build of semantic. buildVersion :: String buildVersion = showVersion version + +-- The SHA1 hash of this build of semantic. +-- If compiled as a development build, this will be @@. +buildSHA :: String +buildSHA = ""