Skip to content

Commit

Permalink
ci: wrap tilt ci tests in script to handle logs (#3933)
Browse files Browse the repository at this point in the history
* ci: wrap tilt ci tests in script to handle logs

* ci: add tiltfile upload to integration gh action

* ci: handle ci-only changes in integration action

* refactor: rename test resources in tilt for easier filtering

* chore: rename integration action test step
  • Loading branch information
vindard authored Feb 7, 2024
1 parent 2fbce39 commit 96c47bb
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/buck2-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
LABELS=($(jq -r '.[]' < labels.json))
if [ ${#LABELS[@]} -eq 0 ]; then
LABELS=("${DEFAULT_LABELS[@]}")
elif [ ${#LABELS[@]} -eq 1 ] && [ "${LABELS[0]}" = "ci" ]; then
LABELS=("${DEFAULT_LABELS[@]}")
fi
for LABEL in "${LABELS[@]}"; do
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,29 @@ jobs:
LABELS=($(jq -r '.[]' < labels.json))
if [ ${#LABELS[@]} -eq 0 ]; then
LABELS=("${DEFAULT_LABELS[@]}")
elif [ ${#LABELS[@]} -eq 1 ] && [ "${LABELS[0]}" = "ci" ]; then
LABELS=("${DEFAULT_LABELS[@]}")
fi
for LABEL in "${LABELS[@]}"; do
case "$LABEL" in
dashboard|consent|pay|core|admin-panel)
ARGS+=" --test $LABEL"
ARGS+=" $LABEL"
;;
esac
done
echo "Prepared args: $ARGS"
echo "args=$ARGS" >> "$GITHUB_OUTPUT"
- name: Tilt CI
- name: Build/start deps and run tests via tilt
if: steps.prepare_args.outputs.args != ''
run: nix develop -c xvfb-run tilt --file dev/Tiltfile ci -- ${{ steps.prepare_args.outputs.args }}
run: nix develop -c xvfb-run ./dev/bin/tilt-ci.sh ${{ steps.prepare_args.outputs.args }}
- name: Rename Tilt log
if: always()
run: mv dev/.e2e-tilt.log dev/e2e-tilt.log
- name: Upload Tilt log
if: always()
uses: actions/upload-artifact@v2
with:
name: Tilt log
path: dev/e2e-tilt.log
2 changes: 1 addition & 1 deletion ci/apps/app-template.lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ plan:
#@ params["GOOGLE_CREDENTIALS"] = "((staging-gcp-creds.creds_json))"
#@ params["SSH_PRIVATE_KEY"] = "((staging-ssh.ssh_private_key))"
#@ params["SSH_PUB_KEY"] = "((staging-ssh.ssh_public_key))"
#@ params["CMD"] = "tilt --file dev/Tiltfile ci -- --test " + app
#@ params["CMD"] = "./dev/bin/tilt-ci.sh " + app
name: #@ tilt_integration_test_name(app)
serial: true
plan:
Expand Down
2 changes: 1 addition & 1 deletion ci/core/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
- #@ build_edge_image(component)
#@ end
- #@ build_edge_image("api", sub_file = "migrate")
- #@ on_nix_host("core-bundle-integration-tests", "api", "tilt --file dev/Tiltfile ci -- --test core")
- #@ on_nix_host("core-bundle-integration-tests", "api", "./dev/bin/tilt-ci.sh core")
- #@ on_nix_host("core-bundle-bats-tests", "api", "bats --setup-suite-file bats/ci_setup_suite.bash -t bats/core/**")
- name: release-core-bundle
plan:
Expand Down
20 changes: 10 additions & 10 deletions dev/Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ PAY_TEST_LABEL = "pay"
ADMIN_PANEL_TEST_LABEL = "admin-panel"

TEST_RESOURCES = {
CORE_TEST_LABEL: "api-test",
CONSENT_TEST_LABEL: "consent-test",
DASHBOARD_TEST_LABEL: "dashboard-test",
PAY_TEST_LABEL: "pay-test",
ADMIN_PANEL_TEST_LABEL: "admin-panel-test"
CORE_TEST_LABEL: "test-api",
CONSENT_TEST_LABEL: "test-consent",
DASHBOARD_TEST_LABEL: "test-dashboard",
PAY_TEST_LABEL: "test-pay",
ADMIN_PANEL_TEST_LABEL: "test-admin-panel"
}

is_ci=("ci" in sys.argv) or cfg.get("bats", False)
Expand Down Expand Up @@ -148,7 +148,7 @@ local_resource(

consent_test_target = "//apps/consent:test-integration"
local_resource(
"consent-test",
"test-consent",
labels = ["test"],
auto_init = is_ci and CONSENT_TEST_LABEL in cfg.get("test", []),
cmd = "buck2 test {}".format(consent_test_target),
Expand All @@ -161,7 +161,7 @@ local_resource(

dashboard_test_target = "//apps/dashboard:test-integration"
local_resource(
"dashboard-test",
"test-dashboard",
labels = ["test"],
auto_init = is_ci and DASHBOARD_TEST_LABEL in cfg.get("test", []),
cmd = "buck2 test {}".format(dashboard_test_target),
Expand All @@ -174,7 +174,7 @@ local_resource(

pay_test_target = "//apps/pay:test-integration"
local_resource(
"pay-test",
"test-pay",
labels = ["test"],
auto_init = is_ci and PAY_TEST_LABEL in cfg.get("test", []),
cmd = "buck2 test {}".format(pay_test_target),
Expand All @@ -187,7 +187,7 @@ local_resource(

admin_panel_test_target = "//apps/admin-panel:test-integration"
local_resource(
"admin-panel-test",
"test-admin-panel",
labels = ["test"],
auto_init = is_ci and ADMIN_PANEL_TEST_LABEL in cfg.get("test", []),
cmd = "buck2 test {}".format(admin_panel_test_target),
Expand Down Expand Up @@ -592,7 +592,7 @@ for service in docker_groups["integration"]:

api_test_target = "//core/api:test-integration"
local_resource(
"api-test",
"test-api",
labels = ["test"],
auto_init = is_ci and CORE_TEST_LABEL in cfg.get("test", []),
cmd = "buck2 test {}".format(api_test_target),
Expand Down
20 changes: 20 additions & 0 deletions dev/bin/tilt-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

REPO_ROOT=$(git rev-parse --show-toplevel)

ARGS_STRING=""
for app in "$@"; do
ARGS_STRING+=" --test $app"
done
IFS=' ' read -r -a ARGS <<< "$ARGS_STRING"

tilt --file "${REPO_ROOT}/dev/Tiltfile" ci -- "${ARGS[@]}" \
| tee "${REPO_ROOT}/dev/.e2e-tilt.log" \
| grep -- '^\s*test-.* │'
status=${PIPESTATUS[0]}

if [[ $status -eq 0 ]]; then
echo "Tilt CI passed"
fi

exit "$status"

0 comments on commit 96c47bb

Please sign in to comment.