Store package build logs as circleci artifacts (#1646)

This commit is contained in:
Hood Chatham 2021-06-19 09:51:36 -07:00 committed by GitHub
parent 2dd41b639b
commit 9ffae14dbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 2 deletions

View File

@ -131,6 +131,9 @@ jobs:
- store_artifacts:
path: /root/repo/build/
- store_artifacts:
path: /root/repo/packages/build-logs
test-core-firefox:
<<: *defaults
steps:

1
.gitignore vendored
View File

@ -25,4 +25,5 @@ geckodriver.log
node_modules
packages/.artifacts
packages/*/build.log
packages/build-logs
dist/

View File

@ -8,8 +8,10 @@ else
endif
all: .artifacts/bin/pyodide-build
mkdir -p build-logs
PYTHONPATH="$(PYODIDE_LIBRARIES)/lib/python:$(PYODIDE_ROOT)/pyodide-build/" pyodide-build buildall . ../build \
--target=$(TARGETPYTHONROOT) $(ONLY_PACKAGES) --install-dir $(PYODIDE_LIBRARIES) --n-jobs $${PYODIDE_JOBS:-4}
--target=$(TARGETPYTHONROOT) $(ONLY_PACKAGES) --install-dir $(PYODIDE_LIBRARIES) --n-jobs $${PYODIDE_JOBS:-4} \
--log-dir=build-logs
.artifacts/bin/pyodide-build: ../pyodide-build/pyodide_build/**
mkdir -p $(PYODIDE_LIBRARIES)

View File

@ -81,7 +81,7 @@ class Package(BasePackage):
self.dependents = set()
def build(self, outputdir: Path, args) -> None:
with open(self.pkgdir / "build.log", "w") as f:
with open(self.pkgdir / "build.log.tmp", "w") as f:
p = subprocess.run(
[
sys.executable,
@ -105,6 +105,27 @@ class Package(BasePackage):
stderr=subprocess.STDOUT,
)
# Don't overwrite build log if we didn't build the file.
# If the file didn't need to be rebuilt, the log will have exactly two lines.
rebuilt = True
with open(self.pkgdir / "build.log.tmp", "r") as f:
try:
next(f)
next(f)
next(f)
except StopIteration:
rebuilt = False
if rebuilt:
shutil.move(self.pkgdir / "build.log.tmp", self.pkgdir / "build.log") # type: ignore
else:
(self.pkgdir / "build.log.tmp").unlink()
if args.log_dir:
shutil.copy(
self.pkgdir / "build.log", Path(args.log_dir) / f"{self.name}.log"
)
try:
p.check_returncode()
except subprocess.CalledProcessError:
@ -337,6 +358,14 @@ def make_parser(parser):
"needed if you want to build other packages that depend on this one."
),
)
parser.add_argument(
"--log-dir",
type=str,
dest="log_dir",
nargs="?",
default=None,
help=("Directory to place log files"),
)
parser.add_argument(
"--only",
type=str,