VERSION 0.8

FROM ../../+base

# deps downloads and caches all dependencies for the deltautil package. When
# called directly, go.mod and go.sum will be updated locally.
deps:
    COPY go.mod go.sum ./
    RUN go mod download
    SAVE ARTIFACT go.mod AS LOCAL go.mod
    SAVE ARTIFACT go.sum AS LOCAL go.sum

code:
    FROM +deps
    COPY . .

# unit-test runs the unit tests in the deltautil package.
unit-test:
    FROM +code
    ARG testname
    RUN if [ -n "$testname" ]; then testarg="-run $testname"; fi && \
        go test -race -count 1 $testarg ./...
