Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/examples/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Please note that these examples, although similar, are distinct from the ones us

<!-- vale HouseStyle.Spelling = NO -->

- [c](https://github.com/earthbuild/earthbuild/tree/main/examples/c)
- [c](https://github.com/earthbuild/earthbuild/tree/main/examples/c) - also demonstrates running `valgrind` inside earthbuild, useful on macOS / Windows where valgrind isn't available natively.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The project name is Earthly, not 'earthbuild'. Using the correct name ensures consistency with the rest of the documentation.

Suggested change
- [c](https://github.com/earthbuild/earthbuild/tree/main/examples/c) - also demonstrates running `valgrind` inside earthbuild, useful on macOS / Windows where valgrind isn't available natively.
- [c](https://github.com/earthbuild/earthbuild/tree/main/examples/c) - also demonstrates running valgrind inside Earthly, useful on macOS / Windows where valgrind isn't available natively.

- [clojure](https://github.com/earthbuild/earthbuild/tree/main/examples/clojure)
- [cobol](https://github.com/earthbuild/earthbuild/tree/main/examples/cobol)
- [cpp](https://github.com/earthbuild/earthbuild/tree/main/examples/cpp)
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Please note that these examples, although similar, are distinct from the ones us
<!-- vale HouseStyle.Spelling = NO -->
- [clojure](./clojure)
- [cobol](./cobol)
- [c](./c)
- [c](./c) - also demonstrates running `valgrind` inside earthbuild, useful on macOS / Windows where valgrind isn't available natively.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The project name is Earthly, not 'earthbuild'. Using the correct name ensures consistency with the rest of the documentation.

Suggested change
- [c](./c) - also demonstrates running `valgrind` inside earthbuild, useful on macOS / Windows where valgrind isn't available natively.
- [c](./c) - also demonstrates running valgrind inside Earthly, useful on macOS / Windows where valgrind isn't available natively.

- [cpp](./cpp)
- [dotnet](./dotnet)
- [elixir](./elixir)
Expand Down
42 changes: 39 additions & 3 deletions examples/c/Earthfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
VERSION 0.8
FROM alpine:3.23.3

# renovate: datasource=docker packageName=alpine
ARG --global alpine_version=3.23.3

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To avoid duplication and ensure consistency, consider defining cunit_dev_version as a global ARG. This allows you to manage the version in one place for both the unit-test and memcheck targets.

ARG --global alpine_version=3.23.3
# renovate: datasource=repology depName=alpine_3_23/cunit-dev versioning=loose
ARG --global cunit_dev_version=2.1.3-r7

FROM alpine:$alpine_version
WORKDIR /c-example

deps:
RUN apk --update add build-base cmake
# renovate: datasource=repology depName=alpine_3_23/build-base versioning=loose
ARG build_base_version=0.5-r3
# renovate: datasource=repology depName=alpine_3_23/cmake versioning=loose
ARG cmake_version=4.1.3-r0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The version 4.1.3-r0 for cmake appears to be incorrect. As of Alpine 3.20, the latest version is 3.29.3-r0. Please verify the correct version for your target Alpine release to avoid build failures.

RUN apk --update add \
build-base=$build_base_version \
cmake=$cmake_version

build:
FROM +deps
Expand All @@ -19,14 +28,41 @@ docker:

unit-test:
FROM +deps
RUN apk add cunit-dev
# renovate: datasource=repology depName=alpine_3_23/cunit-dev versioning=loose
ARG cunit_dev_version=2.1.3-r7
RUN apk add cunit-dev=$cunit_dev_version
Comment on lines +31 to +33

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This local ARG can be removed if cunit_dev_version is defined as a global ARG at the top of the file.

    RUN apk add cunit-dev=$cunit_dev_version

COPY src src
COPY test test
RUN cmake test
RUN make
RUN ./unit-test

# memcheck runs the unit-test binary under valgrind's memcheck tool to detect
# leaks, invalid reads/writes, and uninitialised reads. Built with -g -O0 so
# stack traces resolve to source lines.
memcheck:
FROM +deps
# renovate: datasource=repology depName=alpine_3_23/cunit-dev versioning=loose
ARG cunit_dev_version=2.1.3-r7
Comment on lines +45 to +46

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This local ARG can be removed if cunit_dev_version is defined as a global ARG at the top of the file.

# renovate: datasource=repology depName=alpine_3_23/valgrind versioning=loose
ARG valgrind_version=3.25.1-r2

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The version 3.25.1-r2 for valgrind appears to be incorrect. As of Alpine 3.20, the latest version is 3.23.0-r0. Please verify the correct version for your target Alpine release.

RUN apk add \
cunit-dev=$cunit_dev_version \
valgrind=$valgrind_version
COPY src src
COPY test test
RUN cmake -DCMAKE_C_FLAGS="-g -O0" test
RUN make
RUN valgrind \
--error-exitcode=1 \
--leak-check=full \
--show-leak-kinds=all \
--errors-for-leak-kinds=definite \
--track-origins=yes \
./unit-test

all:
BUILD +build
BUILD +unit-test
BUILD +memcheck
BUILD +docker
Loading