From af4c20abc27120400ef0d520f7699ff340a323b2 Mon Sep 17 00:00:00 2001 From: Gustav Behm Date: Tue, 1 Nov 2022 16:04:59 +0100 Subject: [PATCH] Fix build-and-test --- .github/workflows/build-test.yaml | 17 ++++++++++------- build/archlinux/PKGBUILD.template | 3 ++- build/ubuntu/mk | 9 +++++++-- tools/capture.c | 2 +- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index c864ef6..7a7a4f3 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -10,6 +10,7 @@ jobs: ARCH: ubuntu2204 UNPRIVILEGED: ubuntu TEST_OUTPUT_DIR: /tmp/tests + WORKDIR: /tmp/workdir steps: - name: Install minimal dependencies run: | @@ -28,7 +29,7 @@ jobs: echo "$UNPRIVILEGED ALL = NOPASSWD: $(which apt-get)" | tee -a /etc/sudoers - name: Build package - run: sudo -u $UNPRIVILEGED env SUDO=sudo build/ubuntu/mk + run: sudo -u $UNPRIVILEGED --preserve-env=WORKDIR env SUDO=sudo build/ubuntu/mk - name: Archive source package uses: actions/upload-artifact@v3 @@ -42,9 +43,10 @@ jobs: - name: Test system installation run: | - sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR env SUT=$(which hlua) tools/test-harness -c hlua - sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR env SUT=$(which hpython) tools/test-harness -c hpython - sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR env SUT=$(which hnode) tools/test-harness -c hnode + export TOOLS=$(readlink -f "$WORKDIR"/*/tools) + sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR,TOOLS env SUT=$(which hlua) tools/test-harness -c hlua + sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR,TOOLS env SUT=$(which hpython) tools/test-harness -c hpython + sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR,TOOLS env SUT=$(which hnode) tools/test-harness -c hnode - name: Archive test results uses: actions/upload-artifact@v3 @@ -93,9 +95,10 @@ jobs: - name: Test system installation run: | - sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR env SUT=$(which hlua) tools/test-harness -c hlua - sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR env SUT=$(which hpython) tools/test-harness -c hpython - sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR env SUT=$(which hnode) tools/test-harness -c hnode + export TOOLS=$(readlink -f build/archlinux/src/*/tools) + sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR,TOOLS env SUT=$(which hlua) tools/test-harness -c hlua + sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR,TOOLS env SUT=$(which hpython) tools/test-harness -c hpython + sudo -u $UNPRIVILEGED --preserve-env=TEST_OUTPUT_DIR,TOOLS env SUT=$(which hnode) tools/test-harness -c hnode - name: Archive test results uses: actions/upload-artifact@v3 diff --git a/build/archlinux/PKGBUILD.template b/build/archlinux/PKGBUILD.template index 6820314..6ebcf22 100644 --- a/build/archlinux/PKGBUILD.template +++ b/build/archlinux/PKGBUILD.template @@ -24,7 +24,8 @@ EOF } build() { - make tools build -C "$ROOT" + make tools -C "$ROOT" + make build -C "$ROOT" } check() { diff --git a/build/ubuntu/mk b/build/ubuntu/mk index cad7d0b..857e628 100755 --- a/build/ubuntu/mk +++ b/build/ubuntu/mk @@ -7,8 +7,13 @@ OUTPUT_DIR=${OUTPUT_DIR-$SCRIPT_DIR/out} HOST_TOOLS=${HOST_TOOLS-$(readlink -f "$SCRIPT_DIR/../../tools")} -WORKDIR=$(mktemp -d) -trap 'rm -rf $WORKDIR' EXIT +WORKDIR=${WORKDIR-} +if [ -z "$WORKDIR" ]; then + WORKDIR=$(mktemp -d) + trap 'rm -rf $WORKDIR' EXIT +else + mkdir -p "$WORKDIR" +fi read SHA256 TARBALL < <("$HOST_TOOLS/archive" -O "$WORKDIR") echo 1>&2 "- source tarball: $(basename "$TARBALL") $SHA256" diff --git a/tools/capture.c b/tools/capture.c index 6ce729d..d8a1da7 100644 --- a/tools/capture.c +++ b/tools/capture.c @@ -267,7 +267,7 @@ int main(int argc, char* argv[]) if(o.returncode_fn) { debug("writing returncode to: %s", o.returncode_fn); - int fd = open(o.returncode_fn, O_WRONLY|O_EXCL|O_CREAT); + int fd = open(o.returncode_fn, O_WRONLY|O_EXCL|O_CREAT, 0644); CHECK(fd, "open(%s)", o.returncode_fn); char buf[48];