1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +03:00

Try a different approach for embedding the git commit sha

This commit is contained in:
Timothy Clem 2019-11-06 16:20:14 -08:00
parent f0956624a0
commit 1ab38e297a
5 changed files with 12 additions and 38 deletions

View File

@ -1,5 +1,6 @@
Dockerfile Dockerfile
/.licenses /.licenses
/.git
.ghc.environment.x86_64-darwin-8.6.5 .ghc.environment.x86_64-darwin-8.6.5
/bin /bin

1
.gitignore vendored
View File

@ -18,6 +18,7 @@ dist-repl
tmp/ tmp/
/bin/ /bin/
/src/Semantic/Version.hs.bak
/semanticd/test/current /semanticd/test/current
/semanticd/test/rover-example-config/semantic.log /semanticd/test/rover-example-config/semantic.log
/test/fixtures/*/examples /test/fixtures/*/examples

View File

@ -22,26 +22,11 @@ ENTRYPOINT ["/protobuf/bin/protoc", "-I/protobuf", "--plugin=protoc-gen-haskell=
FROM haskell:8.6 as build FROM haskell:8.6 as build
WORKDIR /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 # Build all of semantic
COPY . . 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 # 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 RUN cp $(find dist-newstyle/build/x86_64-linux -name semantic -type f -perm -u=x) /usr/local/bin/semantic

View File

@ -11,7 +11,8 @@ BUILD_SHA=$(git rev-parse HEAD 2>/dev/null)
DOCKER_IMAGE=docker.pkg.github.com/github/semantic/semantic DOCKER_IMAGE=docker.pkg.github.com/github/semantic/semantic
# Build # 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. # Make sure semantic is in the image.
docker run --rm $DOCKER_IMAGE --version docker run --rm $DOCKER_IMAGE --version

View File

@ -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 module Semantic.Version
( buildSHA ( buildSHA
, buildVersion , buildVersion
) where ) where
import Data.Version (showVersion) import Data.Version (showVersion)
#ifdef COMPUTE_GIT_SHA
import Development.GitRev
#endif
import Paths_semantic (version) import Paths_semantic (version)
-- The SHA1 hash of this build of semantic.
-- If compiled as a development build, this will be @<development>@.
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. -- The version string of this build of semantic.
buildVersion :: String buildVersion :: String
buildVersion = showVersion version buildVersion = showVersion version
-- The SHA1 hash of this build of semantic.
-- If compiled as a development build, this will be @<development>@.
buildSHA :: String
buildSHA = "<development>"