From 26fc2cde5da0ea8ac5b3d753d7b603929ca91acc Mon Sep 17 00:00:00 2001 From: fdb-hiroshima <35889323+fdb-hiroshima@users.noreply.github.com> Date: Mon, 1 Apr 2019 20:28:23 +0200 Subject: [PATCH] use circleci instead of travis (#511) Upgrade rust-toolchain Upgrade Tantivy Warning: tantivy now use a different file format, search index may need to be deleted and recreated to work as intended try to run compile twice in a row because sometime oomk is evil --- .circleci/config.yml | 196 ++++++++++++++++++ .circleci/images/plume-buildenv/Dockerfile | 19 ++ .../images/plume-buildenv/build_and_push.sh | 4 + .travis.yml | 79 ------- Cargo.lock | 76 ++++--- plume-common/src/utils.rs | 2 +- plume-models/Cargo.toml | 2 +- plume-models/src/follows.rs | 2 +- plume-models/src/medias.rs | 2 +- plume-models/src/search/query.rs | 2 +- plume-models/src/search/searcher.rs | 22 +- rust-toolchain | 2 +- script/compute_coverage.sh | 16 +- src/routes/instance.rs | 4 +- src/routes/search.rs | 4 +- src/routes/session.rs | 2 +- 16 files changed, 295 insertions(+), 139 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 .circleci/images/plume-buildenv/Dockerfile create mode 100755 .circleci/images/plume-buildenv/build_and_push.sh delete mode 100644 .travis.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..966c867 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,196 @@ +version: 2.1 + +aliases: + - &defaults + docker: + - image: plumeorg/plume-buildenv:v0.0.3 + working_directory: ~/projects/Plume + - &postgresql + docker: + - image: plumeorg/plume-buildenv:v0.0.3 + - image: circleci/postgres:9.6-alpine + environment: + POSTGRES_USER: postgres + POSTGRES_DB: plume + working_directory: ~/projects/Plume + + - &attach_workspace + attach_workspace: + at: ~/projects/Plume/ + - &persist_to_workspace + persist_to_workspace: + root: ~/projects/Plume/ + paths: + - ./ + + - &env_postgresql + environment: + MIGRATION_DIR: migrations/postgres + FEATURES: postgres + DATABASE_URL: postgres://postgres@localhost/plume + RUST_TEST_THREADS: 1 + - &env_sqlite + environment: + MIGRATION_DIR: migrations/sqlite + FEATURES: sqlite + DATABASE_URL: plume.sqlite3 + RUST_TEST_THREADS: 1 + + - &restore_cache + restore_cache: + keys: + - v1-plume-notest-{{ checksum "Cargo.lock" }} + - v1-plume-notest + - &save_cache + save_cache: + key: v1-plume-notest-{{ checksum "Cargo.lock" }} + paths: + - ~/.cargo/ + - ./target + + - &restore_cache_web + restore_cache: + keys: + - v1-plume-web-{{ checksum "Cargo.lock" }} + - v1-plume-web + - &save_cache_web + save_cache: + key: v1-plume-web-{{ checksum "Cargo.lock" }} + paths: + - ~/.cargo/ + - ./target + + - &restore_cache_cli + restore_cache: + keys: + - v1-plume-notest-{{ checksum "Cargo.lock" }}-{{ checksum "/FEATURES" }}-cli + - v1-plume-notest-{{ checksum "Cargo.lock" }}-{{ checksum "/FEATURES" }} + - v1-plume-notest-{{ checksum "Cargo.lock" }} + - v1-plume-notest + - &save_cache_cli + save_cache: + key: v1-plume-notest-{{ checksum "Cargo.lock" }}-{{ checksum "/FEATURES" }}-cli + paths: + - ~/.cargo/ + - target + + - &restore_cache_plume_dead_code + restore_cache: + keys: + - v1-plume-test-{{ checksum "/FEATURES" }}-{{ checksum "Cargo.lock" }}-plume + - v1-plume-test-{{ checksum "/FEATURES" }}-{{ checksum "Cargo.lock" }} + - v1-plume-test-{{ checksum "/FEATURES" }} + - v1-plume-notest-{{ checksum "Cargo.lock" }}-{{ checksum "/FEATURES" }} + - v1-plume-notest-{{ checksum "Cargo.lock" }} + - v1-plume-notest + - &save_cache_plume_dead_code + save_cache: + key: v1-plume-test-{{ checksum "/FEATURES" }}-{{ checksum "Cargo.lock" }}-plume + paths: + - ~/.cargo/ + - target + + - &test_cli + steps: + - *attach_workspace + - run: + name: Set cache key + command: echo "$FEATURES" > /FEATURES + - *restore_cache_cli + - run: + name: clippy + command: cargo clippy --no-default-features --features="${FEATURES}" --release -p plume-cli -- -D warnings + - *save_cache_cli + - &test_plume + 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: + 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 + - *save_cache_plume_dead_code + +jobs: + download_deps: + <<: *defaults + steps: + - checkout + - *attach_workspace + - *restore_cache + - run: cargo fetch + - *save_cache + - *persist_to_workspace + + cargo_fmt: + <<: *defaults + steps: + - *attach_workspace + - run: cargo fmt --all -- --check + + build_web: + <<: *defaults + steps: + - *attach_workspace + - *restore_cache_web + - run: cargo clippy -p plume-front -- -D warnings + - run: cargo web deploy -p plume-front + - *save_cache_web + - *persist_to_workspace + + test_cli_postgresql: + <<: *postgresql + <<: *env_postgresql + <<: *test_cli + + test_cli_sqlite: + <<: *defaults + <<: *env_sqlite + <<: *test_cli + + test_plume_postgresql: + <<: *postgresql + <<: *env_postgresql + <<: *test_plume + + test_plume_sqlite: + <<: *defaults + <<: *env_sqlite + <<: *test_plume + + +workflows: + version: 2 + build_and_test: + jobs: + - download_deps + - cargo_fmt: + requires: + - download_deps + - build_web: + requires: + - download_deps + - test_cli_postgresql: + requires: + - download_deps + - test_cli_sqlite: + requires: + - download_deps + - test_plume_postgresql: + requires: + - download_deps + - test_plume_sqlite: + requires: + - download_deps diff --git a/.circleci/images/plume-buildenv/Dockerfile b/.circleci/images/plume-buildenv/Dockerfile new file mode 100644 index 0000000..465c760 --- /dev/null +++ b/.circleci/images/plume-buildenv/Dockerfile @@ -0,0 +1,19 @@ +FROM debian:stretch-20190326 +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 + +#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 &&\ + 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 diff --git a/.circleci/images/plume-buildenv/build_and_push.sh b/.circleci/images/plume-buildenv/build_and_push.sh new file mode 100755 index 0000000..4d59709 --- /dev/null +++ b/.circleci/images/plume-buildenv/build_and_push.sh @@ -0,0 +1,4 @@ +#!/bin/bash +[ "$1" = "" ] && echo "you must provide one argument, the build version" && exit 1 +docker build -t plumeorg/plume-buildenv:$1 . +docker push plumeorg/plume-buildenv:$1 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b6f79c0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,79 +0,0 @@ -language: rust -rust: - - nightly-2018-12-06 -cache: - cargo: true - directories: - - kcov-master -sudo: true -dist: trusty -services: postgres - -addons: - apt: - packages: - - libcurl4-openssl-dev - - libelf-dev - - libdw-dev - - cmake - - gcc - - binutils-dev - - zlib1g-dev - - libiberty-dev -stages: - - build - - test and coverage -jobs: - include: - - stage: build - name: "Build front" - script: (cargo web -h || cargo install cargo-web) && cd plume-front && cargo clippy -- -D warnings && cargo web check - before_script: rustup component add clippy - - - stage: build - name: "Build with postgresql" - env: - - MIGRATION_DIR=migrations/postgres FEATURES=postgres DATABASE_URL=postgres://postgres@localhost/plume - script: cargo clippy --no-default-features --features="${FEATURES}" --release -- -D warnings - before_script: rustup component add clippy - - - stage: build - name: "Build CLI with postgresql" - env: - - MIGRATION_DIR=migrations/postgres FEATURES=postgres DATABASE_URL=postgres://postgres@localhost/plume - script: cd plume-cli && cargo clippy --no-default-features --features="${FEATURES}" --release -- -D warnings - before_script: rustup component add clippy - - stage: build - name: "Build with sqlite" - env: - - MIGRATION_DIR=migrations/sqlite FEATURES=sqlite DATABASE_URL=plume.sqlite3 - script: cargo clippy --no-default-features --features="${FEATURES}" --release -- -D warnings - before_script: rustup component add clippy - - - stage: build - name: "Build CLI with sqlite" - env: - - MIGRATION_DIR=migrations/sqlite FEATURES=sqlite DATABASE_URL=plume.sqlite3 - script: cd plume-cli && cargo clippy --no-default-features --features="${FEATURES}" --release -- -D warnings - before_script: rustup component add clippy - - - stage: test and coverage - name: "Test with potgresql backend" - env: - - MIGRATION_DIR=migrations/postgres FEATURES=postgres DATABASE_URL=postgres://postgres@localhost/plume_tests - - RUSTFLAGS='-C link-dead-code' RUST_TEST_THREADS=1 - before_script: psql -c 'create database plume_tests;' -U postgres - script: - - | - cargo test --features "${FEATURES}" --no-default-features --all --exclude plume-front && - ./script/compute_coverage.sh - - - stage: test and coverage - name: "Test with Sqlite backend" - env: - - MIGRATION_DIR=migrations/sqlite FEATURES=sqlite DATABASE_URL=plume.sqlite3 - - RUSTFLAGS='-C link-dead-code' RUST_TEST_THREADS=1 - script: - - | - cargo test --features "${FEATURES}" --no-default-features --all --exclude plume-front && - ./script/compute_coverage.sh diff --git a/Cargo.lock b/Cargo.lock index 5fdc20d..8b00716 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -252,7 +252,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bitpacking" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -329,7 +329,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "census" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -678,8 +678,8 @@ dependencies = [ ] [[package]] -name = "downcast" -version = "0.9.2" +name = "downcast-rs" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -850,6 +850,15 @@ name = "foreign-types-shared" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "fsevent" version = "0.2.17" @@ -874,17 +883,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fst-regex" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1379,7 +1377,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memmap" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1899,7 +1897,7 @@ dependencies = [ "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "tantivy 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tantivy 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "webfinger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "whatlang 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2182,7 +2180,7 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.3.9" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2727,23 +2725,23 @@ dependencies = [ [[package]] name = "tantivy" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atomicwrites 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "bit-set 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitpacking 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitpacking 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "census 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "census 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "combine 3.6.7 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "downcast 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", + "downcast-rs 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fail 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", - "fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fst-regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "htmlescape 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2751,8 +2749,9 @@ dependencies = [ "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "levenshtein_automata 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "murmurhash32 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "notify 4.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "owned-read 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2764,12 +2763,24 @@ dependencies = [ "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", "snap 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tantivy-fst 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tantivy-fst" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "levenshtein_automata 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tempdir" version = "0.3.7" @@ -3272,7 +3283,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum bit-vec 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4440d5cb623bb7390ae27fec0bb6c61111969860f8e3ae198bfa0663645e67cf" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum bitpacking 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "75c04b83d2b444a22c6a30f4d068597efbe468fe56f068e042e627ded2fb21e7" +"checksum bitpacking 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "667f3f518358b2cf64891b46a6dd2eb794e9f80d39f7eb5974f4784bcda9a61b" "checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" "checksum blowfish 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6aeb80d00f2688459b8542068abd974cfb101e7a82182414a99b5026c0d85cc3" "checksum buf_redux 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72f25c67abbf523ff8457771622fb731ac4a2391439de33bc60febcdee1749c9" @@ -3283,7 +3294,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "40ade3d27603c2cb345eb0912aec461a6dec7e06a4ae48589904e808335c7afa" "checksum canapi 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aab4d6d1edcef8bf19b851b7730d3d1a90373c06321a49a984baebe0989c962c" "checksum cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "d01c69d08ff207f231f07196e30f84c70f1c815b04f980f8b7b01ff01f05eb92" -"checksum census 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e5c044df9888597e4e96610c916ce9d58c653b67c01b5eac5b7abd7405f4fee4" +"checksum census 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "641317709904ba3c1ad137cb5d88ec9d8c03c07de087b2cff5e84ec565c7e299" "checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" "checksum chomp 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9f74ad218e66339b11fd23f693fb8f1d621e80ba6ac218297be26073365d163d" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" @@ -3322,7 +3333,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum diesel_migrations 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3cde8413353dc7f5d72fa8ce0b99a560a359d2c5ef1e5817ca731cd9008f4c" "checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" "checksum dotenv 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d0a1279c96732bc6800ce6337b6a614697b0e74ae058dc03c62ebeb78b4d86" -"checksum downcast 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6c6fe31318b6ef21166c8e839e680238eb16f875849d597544eead7ec882eed3" +"checksum downcast-rs 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "18df8ce4470c189d18aa926022da57544f31e154631eb4cfe796aea97051fe6c" "checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" "checksum either 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a39bffec1e2015c5d8a6773cb0cf48d0d758c842398f624c34969071f5499ea7" "checksum either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c67353c641dc847124ea1902d69bd753dee9bb3beff9aa3662ecf86c971d1fac" @@ -3344,10 +3355,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +"checksum fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" "checksum fsevent 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c4bbbf71584aeed076100b5665ac14e3d85eeb31fdbb45fbd41ef9a682b5ec05" "checksum fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1a772d36c338d07a032d5375a36f15f9a7043bf0cb8ce7cee658e037c6032874" "checksum fst 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "db72126ca7dff566cdbbdd54af44668c544897d9d3862b198141f176f1238bdf" -"checksum fst-regex 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "87aca1d91eed3c128132cee31d291fd4e8492df0b742a5b1453857a4c7cedd88" "checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" @@ -3403,7 +3414,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum md5 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e6bcd6433cff03a4bfc3d9834d504467db1f1cf6d0ea765d37d330249ed629d" "checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" -"checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" +"checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum migrations_internals 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8089920229070f914b9ce9b07ef60e175b2b9bc2d35c3edd8bf4433604e863b9" "checksum migrations_macros 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1664412abf7db2b8a6d58be42a38b099780cc542b5b350383b805d88932833fe" @@ -3477,7 +3488,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum regex 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53ee8cfdddb2e0291adfb9f13d31d3bbe0a03c9a402c01b1e24188d86c35b24f" -"checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" +"checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" "checksum regex-syntax 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8c2f35eedad5295fdf00a63d7d4b238135723f92b434ec06774dad15c7ab0861" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum rental 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ca24bf9b98e3df0bb359f1bbb8ef993a0093d8432500c5eaf3ae724f30b5f754" @@ -3536,7 +3547,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" = "525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" -"checksum tantivy 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a08552afc58ea5a6395a087ce21c112b7de2b843d36f6fbd8df5c6f9ff63c8b5" +"checksum tantivy 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "67a63475a55950ad47573f881d912b8fab7f1f53a9cc2e036185efc92b471402" +"checksum tantivy-fst 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16b22af5ff09b8897093287642a5aaee6f30eb496526ef83a8dd0f4c636ac367" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "b86c784c88d98c801132806dadd3819ed29d8600836c4088e855cdf3e178ed8a" "checksum tendril 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "707feda9f2582d5d680d733e38755547a3e8fb471e7ba11452ecfd9ce93a5d3b" diff --git a/plume-common/src/utils.rs b/plume-common/src/utils.rs index 2faf2e3..ac37c92 100644 --- a/plume-common/src/utils.rs +++ b/plume-common/src/utils.rs @@ -82,7 +82,7 @@ pub fn md_to_html( *state = s; Some(res) }) - .flat_map(|v| v.into_iter()) + .flat_map(IntoIterator::into_iter) // Ignore headings, images, and tables if inline = true .scan(vec![], |state: &mut Vec, evt| { if inline { diff --git a/plume-models/Cargo.toml b/plume-models/Cargo.toml index ba899cc..6183216 100644 --- a/plume-models/Cargo.toml +++ b/plume-models/Cargo.toml @@ -20,7 +20,7 @@ scheduled-thread-pool = "0.2.0" serde = "1.0" serde_derive = "1.0" serde_json = "1.0" -tantivy = "0.8.2" +tantivy = "0.9.1" url = "1.7" webfinger = "0.3.1" whatlang = "0.7.0" diff --git a/plume-models/src/follows.rs b/plume-models/src/follows.rs index 496585b..52c4b66 100644 --- a/plume-models/src/follows.rs +++ b/plume-models/src/follows.rs @@ -114,7 +114,7 @@ impl FromActivity for Follow { let from_id = follow .follow_props .actor_link::() - .map(|l| l.into()) + .map(Into::into) .or_else(|_| { Ok(follow .follow_props diff --git a/plume-models/src/medias.rs b/plume-models/src/medias.rs index 49962a4..c152246 100644 --- a/plume-models/src/medias.rs +++ b/plume-models/src/medias.rs @@ -189,7 +189,7 @@ impl Media { let ext = remote_url .rsplit('.') .next() - .map(|ext| ext.to_owned()) + .map(ToOwned::to_owned) .unwrap_or_else(|| String::from("png")); let path = Path::new("static") diff --git a/plume-models/src/search/query.rs b/plume-models/src/search/query.rs index 8c815c2..9e1e997 100644 --- a/plume-models/src/search/query.rs +++ b/plume-models/src/search/query.rs @@ -258,7 +258,7 @@ impl PlumeQuery { // refactor this better. #[allow(clippy::wrong_self_convention)] fn from_str_req(&mut self, mut query: &str) -> &mut Self { - query = query.trim_left(); + query = query.trim_start(); if query.is_empty() { return self; } diff --git a/plume-models/src/search/searcher.rs b/plume-models/src/search/searcher.rs index 2fa6fc2..4433cb7 100644 --- a/plume-models/src/search/searcher.rs +++ b/plume-models/src/search/searcher.rs @@ -7,7 +7,8 @@ use chrono::Datelike; use itertools::Itertools; use std::{cmp, fs::create_dir_all, path::Path, sync::Mutex}; use tantivy::{ - collector::TopDocs, directory::MmapDirectory, schema::*, tokenizer::*, Index, IndexWriter, Term, + collector::TopDocs, directory::MmapDirectory, schema::*, tokenizer::*, Index, IndexReader, + IndexWriter, ReloadPolicy, Term, }; use whatlang::{detect as detect_lang, Lang}; @@ -25,6 +26,7 @@ pub enum SearcherError { pub struct Searcher { index: Index, + reader: IndexReader, writer: Mutex>, } @@ -50,8 +52,8 @@ impl Searcher { let mut schema_builder = SchemaBuilder::default(); - schema_builder.add_i64_field("post_id", INT_STORED | INT_INDEXED); - schema_builder.add_i64_field("creation_date", INT_INDEXED); + schema_builder.add_i64_field("post_id", STORED | INDEXED); + schema_builder.add_i64_field("creation_date", INDEXED); schema_builder.add_text_field("instance", tag_indexing.clone()); schema_builder.add_text_field("author", tag_indexing.clone()); @@ -98,6 +100,11 @@ impl Searcher { .writer(50_000_000) .map_err(|_| SearcherError::WriteLockAcquisitionError)?, )), + reader: index + .reader_builder() + .reload_policy(ReloadPolicy::Manual) + .try_into() + .map_err(|_| SearcherError::IndexCreationError)?, index, }) } @@ -129,6 +136,11 @@ impl Searcher { .map_err(|_| SearcherError::IndexEditionError)?; Ok(Self { writer: Mutex::new(Some(writer)), + reader: index + .reader_builder() + .reload_policy(ReloadPolicy::Manual) + .try_into() + .map_err(|_| SearcherError::IndexCreationError)?, index, }) } @@ -195,7 +207,7 @@ impl Searcher { let collector = TopDocs::with_limit(cmp::max(1, max) as usize); - let searcher = self.index.searcher(); + let searcher = self.reader.searcher(); let res = searcher.search(&query.into_query(), &collector).unwrap(); res.get(min as usize..) @@ -213,7 +225,7 @@ impl Searcher { pub fn commit(&self) { let mut writer = self.writer.lock().unwrap(); writer.as_mut().unwrap().commit().unwrap(); - self.index.load_searchers().unwrap(); + self.reader.reload().unwrap(); } pub fn drop_writer(&self) { diff --git a/rust-toolchain b/rust-toolchain index 2ac19a8..f8862e1 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2018-12-06 +nightly-2019-03-23 diff --git a/script/compute_coverage.sh b/script/compute_coverage.sh index 33a45b0..9ed4c5b 100755 --- a/script/compute_coverage.sh +++ b/script/compute_coverage.sh @@ -1,12 +1,5 @@ -#!/bin/bash -wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && -tar xzf master.tar.gz && -mkdir -p kcov-master/build && -cd kcov-master/build && -cmake .. && -make && -sudo make install && -cd ../.. && +#!/bin/bash +set -eo pipefail for file in target/debug/*-*[^\.d]; do if [[ -x "$file" ]] then @@ -14,6 +7,5 @@ for file in target/debug/*-*[^\.d]; do mkdir -p "target/cov/$filename" kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$filename" "$file" fi -done && -bash <(curl -s https://codecov.io/bash) && -echo "Uploaded code coverage" +done +bash <(curl -s https://codecov.io/bash) diff --git a/src/routes/instance.rs b/src/routes/instance.rs index 8fb97ad..c68ec71 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -11,9 +11,9 @@ use inbox::{Inbox, SignedJson}; use plume_common::activity_pub::sign::{verify_http_headers, Signable}; use plume_models::{ admin::Admin, comments::Comment, db_conn::DbConn, headers::Headers, instance::*, posts::Post, - safe_string::SafeString, users::User, Error, CONFIG + safe_string::SafeString, users::User, Error, CONFIG, }; -use routes::{errors::ErrorPage, Page, rocket_uri_macro_static_files}; +use routes::{errors::ErrorPage, rocket_uri_macro_static_files, Page}; use template_utils::Ructe; use Searcher; diff --git a/src/routes/search.rs b/src/routes/search.rs index d9d2788..7337929 100644 --- a/src/routes/search.rs +++ b/src/routes/search.rs @@ -59,10 +59,10 @@ pub fn search( user: Option, intl: I18n, ) -> Ructe { - let query = query.map(|f| f.into_inner()).unwrap_or_default(); + let query = query.map(Form::into_inner).unwrap_or_default(); let page = query.page.unwrap_or_default(); let mut parsed_query = - Query::from_str(&query.q.as_ref().map(|q| q.as_str()).unwrap_or_default()) + Query::from_str(&query.q.as_ref().map(String::as_str).unwrap_or_default()) .unwrap_or_default(); param_to_query!(query, parsed_query; normal: title, subtitle, content, tag, diff --git a/src/routes/session.rs b/src/routes/session.rs index d5da53e..6b27e58 100644 --- a/src/routes/session.rs +++ b/src/routes/session.rs @@ -95,7 +95,7 @@ pub fn create( .unwrap_or_else(|| "/".to_owned()); let uri = Uri::parse(&destination) - .map(|x| x.into_owned()) + .map(IntoOwned::into_owned) .map_err(|_| { render!(session::login( &(&*conn, &intl.catalog, None),