Compare commits

..

11 Commits

Author SHA1 Message Date
a5da2fbd40 Add Gitea action for CI
All checks were successful
Tests / test (6, 2.7) (pull_request) Has been cancelled
Tests / test (6, 3.0) (pull_request) Has been cancelled
Tests / test (6, 3.1) (pull_request) Has been cancelled
Tests / test (7, 2.7) (pull_request) Has been cancelled
Tests / test (7, 3.0) (pull_request) Has been cancelled
Tests / test (7, 3.1) (pull_request) Has been cancelled
2023-11-21 15:45:13 +01:00
df1a3e6512 Add Drone CI config
Some checks failed
continuous-integration/drone Build is failing
2023-11-21 15:38:15 +01:00
8b6f201a0b Merge pull request 'Switch to AWS v4 signatures' (#5) from feature/aws_v4_signatures into master
All checks were successful
Tests / test (6, 2.7) (push) Has been cancelled
Tests / test (6, 3.0) (push) Has been cancelled
Tests / test (6, 3.1) (push) Has been cancelled
Tests / test (7, 2.7) (push) Has been cancelled
Tests / test (7, 3.0) (push) Has been cancelled
Tests / test (7, 3.1) (push) Has been cancelled
Reviewed-on: #5
2023-11-21 14:19:38 +00:00
209fcca5ea Make headers argument optional 2023-11-21 15:18:13 +01:00
589dcf7fa2 Update example config 2023-11-16 12:39:46 +01:00
91cadbf228 Switch Docker image back to Ruby 3.1 2023-11-16 11:45:07 +01:00
d09c6e7a39 Use production env for Docker image 2023-11-16 11:41:57 +01:00
93fd1ecd5f Merge pull request 'Add Dockerfile' (#2) from dev/add_dockerfile into master
Reviewed-on: #2
2023-11-16 10:40:51 +00:00
024f516a9d Expose Content-Type header 2023-11-16 11:39:33 +01:00
96417e3884 Use development env and Webrick in dev run script 2023-11-16 11:27:15 +01:00
b7ff3e7d42 Remove debug output, rescue 2023-11-16 10:27:58 +01:00
7 changed files with 53 additions and 18 deletions

9
.drone.yml Normal file
View File

@@ -0,0 +1,9 @@
kind: pipeline
name: default
steps:
- name: test
image: ruby
commands:
- bundle install --jobs=3 --retry=3
- rake test

33
.gitea/workflows/ruby.yml Normal file
View File

@@ -0,0 +1,33 @@
name: Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7', '3.0', '3.1']
redis-version: [6, 7]
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Start Redis
uses: supercharge/redis-github-action@1.4.0
with:
redis-version: ${{ matrix.redis-version }}
- name: Configure
run: cp config.yml.erb.example config.yml.erb
- name: Run tests
run: bundle exec rake test

View File

@@ -1,8 +1,7 @@
# FROM ruby:3.1.4
FROM ruby:2.7.8
FROM ruby:3.1.4
WORKDIR /liquorcabinet
ENV RACK_ENV=staging
ENV RACK_ENV=production
COPY Gemfile Gemfile.lock /liquorcabinet/
RUN bundle install

View File

@@ -2,11 +2,11 @@ development: &defaults
maintenance: false
redis:
host: <%= ENV["REDIS_HOST"] || "localhost" %>
port: <%= ENV["REDIS_PORT"] || "6379" %>
db: <%= ENV["REDIS_DB"] || 0 %>
port: <%= ENV["REDIS_PORT"] || 6379 %>
db: <%= ENV["REDIS_DB"] || 1 %>
s3: &s3_defaults
endpoint: <%= ENV["S3_ENDPOINT"] || "http://127.0.0.1:9000" %>
region: <%= ENV["S3_REGION"] %>
region: <%= ENV["S3_REGION"] || "us-east-1" %>
access_key_id: <%= ENV["S3_ACCESS_KEY"] || "minioadmin" %>
secret_key_id: <%= ENV["S3_SECRET_KEY"] || "minioadmin" %>
bucket: <%= ENV["S3_BUCKET"] || "rs-development" %>

View File

@@ -36,10 +36,6 @@ module RemoteStorage
timestamp_for(res.headers[:date]) # S3 does not return a Last-Modified response header on PUTs
]
end
rescue RestClient::Forbidden => ex
puts ex.response.to_s
raise ex
end
def do_get_request(url, &block)
@@ -53,14 +49,14 @@ module RemoteStorage
def do_head_request(url, &block)
deal_with_unauthorized_requests do
auth_headers = auth_headers_for("HEAD", url, {})
auth_headers = auth_headers_for("HEAD", url)
RestClient.head(url, auth_headers, &block)
end
end
def do_delete_request(url)
deal_with_unauthorized_requests do
auth_headers = auth_headers_for("DELETE", url, {})
auth_headers = auth_headers_for("DELETE", url)
RestClient.delete(url, auth_headers)
end
end
@@ -79,12 +75,10 @@ module RemoteStorage
return found
end
def auth_headers_for(http_method, url, headers, data = nil)
def auth_headers_for(http_method, url, headers = {}, data = nil)
signature = s3_signer.sign_request(
http_method: http_method, url: url, headers: headers, body: data
)
puts signature.headers.inspect
signature.headers
end

View File

@@ -64,7 +64,7 @@ class LiquorCabinet < Sinatra::Base
headers 'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => 'GET, PUT, DELETE',
'Access-Control-Allow-Headers' => 'Authorization, Content-Type, Origin, If-Match, If-None-Match, Range',
'Access-Control-Expose-Headers' => 'ETag, Content-Length, Content-Range',
'Access-Control-Expose-Headers' => 'ETag, Content-Length, Content-Range, Content-Type',
'Accept-Ranges' => 'bytes'
headers['Access-Control-Allow-Origin'] = env["HTTP_ORIGIN"] if env["HTTP_ORIGIN"]
headers['Cache-Control'] = 'no-cache'

View File

@@ -1,6 +1,6 @@
#!/bin/bash
RACK_ENV=staging \
RACK_ENV=development \
REDIS_HOST=localhost \
REDIS_PORT=6379 \
REDIS_DB=1 \
@@ -8,4 +8,4 @@ S3_ENDPOINT='http://localhost:9000' \
S3_ACCESS_KEY='dev-key' \
S3_SECRET_KEY='123456789' \
S3_BUCKET=remotestorage \
bundle exec rainbows --listen localhost:4567
bundle exec rackup -p 4567