Skip to content

Commit

Permalink
rearrange tooling
Browse files Browse the repository at this point in the history
Signed-off-by: Romain Gautier <[email protected]>
  • Loading branch information
mykiwi committed Jan 7, 2025
1 parent 5c65899 commit f697ed2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 42 deletions.
6 changes: 2 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
Makefile
Dockerfile
docker-bake.hcl
tests-docker-output
devtools
tests-outputs

*.lo
*.o
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ tmp-php.ini

coverage_report/**

tests-docker-output
tests-outputs
11 changes: 5 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
SHELL := bash
MAKEFLAGS += --no-builtin-rules
.PHONY: help
.PHONY: help tests-outputs

# use local source code here
BAKE = docker buildx bake --set main.contexts.php-v8js-source-code=.
BAKE = docker buildx bake --file devtools/docker-bake.hcl

help:
@grep -E '(^[a-zA-Z0-9\./_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'

build: php84 ## Build the project on latest PHP version
tests-outputs: php84 ## Run tests inside docker containers and save outputs inside `tests-outputs` directory

matrix: ## Build the project on each actively maintained PHP version
tests-outputs-all-versions: ## Same, but with each actively maintained PHP version
make -j4 build-matrix

build-matrix: php84 php83 php82 php81
Expand All @@ -28,4 +27,4 @@ php81:
PHP_VERSION=8.1 $(BAKE)

clean:
rm -rf tests-docker-output
rm -rf tests-outputs
25 changes: 25 additions & 0 deletions devtools/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Usage from the root directory:
# docker buildx bake -f devtools/docker-bake.hcl
# PHP_VERSION=8.3 docker buildx bake -f devtools/docker-bake.hcl
# PHP_VERSION=8.2 docker buildx bake -f devtools/docker-bake.hcl
# PHP_VERSION=8.1 docker buildx bake -f devtools/docker-bake.hcl
# docker buildx bake -f devtools/docker-bake.hcl --set *.contexts.php-v8js-source-code=https://github.com/your-fork/v8js.git#your-branch

group "default" {
targets = ["main"]
platforms = ["linux/amd64", "linux/arm64"]
}

variable "PHP_VERSION" {
default = "8.4"
}

target "main" {
dockerfile = "make-test.Dockerfile"
context = "./devtools"
contexts = {
"php-specified-version" = "docker-image://php:${PHP_VERSION}"
"php-v8js-source-code" = "."
}
output = ["type=local,dest=tests-outputs/"]
}
14 changes: 6 additions & 8 deletions Dockerfile → devtools/make-test.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# syntax=docker/dockerfile:1

FROM php-specified-version AS build

RUN <<EOF
apt update
apt upgrade -y
Expand All @@ -11,20 +10,19 @@ RUN <<EOF
cp -s /usr/lib/`uname -m`-linux-gnu/libv8* /usr/local/lib/
cp -rs /usr/include/node/* /usr/local/include/
EOF

#RUN git clone https://github.com/phpv8/v8js.git --branch php8 /tmp/php-v8js
COPY --from=php-v8js-source-code / /tmp/php-v8js
WORKDIR /tmp/php-v8js

RUN <<EOF
phpize
./configure
make -j$(nproc)
make test > php$(php -r 'echo PHP_VERSION;')_$(uname -m)-make_test_std 2>&1 || true
ls php_test_results_*.txt && mv php_test_results_*.txt php$(php -r 'echo PHP_VERSION;')_$(uname -m)-make_test_report || true
EOF

RUN <<EOF
export PREFIX=php$(php -r 'echo PHP_VERSION;')_$(uname -m)__
make test > ${PREFIX}1-std 2>&1 || true
ls php_test_results_*.txt && mv php_test_results_*.txt ${PREFIX}2-report || true
EOF


FROM scratch
COPY --from=build /tmp/php-v8js/*-make_test_* /
COPY --from=build /tmp/php-v8js/*__* /
23 changes: 0 additions & 23 deletions docker-bake.hcl

This file was deleted.

0 comments on commit f697ed2

Please sign in to comment.