/
Earthfile
53 lines (46 loc) · 1.45 KB
/
Earthfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
deps:
FROM rocker/r-devel
RUN bash -c "Rscript <(echo 'install.packages(\"RUnit\", repos=\"http://cran.us.r-project.org\")')"
code:
FROM +deps
COPY --dir rjson /code/rjson
WORKDIR /code
unittest:
FROM +code
COPY test.r .
# validate this file is utf-8 encoded
RUN file rjson/inst/unittests/test.unicode.r | grep 'test.unicode.r: Unicode text, UTF-8 text'
RUN ./test.r
cran:
FROM +code
# first make sure there are no warnings
RUN R CMD check --as-cran rjson
# next make the tar.gz
RUN R CMD build rjson
SAVE ARTIFACT rjson_*.tar.gz AS LOCAL output/
# based on https://github.com/kalibera/rchk/blob/master/image/docker/Dockerfile
rcheck:
FROM kalibera/rchk:latest
COPY +cran/rjson_* .
RUN test $(ls rjson_*.tar.gz | wc -l) = 1
RUN chmod +x /container.sh
RUN echo "#!/bin/bash
# /container.sh doesn't return an exit code on failures, so we will test that ERROR
# doesn't exist in the output
/container.sh rjson_*.tar.gz 2>&1 | tee output.txt
cat output.txt | grep -v ERROR" > test.sh && chmod +x test.sh
RUN ./test.sh
test:
BUILD +unittest
BUILD +rcheck
reformat:
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y \
clang-format-7
WORKDIR /code
COPY .clang-format .
COPY --dir rjson/src src
RUN find . -type f -name '*.c' -exec clang-format-7 -i {} \;
SAVE ARTIFACT src/* AS LOCAL rjson/src/