Skip to content

Commit

Permalink
ci: top level bats
Browse files Browse the repository at this point in the history
  • Loading branch information
bodymindarts committed Nov 9, 2023
1 parent 7b3b396 commit eb2ca4f
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 14 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/bats.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Bats test"

on:
pull_request:
branches: [main]

jobs:
integration:
name: Bats tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Run the Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Buck2 build
run: nix develop -c buck2 build core/api core/api-keys apps/dashboard apps/consent
- name: Run bats tests
run: |
nix develop -c bats --setup-suite-file bats/ci_setup_suite.bash -t bats/core/api
20 changes: 20 additions & 0 deletions bats/ci_setup_suite.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

export REPO_ROOT=$(git rev-parse --show-toplevel)
source "${REPO_ROOT}/bats/helpers/setup-and-teardown.bash"

TILT_PID_FILE=$REPO_ROOT/bats/.tilt_pid

setup_suite() {
background buck2 run //dev:up -- --bats=True > "${REPO_ROOT}/bats/.e2e-tilt.log"
echo $! > "$TILT_PID_FILE"
await_api_is_up
}

teardown_suite() {
if [[ -f "$TILT_PID_FILE" ]]; then
kill "$(cat "$TILT_PID_FILE")" > /dev/null || true
fi

buck2 run //dev:down
}
9 changes: 0 additions & 9 deletions bats/core/api/public.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@

load "../../helpers/_common.bash"

setup_file() {
start_services "api"
await_api_is_up
}

teardown_file() {
stop_services
}

@test "public: can query globals" {
exec_graphql 'anon' 'globals'
network="$(graphql_output '.data.globals.network')"
Expand Down
4 changes: 2 additions & 2 deletions dev/Tiltfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
config.define_string_list("test")
config.define_string_list("to-run", args = True)
config.define_bool("bats")
cfg = config.parse()

is_ci=("ci" in sys.argv)
is_ci=("ci" in sys.argv) or cfg.get("bats", False)

def _buck2_dep_inputs(target):
cmd = [
Expand Down
2 changes: 1 addition & 1 deletion dev/tilt.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ subcmd="$1"
tiltfile="$2"
args=("${@:3}")
tilt "$subcmd" --file "$rootpath"/"$tiltfile" -- "${args[@]}"
exec tilt "$subcmd" --file "$rootpath"/"$tiltfile" -- "${args[@]}"
""", is_executable = True)

run_cmd_args = cmd_args([
Expand Down
4 changes: 2 additions & 2 deletions toolchains/workspace-pnpm/macros.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ cd "$rootpath/$npm_package_path"
if [ "$install_node_modules" = "True" ]; then
pnpm install
fi
pnpm run --report-summary "$npm_run_command"
exec pnpm run --report-summary "$npm_run_command"
""", is_executable = True)
args = cmd_args([script, str(ctx.attrs.local_node_modules), ctx.label.package, ctx.attrs.command])
args.hidden([ctx.attrs.deps])
Expand Down Expand Up @@ -927,7 +927,7 @@ cd "$rootpath/$npm_package_path"
if [ "$install_node_modules" = "True" ]; then
pnpm install
fi
pnpm run --report-summary "$npm_run_command"
exec pnpm run --report-summary "$npm_run_command"
""", is_executable = True)
args = cmd_args([script, str(ctx.attrs.local_node_modules), ctx.label.package, ctx.attrs.command])
args.hidden([ctx.attrs.deps])
Expand Down

0 comments on commit eb2ca4f

Please sign in to comment.