Skip to content

Commit

Permalink
chore: make clean and docker cleanup
Browse files Browse the repository at this point in the history
- adds 'make clean' that removes artifacts
- improves ux when working with docker, especially when image is missing
- 'make' only builds the binary, kubo logic needs to be explicitly
  called
  • Loading branch information
lidel committed Jul 14, 2023
1 parent de83c0c commit f5a7749
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
/merge-fixtures
/entrypoint
/gateway-conformance
/dnslinks.json
/*.ipns-record

# Logs
logs
Expand Down
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
all: test-kubo
all: gateway-conformance

clean: clean-docker
rm -f ./gateway-conformance
rm -f *.ipns-record
rm -f fixtures.car
rm -f dnslinks.json
rm -f ./reports/*

test-cargateway: provision-cargateway fixtures.car gateway-conformance
./gateway-conformance test --json reports/output.json --gateway-url http://127.0.0.1:8040 --specs -subdomain-gateway
Expand All @@ -15,8 +22,8 @@ provision-cargateway: ./fixtures.car
car -c ./fixtures.car &

provision-kubo:
find ./fixtures -name '*.car' -exec ipfs dag import {} \;
find ./fixtures -name '*.ipns-record' -exec sh -c 'ipfs routing put --allow-offline /ipns/$$(basename -s .ipns-record "{}") "{}"' \;
find ./fixtures -name '*.car' -exec ipfs dag import --stats --pin-roots=false {} \;
find ./fixtures -name '*.ipns-record' -exec sh -c 'ipfs routing put --offline --allow-offline /ipns/$$(basename -s .ipns-record "{}") "{}"' \;

# tools
fixtures.car: gateway-conformance
Expand All @@ -31,12 +38,17 @@ test-docker: docker fixtures.car gateway-conformance
./reports/output.xml: ./reports/output.json
jq -ns 'inputs' ./reports/output.json > ./reports/output.json.alt
docker run --rm -v "${PWD}:/workspace" -w "/workspace" ghcr.io/pl-strflt/saxon:v1 -json:"./reports/output.json.alt" -xsl:/etc/gotest.xsl -o:"./reports/output.xml"

./reports/output.html: ./reports/output.xml
docker run --rm -v "${PWD}:/workspace" -w "/workspace" ghcr.io/pl-strflt/saxon:v1 -s:./reports/output.xml -xsl:/etc/junit-noframes-saxon.xsl -o:./reports/output.html
open ./reports/output.html

docker:
docker build -t gateway-conformance .

clean-docker:
@if command -v docker >/dev/null 2>&1 && docker image inspect gateway-conformance >/dev/null 2>&1; then \
docker image rm gateway-conformance; \
fi

.PHONY: gateway-conformance
7 changes: 6 additions & 1 deletion gc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#!/usr/bin/env bash

docker run --rm -v "${PWD}:/workspace" -w "/workspace" --network=host gateway-conformance "$@"
if docker image inspect gateway-conformance >/dev/null 2>&1; then
docker run --rm -v "${PWD}:/workspace" -w "/workspace" --network=host gateway-conformance "$@"
else
echo "Docker image 'gateway-conformance' does not exist. Run 'make docker' first." >&2
exit 1
fi

0 comments on commit f5a7749

Please sign in to comment.