From 09e02f0521f966dde5da84eccaf36344373486ab Mon Sep 17 00:00:00 2001 From: Roman Kalnytskyi Date: Mon, 28 Jun 2021 23:10:06 +0300 Subject: [PATCH] Add crystal 1.0.0 support --- .github/workflows/ci.yml | 47 +++++++++++++++++++++++++++++++++ .travis.yml | 20 -------------- sam.cr | 9 +++---- script/runner.cr | 6 ----- shard.yml | 8 +++--- spec/config.cr | 8 +++--- spec/hermes/persistence_spec.cr | 26 +++++++++--------- src/hermes.cr | 2 +- src/hermes/search_response.cr | 1 - 9 files changed, 72 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml delete mode 100644 script/runner.cr diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..32c8869 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +name: CI + +on: + push: + schedule: + - cron: "0 7 * * 1" + +jobs: + test: + strategy: + fail-fast: false + + runs-on: ubuntu-latest + + steps: + - name: Install Crystal + uses: oprypin/install-crystal@v1 + + - name: Donwload sources + uses: actions/checkout@v2 + + - name: Check formatting + run: crystal tool format --check + + - name: Install dependencies + run: shards install + + - name: Run linter + run: ./bin/ameba + + - name: Configure sysctl limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + + - name: Runs Elasticsearch + uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: 7.6.0 + + - name: Run migrations + run: crystal sam.cr es:index:create_all + + - name: Run specs + run: crystal spec diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f04d146..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: crystal -dist: xenial -sudo: true -addons: - apt: - packages: - - openjdk-8-jdk - - openjdk-8-jre -services: - - elasticsearch -before_script: - - sleep 10 - - crystal ./script/runner.cr es:index:create_all -script: - - ./bin/ameba - - crystal spec - -notifications: - on_failure: never - on_success: never diff --git a/sam.cr b/sam.cr index 62862e8..f3198f0 100644 --- a/sam.cr +++ b/sam.cr @@ -1,9 +1,6 @@ +require "./src/hermes" +require "./spec/config" require "sam" - -# Here you can define your tasks -# desc "with description to be used by help command" -# task "test" do -# puts "ping" -# end +require "./src/sam" Sam.help diff --git a/script/runner.cr b/script/runner.cr deleted file mode 100644 index 835cdc2..0000000 --- a/script/runner.cr +++ /dev/null @@ -1,6 +0,0 @@ -require "../src/hermes" -require "../spec/config" -require "sam" -require "../src/sam" - -Sam.help diff --git a/shard.yml b/shard.yml index 3e9d4bd..b56ca50 100644 --- a/shard.yml +++ b/shard.yml @@ -1,16 +1,16 @@ name: hermes -version: 0.3.0 +version: 0.3.1 authors: - Roman Kalnytskyi -crystal: 0.35.1 +crystal: ">= 0.35.1" license: MIT development_dependencies: sam: github: imdrasil/sam.cr - version: "~> 0.3.0" + version: "~> 0.4.1" ameba: github: crystal-ameba/ameba - version: "= 0.12.1" + version: "= 0.14.3" diff --git a/spec/config.cr b/spec/config.cr index 6129dd2..400ad8f 100644 --- a/spec/config.cr +++ b/spec/config.cr @@ -62,10 +62,10 @@ class TestUserIndex < Hermes::Index index_name "test_user_index" config({ user: { - properties: { - full_name: {type: "text"}, - location: {type: "geo_point"}, - photo: {type: "binary"}, + properties: { + full_name: {type: "text"}, + location: {type: "geo_point"}, + photo: {type: "binary"}, }, }, }) diff --git a/spec/hermes/persistence_spec.cr b/spec/hermes/persistence_spec.cr index e211b4e..1bc1ebe 100644 --- a/spec/hermes/persistence_spec.cr +++ b/spec/hermes/persistence_spec.cr @@ -17,13 +17,13 @@ describe Hermes::Persistent do post = build_post hash = post.to_hash hash.should eq({ - "title" => post.title, - "likes" => post.likes, - "user" => post.user, - "text" => post.text, - "tag" => post.tag, - "created_at" => post.created_at, - "non_existing_field" => nil + "title" => post.title, + "likes" => post.likes, + "user" => post.user, + "text" => post.text, + "tag" => post.tag, + "created_at" => post.created_at, + "non_existing_field" => nil, }) end end @@ -33,13 +33,13 @@ describe Hermes::Persistent do post = build_post hash = post.to_json hash.should eq({ - "title" => post.title, - "likes" => post.likes, - "user" => post.user, - "text" => post.text, - "tag" => post.tag, + "title" => post.title, + "likes" => post.likes, + "user" => post.user, + "text" => post.text, + "tag" => post.tag, "created_at" => post.created_at, - }.to_json) + }.to_json) end end end diff --git a/src/hermes.cr b/src/hermes.cr index efb01f6..64c7e01 100644 --- a/src/hermes.cr +++ b/src/hermes.cr @@ -13,7 +13,7 @@ require "./hermes/client" require "./hermes/*" module Hermes - VERSION = "0.3.0" + VERSION = "0.3.1" def self.status client.get("/") diff --git a/src/hermes/search_response.cr b/src/hermes/search_response.cr index b1edfa3..d58a0c6 100644 --- a/src/hermes/search_response.cr +++ b/src/hermes/search_response.cr @@ -34,7 +34,6 @@ module Hermes @[JSON::Field(key: "total")] property total : Int32 | Hash(String, JSON::Any) - @[JSON::Field(key: "max_score")] property max_score : Float32?