Skip to content

Commit

Permalink
chore: inject git commit hash
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Apr 2, 2024
1 parent f338b34 commit 0039e56
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/earthly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
version: 'v0.8.5'

- name: Build
run: earthly --ci +build
run: earthly --ci +build --GIT_COMMIT=${{ github.sha }}
env:
FORCE_COLOR: 1
46 changes: 33 additions & 13 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,21 @@ source:

DO rust+CARGO --args=fetch

COPY --dir +git-info/* /tmp/git/
ENV GIT_COMMIT=$(cat /tmp/git/commit_hash)
ENV GIT_DIRTY=$(cat /tmp/git/dirty)
RUN rm -rf /tmp/git

SAVE ARTIFACT --keep-ts ./*

build:
FROM +source
ARG GIT_COMMIT
IF [ -n "${GIT_COMMIT}" ]
ENV GIT_COMMIT=$GIT_COMMIT
ENV GIT_DIRTY="false"
ELSE
COPY --dir +git-info/* /tmp/git/
ENV GIT_COMMIT=$(cat /tmp/git/commit_hash)
ENV GIT_DIRTY=$(cat /tmp/git/dirty)
RUN rm -rf /tmp/git
END

DO rust+CARGO --args="build --offline --release" --output="release/nargo"
SAVE ARTIFACT ./target/release/nargo

Expand Down Expand Up @@ -155,12 +161,19 @@ yarn-source:
COPY --dir --keep-ts tooling/noir_codegen tooling/noir_js tooling/noir_js_backend_barretenberg tooling/noir_js_types ./tooling

yarn-build:
ARG GIT_COMMIT
FROM +yarn-source
COPY --dir --keep-ts +source/* .
COPY --dir +git-info/* /tmp/git/
ENV GIT_COMMIT=$(cat /tmp/git/commit_hash)
ENV GIT_DIRTY=$(cat /tmp/git/dirty)
RUN rm -rf /tmp/git

IF [ -n "${GIT_COMMIT}" ]
ENV GIT_COMMIT=$GIT_COMMIT
ENV GIT_DIRTY="false"
ELSE
COPY --dir +git-info/* /tmp/git/
ENV GIT_COMMIT=$(cat /tmp/git/commit_hash)
ENV GIT_DIRTY=$(cat /tmp/git/dirty)
RUN rm -rf /tmp/git
END

DO rust+SET_CACHE_MOUNTS_ENV
RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE \
Expand All @@ -182,13 +195,20 @@ yarn-test:
RUN yarn test

docs-build:
ARG GIT_COMMIT
FROM +yarn-source
COPY --dir --keep-ts +source/* .
COPY --dir +git-info/* /tmp/git/
ENV GIT_COMMIT=$(cat /tmp/git/commit_hash)
ENV GIT_DIRTY=$(cat /tmp/git/dirty)
RUN rm -rf /tmp/git
COPY ./docs ./docs

IF [ -n "${GIT_COMMIT}" ]
ENV GIT_COMMIT=$GIT_COMMIT
ENV GIT_DIRTY="false"
ELSE
COPY --dir +git-info/* /tmp/git/
ENV GIT_COMMIT=$(cat /tmp/git/commit_hash)
ENV GIT_DIRTY=$(cat /tmp/git/dirty)
RUN rm -rf /tmp/git
END

DO rust+SET_CACHE_MOUNTS_ENV
RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE \
Expand Down
2 changes: 0 additions & 2 deletions tooling/noirc_abi_wasm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ fn main() {
if std::env::var(GIT_COMMIT).is_err() {
build_data::set_GIT_COMMIT();
build_data::set_GIT_DIRTY();
build_data::no_debug_rebuilds();
}

build_data::set_SOURCE_TIMESTAMP();
build_data::no_debug_rebuilds();
}

0 comments on commit 0039e56

Please sign in to comment.