Skip to content
This repository has been archived by the owner on Nov 2, 2022. It is now read-only.

Add GoTrue nix files + Initial setup #39

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions gotrue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# GoTrue benchmark(Work in progress)

Updated and reproducible benchmark for GoTrue by using [Nix](https://nixos.org/) and [k6](https://k6.io).

## Setup

This whole setup will be handled by Nix.

Run `nix-shell`. This will provide an environment where all the dependencies are available.

```
nix-shell
>
```

## Usage


TODO(Joel): Add K6 scripts

25 changes: 25 additions & 0 deletions gotrue/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{ callPackage
, lib
, stdenv
, fetchurl
, nixos
, testers
}:

stdenv.mkDerivation (finalAttrs: {
pname = "gotrue";
version = "2.9.2";

src = fetchurl {
url = "https://github.com/supabase/gotrue/releases/download/v${finalAttrs.version}/gotrue-v${finalAttrs.version}-x86.tar.gz";
sha256 = "G+3qddI9zyuhx//TA1i1Pt+0Nig2PgEMOXvb9HqfBtY=";
};
phases = ["installPhase"];
installPhase = ''
mkdir -p $out/bin
tar xzvf $src
cp gotrue $out/bin/gotrue
chmod +x $out/bin/gotrue
'';

})
Empty file added gotrue/k6/.gitkeep
Empty file.
73 changes: 73 additions & 0 deletions gotrue/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
let
nixpkgs = builtins.fetchTarball {
name = "nixos-20.03";
url = "https://github.com/nixos/nixpkgs/archive/7bc3a08d3a4c700b53a3b27f5acd149f24b931ec.tar.gz";
sha256 = "1kiz37052zsgvw7a378zg08mpbi1wk8dkgm5j6dy0x4mxvcg8ws3";
};
pkgs = import nixpkgs {};
deploy =
pkgs.writeShellScriptBin "gotrue-deploy"
''
set -euo pipefail
set +e && nixops info -d gotrue > /dev/null 2> /dev/null
info=$? && set -e
if test $info -eq 1
then
echo "Creating deployment..."
nixops create deploy.nix -d gotrue
fi
nixops deploy -k -d pgrbench --allow-reboot --confirm
'';
info =
pkgs.writeShellScriptBin "gotrue-info"
''
set -euo pipefail
nixops info -d gotrue
'';
k6 =
pkgs.writeShellScriptBin "gotrue-k6"
''
set -euo pipefail
nixops ssh -d gotrue client k6 run -q --vus $1 - < $2
'';
repeat =
pkgs.writeShellScriptBin "repeat"
''
set -euo pipefail
number=$1
shift
for i in `seq $number`; do
echo -e "\nRun: $i"
$@
done
'';
ssh =
pkgs.writeShellScriptBin "pgrbench-ssh"
''
set -euo pipefail
nixops ssh -d pgrbench $1
'';
destroy =
pkgs.writeShellScriptBin "gotrue-destroy"
''
set -euo pipefail
nixops destroy -d gotrue --confirm
nixops delete -d gotrue
rm .deployment.nixops
'';
in
pkgs.mkShell {
buildInputs = [
pkgs.nixops
deploy
info
k6
ssh
destroy
repeat
];
shellHook = ''
export NIX_PATH="nixpkgs=${nixpkgs}:."
export NIXOPS_STATE=".deployment.nixops"
'';
}