Add tests for plume webserver (#513)
* begin setup front-end test environment with selenium * run migrations before tests * use https for tests
This commit is contained in:
+72
-19
@@ -1,18 +1,34 @@
|
||||
version: 2.1
|
||||
|
||||
aliases:
|
||||
- &plume-docker
|
||||
image: plumeorg/plume-buildenv:v0.0.5
|
||||
- &defaults
|
||||
docker:
|
||||
- image: plumeorg/plume-buildenv:v0.0.3
|
||||
- *plume-docker
|
||||
working_directory: ~/projects/Plume
|
||||
- &postgresql
|
||||
docker:
|
||||
- image: plumeorg/plume-buildenv:v0.0.3
|
||||
- *plume-docker
|
||||
- image: circleci/postgres:9.6-alpine
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_DB: plume
|
||||
working_directory: ~/projects/Plume
|
||||
- &selenium
|
||||
docker:
|
||||
- *plume-docker
|
||||
- image: elgalu/selenium:latest
|
||||
working_directory: ~/projects/Plume
|
||||
- &postgresql_selenium
|
||||
docker:
|
||||
- *plume-docker
|
||||
- image: circleci/postgres:9.6-alpine
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_DB: plume
|
||||
- image: elgalu/selenium:latest
|
||||
working_directory: ~/projects/Plume
|
||||
|
||||
- &attach_workspace
|
||||
attach_workspace:
|
||||
@@ -25,13 +41,13 @@ aliases:
|
||||
|
||||
- &env_postgresql
|
||||
environment:
|
||||
MIGRATION_DIR: migrations/postgres
|
||||
MIGRATION_DIRECTORY: migrations/postgres
|
||||
FEATURES: postgres
|
||||
DATABASE_URL: postgres://postgres@localhost/plume
|
||||
RUST_TEST_THREADS: 1
|
||||
- &env_sqlite
|
||||
environment:
|
||||
MIGRATION_DIR: migrations/sqlite
|
||||
MIGRATION_DIRECTORY: migrations/sqlite
|
||||
FEATURES: sqlite
|
||||
DATABASE_URL: plume.sqlite3
|
||||
RUST_TEST_THREADS: 1
|
||||
@@ -101,26 +117,48 @@ aliases:
|
||||
name: clippy
|
||||
command: cargo clippy --no-default-features --features="${FEATURES}" --release -p plume-cli -- -D warnings
|
||||
- *save_cache_cli
|
||||
- &test_plume
|
||||
- &test_unit
|
||||
steps:
|
||||
- *attach_workspace
|
||||
- run:
|
||||
name: Set cache key
|
||||
command: echo "$FEATURES" > /FEATURES
|
||||
- run:
|
||||
name: Set compiler flags
|
||||
# rustflags = ["-Clink-dead-code", "-Clink-args=-Xlinker --no-keep-memory -Xlinker --reduce-memory-overheads"]
|
||||
command: echo "W3RhcmdldC54ODZfNjQtdW5rbm93bi1saW51eC1nbnVdCnJ1c3RmbGFncyA9IFsiLUNsaW5rLWRlYWQtY29kZSIsICItQ2xpbmstYXJncz0tWGxpbmtlciAtLW5vLWtlZXAtbWVtb3J5IC1YbGlua2VyIC0tcmVkdWNlLW1lbW9yeS1vdmVyaGVhZHMiXQoK" | base64 -d >> ~/.cargo/config
|
||||
- *restore_cache_plume_dead_code
|
||||
- run:
|
||||
name: clippy
|
||||
command: cargo clippy --no-default-features --features="${FEATURES}" --release -- -D warnings
|
||||
- run:
|
||||
- run:
|
||||
name: compile test
|
||||
command: cargo test --no-default-features --features="${FEATURES}" --all --exclude plume-front --no-run || cargo test --no-default-features --features="${FEATURES}" --all --exclude plume-front --no-run
|
||||
- run:
|
||||
name: run test and upload coverage
|
||||
command: ./script/compute_coverage.sh
|
||||
- run:
|
||||
name: run test
|
||||
command: ./script/run_unit_test.sh
|
||||
- run:
|
||||
name: upload coverage
|
||||
command: ./script/upload_coverage.sh unit
|
||||
- *save_cache_plume_dead_code
|
||||
|
||||
- &test_browser
|
||||
steps:
|
||||
- *attach_workspace
|
||||
- run:
|
||||
name: Set cache key
|
||||
command: echo "$FEATURES" > /FEATURES
|
||||
- *restore_cache_plume_dead_code
|
||||
- run:
|
||||
name: install server
|
||||
command: cargo install --debug --no-default-features --features="${FEATURES}",test --path . || cargo install --debug --no-default-features --features="${FEATURES}",test --path .
|
||||
- run:
|
||||
name: install plm
|
||||
command: cargo install --debug --no-default-features --features="${FEATURES}" --path plume-cli || cargo install --debug --no-default-features --features="${FEATURES}" --path plume-cli
|
||||
- run:
|
||||
name: run test
|
||||
command: ./script/run_browser_test.sh
|
||||
environment:
|
||||
BROWSER: firefox
|
||||
- run:
|
||||
name: upload coverage
|
||||
command: ./script/upload_coverage.sh integration
|
||||
- *save_cache_plume_dead_code
|
||||
|
||||
jobs:
|
||||
@@ -160,16 +198,25 @@ jobs:
|
||||
<<: *env_sqlite
|
||||
<<: *test_cli
|
||||
|
||||
test_plume_postgresql:
|
||||
test_unit_postgresql:
|
||||
<<: *postgresql
|
||||
<<: *env_postgresql
|
||||
<<: *test_plume
|
||||
<<: *test_unit
|
||||
|
||||
test_plume_sqlite:
|
||||
test_unit_sqlite:
|
||||
<<: *defaults
|
||||
<<: *env_sqlite
|
||||
<<: *test_plume
|
||||
<<: *test_unit
|
||||
|
||||
test_browser_postgresql:
|
||||
<<: *postgresql_selenium
|
||||
<<: *env_postgresql
|
||||
<<: *test_browser
|
||||
|
||||
test_browser_sqlite:
|
||||
<<: *selenium
|
||||
<<: *env_sqlite
|
||||
<<: *test_browser
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
@@ -188,9 +235,15 @@ workflows:
|
||||
- test_cli_sqlite:
|
||||
requires:
|
||||
- download_deps
|
||||
- test_plume_postgresql:
|
||||
- test_unit_postgresql:
|
||||
requires:
|
||||
- download_deps
|
||||
- test_plume_sqlite:
|
||||
- test_unit_sqlite:
|
||||
requires:
|
||||
- download_deps
|
||||
- test_browser_postgresql:
|
||||
requires:
|
||||
- build_web
|
||||
- test_browser_sqlite:
|
||||
requires:
|
||||
- build_web
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
localhost:443 {
|
||||
proxy / localhost:7878 {
|
||||
transparent
|
||||
}
|
||||
tls self_signed
|
||||
}
|
||||
@@ -4,16 +4,29 @@ ENV PATH="/root/.cargo/bin:${PATH}"
|
||||
#install native/circleci/build dependancies
|
||||
RUN apt update &&\
|
||||
apt install -y git ssh tar gzip ca-certificates &&\
|
||||
apt install -y binutils-dev build-essential cmake curl gcc gettext git libcurl4-openssl-dev libdw-dev libelf-dev libiberty-dev libpq-dev libsqlite3-dev libssl-dev make openssl pkg-config postgresql postgresql-contrib python zlib1g-dev
|
||||
apt install -y binutils-dev build-essential cmake curl gcc gettext git libcurl4-openssl-dev libdw-dev libelf-dev libiberty-dev libpq-dev libsqlite3-dev libssl-dev make openssl pkg-config postgresql postgresql-contrib python zlib1g-dev python3-pip
|
||||
|
||||
#install and configure rust
|
||||
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2019-03-23 -y &&\
|
||||
rustup component add rustfmt clippy &&\
|
||||
rustup component add rust-std --target wasm32-unknown-unknown &&\
|
||||
cargo install cargo-web &&\
|
||||
rustup component add rust-std --target wasm32-unknown-unknown
|
||||
|
||||
#compile some deps
|
||||
RUN cargo install cargo-web &&\
|
||||
cargo install diesel_cli --no-default-features --features postgres,sqlite --version '=1.3.0' &&\
|
||||
rm -fr ~/.cargo/registry
|
||||
|
||||
#install coverage tools
|
||||
RUN curl -L https://github.com/SimonKagstrom/kcov/archive/master.tar.gz | tar xz &&\
|
||||
mkdir -p kcov-master/build && cd kcov-master/build && cmake .. && make &&\
|
||||
make install && cd ../.. && rm -rf kcov-master
|
||||
|
||||
#set some compilation parametters
|
||||
COPY cargo_config /root/.cargo/config
|
||||
|
||||
#install selenium for front end tests
|
||||
RUN pip3 install selenium
|
||||
|
||||
#install and configure caddy
|
||||
RUN curl https://getcaddy.com | bash -s personal
|
||||
COPY Caddyfile /Caddyfile
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[target.x86_64-unknown-linux-gnu]
|
||||
# link dead code for coverage, attempt to reduce linking memory usage to not get killed
|
||||
rustflags = ["-Clink-dead-code", "-Clink-args=-Xlinker --no-keep-memory -Xlinker --reduce-memory-overheads"]
|
||||
Reference in New Issue
Block a user