Skip to content

Commit

Permalink
refactor(make): rewrite test-pure-on to simply extend dev-pure-on
Browse files Browse the repository at this point in the history
  • Loading branch information
edouard-lopez committed Aug 17, 2023
1 parent 05e888b commit fd3a5e6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Specify fish version to use during build
# docker build -t <image> --build-arg FISH_VERSION=<version>
ARG FISH_VERSION
FROM purefish/docker-fish:${FISH_VERSION} AS fish-only
FROM purefish/docker-fish:${FISH_VERSION} AS only-fish

# Redeclare ARG so its value is available after FROM (cf. https://github.com/moby/moby/issues/34129#issuecomment-417609075)
ARG FISH_VERSION
Expand All @@ -25,14 +25,15 @@ RUN echo '%wheel ALL=(ALL) ALL' > /etc/sudoers.d/wheel \
&& usermod -g wheel nemo \
&& echo "nemo:123" | sudo chpasswd

# create an image with pure's source code
FROM only-fish AS with-pure-source
USER nemo
WORKDIR /home/nemo/.config/fish/
WORKDIR /home/nemo/.config/fish/pure/
COPY --chown=nemo:nemo ./ /home/nemo/.config/fish/pure/

FROM fish-only AS with-pure
# Copy source code
COPY --chown=nemo:nemo ./conf.d/* /home/nemo/.config/fish/conf.d/
COPY --chown=nemo:nemo ./functions/* /home/nemo/.config/fish/functions/
COPY --chown=nemo:nemo ./tests/* /home/nemo/.config/fish/tests/
# create an image with pure installed as prompt
FROM with-pure-source AS with-pure-installed
RUN cp ./pure/ ./

ENTRYPOINT ["fish", "-c"]
CMD ["fishtape tests/*.test.fish"]
27 changes: 19 additions & 8 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ usage:
@printf "\tmake dev-pure-on FISH_VERSION=3.3.1\t# dev in container\n"

.PHONY: build-pure-on
build-pure-on: STAGE?=only-fish
build-pure-on:
docker build \
--quiet \
--file ./Dockerfile \
--target fish-only \
--target ${STAGE} \
--build-arg FISH_VERSION=${FISH_VERSION} \
--tag=pure-on-fish-${FISH_VERSION} \
--tag=pure-${STAGE}-${FISH_VERSION} \
./

.PHONY: dev-pure-on
Expand All @@ -34,15 +35,25 @@ dev-pure-on:
--tty \
--volume=$$(pwd):/home/nemo/.config/fish/pure/ \
--workdir /home/nemo/.config/fish/pure/ \
pure-on-fish-${FISH_VERSION} "${CMD}"
pure-${STAGE}-${FISH_VERSION} "${CMD}"
chmod o=r-x tests/fixtures/ # for migration-to-4.0.0.test.fish only

# Don't override COPY directive as `--volume` doesnt play nice with Travis
.PHONY: test-pure-on
test-pure-on: export CMD=fishtape tests/*.test.fish # can be overriden by user
test-pure-on:
test-pure-on: CMD?=fishtape tests/*.test.fish
test-pure-on: STAGE?=with-pure-source
test-pure-on: build-with-pure-source
docker run \
--name test-pure-on-${FISH_VERSION} \
--name run-pure-on-${FISH_VERSION} \
--rm \
--tty \
pure-on-fish-${FISH_VERSION} "${CMD}"
pure-${STAGE}-${FISH_VERSION} "${CMD}"

.PHONY: build-with-pure-source
build-with-pure-source:
$(MAKE) build-pure-on FISH_VERSION=${FISH_VERSION} STAGE=with-pure-source

.PHONY: build-with-pure-installed
build-with-pure-installed:
$(MAKE) build-pure-on FISH_VERSION=${FISH_VERSION} STAGE=with-pure-installed


0 comments on commit fd3a5e6

Please sign in to comment.