nix(feat): Create all temporary directories with script name template

Temporary directories are now created in $TMPDIR/postgrest/script-name-XXX. This allows recognizing the origin of a single temporary directory and uploading the whole $TMPDIR/postgrest folder as an artifact in CI.
This commit is contained in:
Wolfgang Walther
2021-04-24 15:07:13 +02:00
committed by Wolfgang Walther
parent 14ddecc81a
commit c691b37f76
3 changed files with 14 additions and 3 deletions
+8 -1
View File
@@ -67,6 +67,8 @@ jobs:
name: run spec tests
command: |
test/create_test_db "postgres://circleci@localhost" postgrest_test stack test
- store_artifacts:
path: /tmp/postgrest
# Publish a new release. This only runs when a release is tagged (see
# workflow below).
@@ -111,6 +113,8 @@ jobs:
then
postgrest-release-dockerhub-description
fi
- store_artifacts:
path: /tmp/postgrest
# Build everything in default.nix and push to the Cachix binary cache if running on main
nix-build:
@@ -154,6 +158,8 @@ jobs:
echo "Building all derivations (caching skipped for outside pull requests)..."
nix-build
fi
- store_artifacts:
path: /tmp/postgrest
# Run tests
nix-test:
@@ -218,7 +224,8 @@ jobs:
name: Run memory tests
command: postgrest-test-memory
when: always
- store_artifacts:
path: /tmp/postgrest
workflows:
version: 2
@@ -3,6 +3,7 @@
# to be used in a path for example.
{ argbash
, bash_5
, coreutils
, git
, lib
, runCommand
@@ -83,7 +84,7 @@ let
+ lib.optionalString redirectTixFiles ''
# storing tix files in a temporary throw away directory avoids mix/tix conflicts after changes
hpctixdir=$(mktemp -d)
hpctixdir=$(${coreutils}/bin/mktemp -d)
export HPCTIXFILE="$hpctixdir"/postgrest.tix
trap 'rm -rf $hpctixdir' EXIT
''
@@ -99,7 +100,8 @@ let
''
+ lib.optionalString withTmpDir ''
tmpdir="$(mktemp -d)"
mkdir -p "''${TMPDIR:-/tmp}/postgrest"
tmpdir="$(${coreutils}/bin/mktemp -d --tmpdir postgrest/${name}-XXX)"
# we keep the tmpdir when an error occurs for debugging
trap 'echo Temporary directory kept at: $tmpdir' ERR
+2
View File
@@ -41,6 +41,8 @@ let
}
mkdir -p "$tmpdir"/{db,socket}
# remove data dir, even if we keep tmpdir - no need to upload it to artifacts
trap 'rm -rf $tmpdir/db' EXIT
export PGDATA="$tmpdir/db"
export PGHOST="$tmpdir/socket"