Skip to content

Commit

Permalink
Merge pull request #104 from crazy-max/gen-serve
Browse files Browse the repository at this point in the history
generate html report and serve website
  • Loading branch information
crazy-max authored Sep 16, 2024
2 parents d7a01e3 + 1ea19ef commit 113bf10
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test:

.PHONY: gen
gen:
docker buildx bake tests-gen
./hack/gen

.PHONY: vendor
vendor:
Expand Down
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,37 @@ BUILDKIT_REFS=master,v0.9.3,v0.16.0 make test
> images in a docker volume if you are repeatedly calling `./hack/test` script.
> This helps to avoid rate limiting on the remote registry side.
After running the tests, you can generate a report with the following command:
After running the tests, you can generate the HTML report and serve the
website with:

```bash
make gen
```

Report will be generated in `./bin/gen/index.html`.
```text
...
[+] Running 1/0
✔ Container website-serve-1 Created 0.0s
Attaching to serve-1
serve-1 | Running generateResults.js...
serve-1 | /src/public/results.json has been generated successfully.
serve-1 | INFO Starting development server...
DONE Compiled successfully in 947ms2:39:29 PM
serve-1 |
serve-1 | App running at:
serve-1 | - Local: http://localhost:8080/
serve-1 |
serve-1 | It seems you are running Vue CLI inside a container.
serve-1 | Access the dev server via http://localhost:<your container's external mapped port>/
serve-1 |
serve-1 | Note that the development build is not optimized.
serve-1 | To create a production build, run yarn build.
serve-1 |
Build finished at 14:39:29 by 0.000s
```

Then open [http://localhost:8080](http://localhost:8080) in your browser.

## License

Expand Down
1 change: 1 addition & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ variable "WEBSITE_PUBLIC_PATH" {

target "website" {
context = "./website"
target = "build-update"
output = ["./bin/website"]
args = {
WEBSITE_PUBLIC_PATH = WEBSITE_PUBLIC_PATH
Expand Down
18 changes: 18 additions & 0 deletions hack/gen
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -eu -o pipefail

testFile=./bin/results/gotestoutput.json
testDate=$(date +'%Y%m%d-%H%M%S')
if [ -f "$testFile" ]; then
testDate=$(date -d "$(stat -c %y "$testFile" | cut -d' ' -f1,2)" +'%Y%m%d-%H%M%S')
fi

resultDir=./website/public/result/${testDate}
if [ -d "$resultDir" ]; then
rm -rf "$resultDir"
fi

set -x
docker buildx bake tests-gen --set "*.output=${resultDir}"
docker compose --project-directory website up --build
18 changes: 10 additions & 8 deletions website/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ RUN --mount=type=bind,target=.,rw \
yarn config set --home enableTelemetry 0
EOT

FROM base AS deps
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \
yarn install
FROM base AS install
COPY .yarnrc.yml package.json yarn.lock ./
RUN yarn install

FROM base AS dev
COPY --from=install /src/node_modules /src/node_modules
COPY . .

FROM deps AS build
FROM base AS build
ARG WEBSITE_PUBLIC_PATH
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \
--mount=from=install,source=/src/node_modules,target=/src/node_modules \
yarn run build && cp -Rf ./dist /out

FROM scratch
FROM scratch AS build-update
COPY --from=build /out /
8 changes: 8 additions & 0 deletions website/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
serve:
build:
context: .
target: dev
ports:
- "8080:8080"
entrypoint: ["yarn", "run", "serve"]

0 comments on commit 113bf10

Please sign in to comment.