Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

test(e2e): add cypress (DSP-468) #4

Merged
merged 20 commits into from
Feb 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.tmp/
node_modules/
4 changes: 4 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ build --workspace_status_command=tools/buildstamp/get_workspace_status --stamp=y
startup --host_jvm_args=-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts \
--host_jvm_args=-Djavax.net.ssl.trustStorePassword=changeit
test --test_output=errors --local_test_jobs=1 --runs_per_test 1


# Required for cypress_repository on macOS
build --experimental_inprocess_symlink_creation
7 changes: 3 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
architecture: 'x64' # defaults to 'x64'
- name: install requirements
run: sudo apt-get install ca-certificates-java expect
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
Expand All @@ -39,8 +39,8 @@ jobs:
${{ runner.OS }}-build-${{ env.cache-name }}-
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Run build everything
run: make build
- name: Run tests
run: make test-e2e

docs:
name: Docs Build Test
Expand Down Expand Up @@ -81,7 +81,6 @@ jobs:
package-name: dsp-tangoh-app
changelog-types: '[{"type": "feat","section": "Enhancements","hidden": false }, {"type": "fix","section": "Bug Fixes","hidden": false }, {"type": "chore","section": "Maintenance","hidden": false }, {"type": "docs","section": "Documentation","hidden": false }]'


# publish only on release
publish:
name: Publish (on release only)
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ dump.rdb
dependencies.txt
/client-test-data.zip
/db_staging_dump.trig

node_modules
4 changes: 2 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package(default_visibility = ["//visibility:public"])



exports_files(["tsconfig.json"])
35 changes: 31 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ build: ## build all targets (excluding docs)
run: ## run app
@bazel run //app

.PHONY: yarn
yarn: ## install dependencies
@bazel run @nodejs//:yarn

.PHONY: cypress-install
cypress-install: yarn ## install dependencies
@bazel run @npm//cypress/cypress:bin -- install

#################################
# Docker targets
#################################
Expand All @@ -58,20 +66,39 @@ docker-build: ## build and publish Tangoh docker image locally
docker-publish: ## publish Tangoh image to Dockerhub
@bazel run //docker:push

#################################
# Integration test targets
#################################

# Clones the knora-api git repository
.PHONY: dsp-stack-clone
dsp-stack-clone:
@git clone --branch main --single-branch --depth 1 https://github.com/dasch-swiss/dsp-api.git $(CURRENT_DIR)/.tmp/dsp-stack

.PHONY: dsp-stack-run
dsp-stack-run: dsp-stack-clone ## runs the dsp-stack
$(MAKE) -C $(CURRENT_DIR)/.tmp/dsp-stack init-db-test
$(MAKE) -C $(CURRENT_DIR)/.tmp/dsp-stack stack-up
$(MAKE) -C $(CURRENT_DIR)/.tmp/dsp-stack stack-logs-api-no-follow

#################################
## Test Targets
#################################

.PHONY: test-docker
test-docker: docker-build ## runs Docker image tests
test-docker: yarn ## runs Docker image tests
bazel test //docker/...

.PHONY: test-app
test-webapi: docker-build ## runs all app tests.
bazel test //app/...
test-app: yarn ## runs all app tests (requires a running dsp-stack).
bazel test //e2e/...

.PHONY: test
test: docker-build ## runs all test targets.
test: yarn ## runs all test targets (requires a running dsp-stack).
bazel test //...

.PHONY: test-e2e
test-e2e: yarn dsp-stack-clone dsp-stack-run ## runs all test targets and starts a dsp-stack.
bazel test //...

#################################
Expand Down
38 changes: 37 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
workspace(name = "io_dasch_dsp_api")
workspace(
name = "io_dasch_dsp_tangoh_app",
managed_directories = {"@npm": ["node_modules"]},
)

# load http_archive method
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
Expand Down Expand Up @@ -60,6 +63,39 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()


#
# download rules_nodejs (javascript)
#
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "dd4dc46066e2ce034cba0c81aa3e862b27e8e8d95871f567359f7a534cccb666",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.1.0/rules_nodejs-3.1.0.tar.gz"],
)

# NOTE: this rule installs nodejs, npm, and yarn, but does NOT install
# your npm dependencies into your node_modules folder.
# You must still run the package manager to do this.
load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories")
node_repositories(
node_version = "14.15.4",
package_json = ["//:package.json"],
)

load("@build_bazel_rules_nodejs//:package.bzl", "rules_nodejs_dev_dependencies")
rules_nodejs_dev_dependencies()

load("@build_bazel_rules_nodejs//:index.bzl", "yarn_install")
yarn_install(
name = "npm",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)

load("@npm//@bazel/cypress:index.bzl", "cypress_repository")

# The name you pass here names the external repository you can load cypress_web_test from
cypress_repository(name = "cypress")

#
# download rules_webtesting (for browser tests of salsah1)
#
Expand Down
70 changes: 35 additions & 35 deletions app/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,38 +65,38 @@ scala_library(
],
)

scala_library(
name = "test_library",
testonly = True,
srcs = [
"//app/src/test/scala/org/knora/salsah:test_srcs",
],
# unused_dependency_checker_mode = "warn",
runtime_deps = [
"@maven//:ch_qos_logback_logback_classic",
"@maven//:ch_qos_logback_logback_core",
"@maven//:com_typesafe_akka_akka_slf4j_2_12",
"@maven//:org_slf4j_log4j_over_slf4j",
],
deps = [
":main_library",
"@io_bazel_rules_webtesting//java/com/google/testing/web",
"@maven//:com_typesafe_akka_akka_actor_2_12",
"@maven//:com_typesafe_akka_akka_http_2_12",
"@maven//:com_typesafe_akka_akka_http_core_2_12",
"@maven//:com_typesafe_akka_akka_stream_2_12",
"@maven//:com_typesafe_config",
"@maven//:org_scalatest_scalatest_2_12",
"@maven//:org_scalatest_scalatest_core_2_12",
"@maven//:org_scalatest_scalatest_wordspec_2_12",
"@maven//:org_scalatest_scalatest_matchers_core_2_12",
"@maven//:org_scalatest_scalatest_shouldmatchers_2_12",
"@maven//:org_scalatest_scalatest_compatible",
"@maven//:org_scalactic_scalactic_2_12",
# Selenium
"@maven//:org_seleniumhq_selenium_selenium_support",
"@org_seleniumhq_selenium_selenium_api", # pulled in by io_bazel_rules_webtesting
"@maven//:org_testcontainers_testcontainers",
"@maven//:junit_junit",
],
)
#scala_library(
# name = "test_library",
# testonly = True,
# srcs = [
# "//app/src/test/scala/org/knora/salsah:test_srcs",
# ],
# # unused_dependency_checker_mode = "warn",
# runtime_deps = [
# "@maven//:ch_qos_logback_logback_classic",
# "@maven//:ch_qos_logback_logback_core",
# "@maven//:com_typesafe_akka_akka_slf4j_2_12",
# "@maven//:org_slf4j_log4j_over_slf4j",
# ],
# deps = [
# ":main_library",
# "@io_bazel_rules_webtesting//java/com/google/testing/web",
# "@maven//:com_typesafe_akka_akka_actor_2_12",
# "@maven//:com_typesafe_akka_akka_http_2_12",
# "@maven//:com_typesafe_akka_akka_http_core_2_12",
# "@maven//:com_typesafe_akka_akka_stream_2_12",
# "@maven//:com_typesafe_config",
# "@maven//:org_scalatest_scalatest_2_12",
# "@maven//:org_scalatest_scalatest_core_2_12",
# "@maven//:org_scalatest_scalatest_wordspec_2_12",
# "@maven//:org_scalatest_scalatest_matchers_core_2_12",
# "@maven//:org_scalatest_scalatest_shouldmatchers_2_12",
# "@maven//:org_scalatest_scalatest_compatible",
# "@maven//:org_scalactic_scalactic_2_12",
# # Selenium
# "@maven//:org_seleniumhq_selenium_selenium_support",
# "@org_seleniumhq_selenium_selenium_api", # pulled in by io_bazel_rules_webtesting
# "@maven//:org_testcontainers_testcontainers",
# "@maven//:junit_junit",
# ],
#)