Skip to content

Commit bbd993d

Browse files
committed
test.yml: add end-to-end test workflow
Signed-off-by: Victoria Dye <[email protected]>
1 parent 814bcd7 commit bbd993d

File tree

4 files changed

+99
-1
lines changed

4 files changed

+99
-1
lines changed

.github/workflows/test.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: End-to-end test
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
test-perf:
8+
type: boolean
9+
description: 'Whether to run the (slow) end-to-end perf tests'
10+
default: false
11+
12+
jobs:
13+
e2e-test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Setup Go
18+
uses: actions/setup-go@v3
19+
with:
20+
go-version: 'stable'
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: 18
26+
27+
- name: Clone repository
28+
uses: actions/checkout@v3
29+
30+
- name: Install system dependencies for end-to-end tests
31+
run: build/ci/install-dependencies.sh
32+
shell: bash
33+
34+
- name: Enable perf tests
35+
if: ${{ github.event.inputs.test-perf }}
36+
run: echo "TEST_E2E_PERF=1" >> $GITHUB_ENV
37+
38+
- name: Run end-to-end tests
39+
env:
40+
TEST_E2E_PERF: ${{matrix.jobs.goarch}}
41+
run: make e2e-test TEST_E2E_PERF="$TEST_E2E_PERF"

Makefile

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ INSTALL_ROOT := /
1313
BINDIR := $(CURDIR)/bin
1414
DISTDIR := $(CURDIR)/_dist
1515
DOCDIR := $(CURDIR)/_docs
16+
TESTDIR := $(CURDIR)/_test
1617

1718
# Platform information
1819
GOOS := $(shell go env GOOS)
@@ -22,6 +23,9 @@ GOARCH := $(shell go env GOARCH)
2223
SUPPORTED_PACKAGE_GOARCHES := amd64 arm64
2324
PACKAGE_ARCH := $(GOARCH)
2425

26+
# Guard against environment variables
27+
TEST_E2E_PERF=
28+
2529
# Build targets
2630
.PHONY: build
2731
build:
@@ -38,7 +42,13 @@ doc:
3842
.PHONY: e2e-test
3943
e2e-test: build
4044
@echo
41-
@scripts/ci/install-dependencies.sh
45+
@echo "======== Running end-to-end tests ========"
46+
$(RM) -r $(TESTDIR)
47+
@if [ -n "$(TEST_E2E_PERF)" ]; then \
48+
./scripts/run-e2e-tests.sh --all; \
49+
else \
50+
./scripts/run-e2e-tests.sh; \
51+
fi
4252

4353
# Installation targets
4454
.PHONY: install
@@ -141,3 +151,4 @@ clean:
141151
$(RM) -r $(BINDIR)
142152
$(RM) -r $(DISTDIR)
143153
$(RM) -r $(DOCDIR)
154+
$(RM) -r $(TESTDIR)

build/ci/install-dependencies.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
die () {
3+
echo "$*" >&2
4+
exit 1
5+
}
6+
7+
# Exit as soon as any line fails
8+
set -e
9+
10+
# Install latest version of Git (minimum v2.40)
11+
if command -v apt-get; then
12+
sudo apt-get -q -y install git
13+
elif command -v brew; then
14+
else
15+
brew install git
16+
die 'Cannot install git'
17+
fi

scripts/run-e2e-tests.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
THISDIR="$( cd "$(dirname "$0")" ; pwd -P )"
4+
TESTDIR="$THISDIR/../test/e2e"
5+
6+
# Defaults
7+
NPM_TARGET="test"
8+
9+
# Parse script arguments
10+
for i in "$@"
11+
do
12+
case "$i" in
13+
--all)
14+
NPM_TARGET="test-all"
15+
shift # past argument
16+
;;
17+
*)
18+
die "unknown option '$i'"
19+
;;
20+
esac
21+
done
22+
23+
# Exit as soon as any line fails
24+
set -e
25+
26+
cd "$TESTDIR"
27+
28+
npm install
29+
npm run $NPM_TARGET

0 commit comments

Comments
 (0)