Windows support (#690)

Windows support
This commit is contained in:
Serdar Dogruyol - Sedo セド 2024-10-01 10:11:52 +03:00 committed by GitHub
parent 3243b8e0e0
commit 85fcbbee02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 53 additions and 10 deletions

2
.gitattributes vendored Normal file
View file

@ -0,0 +1,2 @@
*.cr text eol=lf
*.ecr text eol=lf

View file

@ -11,31 +11,66 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [ubuntu-latest, macos-latest] os: [ubuntu-latest, macos-latest, windows-latest]
crystal: [latest, nightly] crystal: [latest, nightly]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Install Crystal - name: Install Crystal
uses: oprypin/install-crystal@v1 uses: crystal-lang/install-crystal@v1
with: with:
crystal: ${{ matrix.crystal }} crystal: ${{ matrix.crystal }}
- name: Download source - name: Download source
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Install dependencies - name: Install dependencies
run: shards install run: shards install
env:
SHARDS_OPTS: --ignore-crystal-version
- name: Run specs - name: Run specs
run: | run: |
crystal spec crystal spec
crystal spec --release --no-debug
format:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
crystal: [latest, nightly]
runs-on: ${{ matrix.os }}
steps:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: ${{ matrix.crystal }}
- name: Download source
uses: actions/checkout@v4
- name: Check formatting - name: Check formatting
run: crystal tool format --check run: crystal tool format --check
ameba:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
crystal: [latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Crystal
uses: crystal-lang/install-crystal@v1
with:
crystal: ${{ matrix.crystal }}
- name: Download source
uses: actions/checkout@v4
- name: Install dependencies
run: shards install
- name: Run ameba linter - name: Run ameba linter
run: bin/ameba run: bin/ameba

View file

@ -106,6 +106,7 @@ describe "Macros" do
request = HTTP::Request.new("GET", "/") request = HTTP::Request.new("GET", "/")
response = call_request_on_app(request) response = call_request_on_app(request)
response.status_code.should eq(200) response.status_code.should eq(200)
response.headers["Content-Type"].should eq("application/octet-stream") response.headers["Content-Type"].should eq("application/octet-stream")
response.headers["Content-Length"].should eq("18") response.headers["Content-Length"].should eq("18")
end end

View file

@ -38,8 +38,13 @@ describe "Run" do
Kemal.config.env = "test" Kemal.config.env = "test"
Kemal.run do |config| Kemal.run do |config|
server = config.server.not_nil! server = config.server.not_nil!
server.bind_tcp "127.0.0.1", 3000, reuse_port: true
server.bind_tcp "0.0.0.0", 3001, reuse_port: true {% if flag?(:windows) %}
server.bind_tcp "127.0.0.1", 3000
{% else %}
server.bind_tcp "127.0.0.1", 3000, reuse_port: true
server.bind_tcp "0.0.0.0", 3001, reuse_port: true
{% end %}
end end
CR CR
end end

View file

@ -1,5 +1,5 @@
module Kemal module Kemal
VERSION = {{ `shards version #{__DIR__}`.chomp.stringify }} VERSION = {{ `shards version "#{__DIR__}"`.chomp.stringify }}
# Stores all the configuration options for a Kemal application. # Stores all the configuration options for a Kemal application.
# It's a singleton and you can access it like. # It's a singleton and you can access it like.

View file

@ -27,7 +27,7 @@ module Kemal
return return
end end
expanded_path = File.expand_path(request_path, "/") expanded_path = request_path
is_dir_path = if original_path.ends_with?('/') && !expanded_path.ends_with? '/' is_dir_path = if original_path.ends_with?('/') && !expanded_path.ends_with? '/'
expanded_path = expanded_path + '/' expanded_path = expanded_path + '/'
true true