diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..983dc67 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: CI + +on: + push: + pull_request: + schedule: + - cron: "0 3 * * 1" # Every monday at 3 AM + +jobs: + test: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + crystal: [latest, nightly] + runs-on: ${{ matrix.os }} + + steps: + - name: Install Crystal + uses: oprypin/install-crystal@v1 + with: + crystal: ${{ matrix.crystal }} + + - name: Download source + uses: actions/checkout@v2 + + - name: Install dependencies + run: shards install + env: + SHARDS_OPTS: --ignore-crystal-version + + - name: Run specs + run: | + crystal spec + crystal spec --release --no-debug + + - name: Check formatting + run: crystal tool format --check + + - name: Run ameba linter + run: bin/ameba diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9883f5e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: crystal -crystal: - - latest - - nightly - -script: - - crystal spec - - crystal spec --release --no-debug - - crystal tool format --check - - bin/ameba src - -matrix: - allow_failures: - - crystal: nightly diff --git a/CHANGELOG.md b/CHANGELOG.md index 48d21fa..c3949fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 1.0.0 (??-03-2021) + +- Crystal 1.0.0 support :tada: +- Update Radix to use latest 0.4.0 [#596](https://github.com/kemalcr/kemal/pull/596). Thanks @luislavena :pray: +- Use latest version of Ameba dependency (dev) [#597](https://github.com/kemalcr/kemal/pull/597). Thanks @luislavena :pray: +- Fix StaticFileHandler failing spec [#599](https://github.com/kemalcr/kemal/pull/599). Thanks @jinn999 :pray: + # 0.27.0 (28-11-2020) - Crystal 0.35.x support :tada: Thanks @bcardiff :pray: diff --git a/README.md b/README.md index 068cc25..e86af15 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Lightning Fast, Super Simple web framework. -[![Build Status](https://travis-ci.org/kemalcr/kemal.svg?branch=master)](https://travis-ci.org/kemalcr/kemal) +[![CI](https://github.com/kemalcr/kemal/actions/workflows/ci.yml/badge.svg)](https://github.com/kemalcr/kemal/actions/workflows/ci.yml) [![Join the chat at https://gitter.im/sdogruyol/kemal](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sdogruyol/kemal?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) # Super Simple ⚡️ diff --git a/shard.yml b/shard.yml index 57ce8bb..50dea58 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: kemal -version: 0.27.0 +version: 1.0.0 authors: - Serdar Dogruyol @@ -7,7 +7,7 @@ authors: dependencies: radix: github: luislavena/radix - version: ~> 0.3.8 + version: ~> 0.4.0 kilt: github: jeromegn/kilt version: ~> 0.4.0 @@ -18,8 +18,8 @@ dependencies: development_dependencies: ameba: github: crystal-ameba/ameba - version: ~> 0.12.0 + version: ~> 0.14.0 -crystal: 0.35.0 +crystal: ">= 0.36.0" license: MIT diff --git a/spec/static_file_handler_spec.cr b/spec/static_file_handler_spec.cr index 1aac161..e9307f6 100644 --- a/spec/static_file_handler_spec.cr +++ b/spec/static_file_handler_spec.cr @@ -1,6 +1,6 @@ require "./spec_helper" -private def handle(request, fallthrough = true) +private def handle(request, fallthrough = true, decompress = true) io = IO::Memory.new response = HTTP::Server::Response.new(io) context = HTTP::Server::Context.new(request, response) @@ -8,7 +8,7 @@ private def handle(request, fallthrough = true) handler.call context response.close io.rewind - HTTP::Client::Response.from_io(io) + HTTP::Client::Response.from_io(io, decompress: decompress) end describe Kemal::StaticFileHandler do @@ -51,7 +51,7 @@ describe Kemal::StaticFileHandler do it "should gzip a file if config is true, headers accept gzip and file is > 880 bytes" do serve_static({"gzip" => true, "dir_listing" => true}) headers = HTTP::Headers{"Accept-Encoding" => "gzip, deflate, sdch, br"} - response = handle HTTP::Request.new("GET", "/dir/bigger.txt", headers) + response = handle HTTP::Request.new("GET", "/dir/bigger.txt", headers), decompress: false response.status_code.should eq(200) response.headers["Content-Encoding"].should eq "gzip" end @@ -59,7 +59,7 @@ describe Kemal::StaticFileHandler do it "should not gzip a file if config is true, headers accept gzip and file is < 880 bytes" do serve_static({"gzip" => true, "dir_listing" => true}) headers = HTTP::Headers{"Accept-Encoding" => "gzip, deflate, sdch, br"} - response = handle HTTP::Request.new("GET", "/dir/test.txt", headers) + response = handle HTTP::Request.new("GET", "/dir/test.txt", headers), decompress: false response.status_code.should eq(200) response.headers["Content-Encoding"]?.should be_nil end @@ -67,7 +67,7 @@ describe Kemal::StaticFileHandler do it "should not gzip a file if config is false, headers accept gzip and file is > 880 bytes" do serve_static({"gzip" => false, "dir_listing" => true}) headers = HTTP::Headers{"Accept-Encoding" => "gzip, deflate, sdch, br"} - response = handle HTTP::Request.new("GET", "/dir/bigger.txt", headers) + response = handle HTTP::Request.new("GET", "/dir/bigger.txt", headers), decompress: false response.status_code.should eq(200) response.headers["Content-Encoding"]?.should be_nil end diff --git a/spec/websocket_handler_spec.cr b/spec/websocket_handler_spec.cr index bc02d3c..64f5489 100644 --- a/spec/websocket_handler_spec.cr +++ b/spec/websocket_handler_spec.cr @@ -22,8 +22,8 @@ describe "Kemal::WebSocketHandler" do it "matches on given route" do handler = Kemal::WebSocketHandler::INSTANCE - ws "/" { |socket| socket.send("Match") } - ws "/no_match" { |socket| socket.send "No Match" } + ws("/", &.send("Match")) + ws("/no_match", &.send("No Match")) headers = HTTP::Headers{ "Upgrade" => "websocket", "Connection" => "Upgrade", diff --git a/src/kemal.cr b/src/kemal.cr index 009337e..5504b5c 100644 --- a/src/kemal.cr +++ b/src/kemal.cr @@ -66,7 +66,7 @@ module Kemal end def self.display_startup_message(config, server) - addresses = server.addresses.map { |address| "#{config.scheme}://#{address}" }.join ", " + addresses = server.addresses.join ", " { |address| "#{config.scheme}://#{address}" } log "[#{config.env}] Kemal is ready to lead at #{addresses}" end