Skip to content

Commit

Permalink
chore: fix make
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed May 22, 2024
1 parent 5a66711 commit d204c00
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
3 changes: 1 addition & 2 deletions interop/BrowserDockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ FROM mcr.microsoft.com/playwright

COPY --from=js-libp2p-base /app/ /app/
WORKDIR /app

# We install browsers here instead of the cached version so that we use the latest browsers at run time.
# Ideally this would also be pinned, but playwright controls this, so there isn't much we can do about it.
# By installing here, we avoid installing it at test time.
RUN npm ci
RUN npx playwright install-deps
RUN npx playwright install
RUN npm run build

# Options: chromium, firefox, webkit
ARG BROWSER=chromium
Expand Down
13 changes: 9 additions & 4 deletions interop/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ FROM node:22-bullseye-slim

WORKDIR /app

COPY package*.json .aegir.js tsconfig.json ./
COPY src ./src
COPY test ./test
COPY package.json .
COPY ./packages ./packages
COPY ./interop ./interop

RUN npm ci
RUN npm i
RUN npm run build

WORKDIR /app/interop

# disable colored output and CLI animation from test runners
ENV CI true

ENTRYPOINT npm test -- -t node
42 changes: 19 additions & 23 deletions interop/Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
image_name := js-v0.46
image_name := js-libp2p-head
TEST_SOURCES := $(wildcard test/*.ts)

# TODO Enable webkit once https://github.com/libp2p/js-libp2p/pull/1627 is in
all: node-image.json chromium-image.json firefox-image.json update-lock-file
# Enable webkit once https://github.com/libp2p/js-libp2p/pull/1627 is in
# all: node-image.json webkit-image.json firefox-image.json chromium-image.json
all: node-image.json firefox-image.json chromium-image.json

# Necessary because multistage builds require a docker image name rather than a digest to be used
load-image-json: node-image.json
docker image tag $$(jq -r .imageID node-image.json) ${image_name}
node-image.json: Dockerfile $(TEST_SOURCES) package.json .aegir.js
cd .. && docker build -f interop/Dockerfile -t node-${image_name} .
docker image inspect node-${image_name} -f "{{.Id}}" | \
xargs -I {} echo "{\"imageID\": \"{}\"}" > $@

chromium-image.json: load-image-json BrowserDockerfile
docker build -f BrowserDockerfile --build-arg=BASE_IMAGE=${image_name} --build-arg=BROWSER=chromium -t chromium-${image_name} .
chromium-image.json: node-image.json BrowserDockerfile $(TEST_SOURCES) package.json .aegir.js
cd .. && docker build -f interop/BrowserDockerfile --build-arg=BROWSER=chromium -t chromium-${image_name} .
docker image inspect chromium-${image_name} -f "{{.Id}}" | \
xargs -I {} echo "{\"imageID\": \"{}\"}" > $@

firefox-image.json: load-image-json BrowserDockerfile
docker build -f BrowserDockerfile --build-arg=BASE_IMAGE=${image_name} --build-arg=BROWSER=firefox -t firefox-${image_name} .
firefox-image.json: node-image.json BrowserDockerfile $(TEST_SOURCES) package.json .aegir.js
cd .. && docker build -f interop/BrowserDockerfile --build-arg=BROWSER=firefox -t firefox-${image_name} .
docker image inspect firefox-${image_name} -f "{{.Id}}" | \
xargs -I {} echo "{\"imageID\": \"{}\"}" > $@

# We update the lock file here so that we make sure we are always using the correct lock file.
# If this changes, CI will fail since there are unstaged changes.
update-lock-file: node-image.json
CONTAINER_ID=$$(docker create $$(jq -r .imageID node-image.json)); \
docker cp $$CONTAINER_ID:/app/package-lock.json ./package-lock.json; \
docker rm $$CONTAINER_ID

image.json:
docker build -t ${image_name} -f ./Dockerfile .
docker image inspect ${image_name} -f "{{.Id}}" | \
webkit-image.json: node-image.json BrowserDockerfile $(TEST_SOURCES) package.json .aegir.js
cd .. && docker build -f interop/BrowserDockerfile --build-arg=BROWSER=webkit -t webkit-${image_name} .
docker image inspect webkit-${image_name} -f "{{.Id}}" | \
xargs -I {} echo "{\"imageID\": \"{}\"}" > $@

clean:
rm -rf *-image.json
.PHONY: clean

.PHONY: all clean browser-images load-image-json
clean:
rm *image.json

0 comments on commit d204c00

Please sign in to comment.