Rework the makefiles.
This commit is contained in:
@@ -2,10 +2,16 @@ FROM rustlang/rust:nightly-alpine3.19 AS builder
|
||||
|
||||
RUN apk add --no-cache musl-dev
|
||||
RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache
|
||||
RUN rustup component add rustfmt
|
||||
RUN rustup component add clippy
|
||||
RUN rustup component add rustc-codegen-cranelift
|
||||
|
||||
FROM builder AS format
|
||||
|
||||
RUN rustup component add rustfmt
|
||||
|
||||
FROM builder AS clippy
|
||||
|
||||
RUN rustup component add clippy
|
||||
|
||||
FROM builder AS wasm
|
||||
|
||||
RUN rustup target add wasm32-unknown-unknown
|
||||
|
||||
@@ -10,8 +10,11 @@ ifeq ($(origin .RECIPEPREFIX), undefined)
|
||||
endif
|
||||
.RECIPEPREFIX = >
|
||||
|
||||
IMAGE_NAME:=organic-development
|
||||
TARGET :=
|
||||
TARGET := builder
|
||||
IMAGE_NAME := organic-development
|
||||
ifneq ($(TARGET),builder)
|
||||
IMAGE_NAME := $(IMAGE_NAME)-$(TARGET)
|
||||
endif
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
|
||||
@@ -29,6 +29,7 @@ FROM rustlang/rust:nightly-alpine3.19 AS tester
|
||||
ENV LANG=en_US.UTF-8
|
||||
RUN apk add --no-cache musl-dev ncurses gnutls libgccjit
|
||||
RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache
|
||||
RUN rustup component add rustc-codegen-cranelift
|
||||
COPY --from=build-emacs /root/dist/ /
|
||||
COPY --from=build-org-mode /root/dist/ /
|
||||
|
||||
@@ -100,7 +101,7 @@ RUN mkdir -p $LITERATE_BUILD_EMACS_PATH && git -C $LITERATE_BUILD_EMACS_PATH ini
|
||||
# unused/aws.org contains invalid paths for setupfile which causes both upstream org-mode and Organic to error out.
|
||||
RUN rm $LITERATE_BUILD_EMACS_PATH/unused/aws.org
|
||||
|
||||
FROM tester as foreign-document-test
|
||||
FROM tester as foreign-document
|
||||
RUN apk add --no-cache bash coreutils
|
||||
RUN mkdir /foreign_documents
|
||||
COPY --from=foreign-document-gather /foreign_documents/howardabrams /foreign_documents/howardabrams
|
||||
|
||||
@@ -1,44 +1,36 @@
|
||||
IMAGE_NAME:=organic-test
|
||||
# REMOTE_REPO:=harbor.fizz.buzz/private
|
||||
SHELL := bash
|
||||
.ONESHELL:
|
||||
.SHELLFLAGS := -eu -o pipefail -c
|
||||
.DELETE_ON_ERROR:
|
||||
MAKEFLAGS += --warn-undefined-variables
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
|
||||
.PHONY: all
|
||||
all: build push
|
||||
ifeq ($(origin .RECIPEPREFIX), undefined)
|
||||
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
|
||||
endif
|
||||
.RECIPEPREFIX = >
|
||||
|
||||
TARGET := tester
|
||||
IMAGE_NAME := organic-test
|
||||
ifneq ($(TARGET),tester)
|
||||
IMAGE_NAME := $(IMAGE_NAME)-$(TARGET)
|
||||
endif
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
> @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -E 's/^([^:]*): *## */\1: /'
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
docker build -t $(IMAGE_NAME) -f Dockerfile --target tester .
|
||||
|
||||
.PHONY: build_foreign_document_test
|
||||
build_foreign_document_test:
|
||||
docker build -t $(IMAGE_NAME)-foreign-document -f Dockerfile --target foreign-document-test .
|
||||
|
||||
.PHONY: push
|
||||
push:
|
||||
ifdef REMOTE_REPO
|
||||
docker tag $(IMAGE_NAME) $(REMOTE_REPO)/$(IMAGE_NAME)
|
||||
docker push $(REMOTE_REPO)/$(IMAGE_NAME)
|
||||
else
|
||||
@echo "REMOTE_REPO not defined, not pushing to a remote repo."
|
||||
endif
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
docker rmi $(IMAGE_NAME)
|
||||
ifdef REMOTE_REPO
|
||||
docker rmi $(REMOTE_REPO)/$(IMAGE_NAME)
|
||||
else
|
||||
@echo "REMOTE_REPO not defined, not removing from remote repo."
|
||||
endif
|
||||
docker volume rm rust-cache cargo-cache
|
||||
|
||||
.PHONY: run
|
||||
run: build
|
||||
docker run --rm --init --read-only --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME) --no-default-features --features compare --no-fail-fast --lib --test test_loader
|
||||
build: ## Build the docker image.
|
||||
> docker build --tag $(IMAGE_NAME) --target=$(TARGET) --file Dockerfile .
|
||||
> docker volume create organic-cargo-registry
|
||||
|
||||
.PHONY: shell
|
||||
shell: ## Launch an interactive shell inside the docker image with the source repository mounted at /source.
|
||||
shell: build
|
||||
docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME)
|
||||
> docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source" --workdir=/source --env CARGO_TARGET_DIR=/target -v "organic-cargo-registry:/usr/local/cargo/registry" $(IMAGE_NAME)
|
||||
|
||||
.PHONY: run_foreign_document_test
|
||||
run_foreign_document_test: build_foreign_document_test
|
||||
docker run --rm --init --read-only --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME)-foreign-document
|
||||
.PHONY: clean
|
||||
clean: ## Remove the docker image and volume.
|
||||
> docker rmi $(IMAGE_NAME)
|
||||
> docker volume rm organic-cargo-registry
|
||||
|
||||
Reference in New Issue
Block a user