diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 99e111e..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,49 +0,0 @@ -version: 2.1 -jobs: - test: - parameters: - ruby_version: - type: string - resource_class: small - docker: - - image: cimg/ruby:<< parameters.ruby_version >> - environment: - - S3_ENDPOINT=http://localhost:9000 - - S3_BUCKET=test - - GCS_ENDPOINT=http://localhost:8080/ - - GCS_BUCKET=some-bucket - - image: minio/minio:edge - entrypoint: sh - command: -c 'mkdir -p /data/test && minio server /data --json' - - image: fsouza/fake-gcs-server - entrypoint: sh - command: > - -c 'mkdir -p /data/some-bucket && - /bin/fake-gcs-server -port 8080 -scheme http -external-url=http://localhost:8080 -public-host=localhost:8080 -filesystem-root /data - ' - steps: - - checkout - - run: - name: setup env - command: gem install bundler && ruby -v && bundle -v - - run: - name: bundle install - command: bundle install - - run: - name: Test syntax with rubocop - command: bundle exec ./rubocop --display-style-guide --extra-details - - run: - name: Run tests - command: bundle exec rspec -references: - matrix_test: &matrix_test - test: - matrix: - parameters: - ruby_version: ["2.5", "2.7", "3.0", "3.1"] - -workflows: - version: 2 - build_and_test: - jobs: - - <<: *matrix_test diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 74482a8..b7e48d3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,13 +22,16 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Start MinIO + - name: Start SeaweedFS run: | - docker run -d --name minio \ + docker run -d --name seaweedfs \ -p 9000:9000 \ - --entrypoint sh \ - minio/minio:RELEASE.2025-04-22T22-12-26Z \ - -c 'mkdir -p /data/test && minio server /data --json' + -e AWS_ACCESS_KEY_ID=minioadmin \ + -e AWS_SECRET_ACCESS_KEY=minioadmin \ + docker.io/chrislusf/seaweedfs:4.48 \ + mini -dir=/data -webdav=false -admin.ui=false \ + -s3.port=9000 -s3.port.iceberg=0 -s3.port.lance=0 -s3.autoCreateBucket=false \ + -bucket=test - name: Start fake-gcs-server run: | @@ -41,9 +44,12 @@ jobs: - name: Wait for services run: | for i in $(seq 1 30); do - curl -sf http://localhost:9000/minio/health/live && curl -sf http://localhost:8080/ && break + curl -sfI --aws-sigv4 aws:amz:us-east-1:s3 --user minioadmin:minioadmin http://localhost:9000/test \ + && curl -sf "http://localhost:8080/storage/v1/b/$GCS_BUCKET" >/dev/null && exit 0 sleep 1 done + echo "SeaweedFS or fake-gcs-server did not become ready" >&2 + exit 1 - name: Set up Ruby ${{ matrix.ruby-version }} uses: ruby/setup-ruby@v1 diff --git a/dip.yml b/dip.yml index a45b238..fe0bff1 100644 --- a/dip.yml +++ b/dip.yml @@ -34,7 +34,6 @@ interaction: provision: - ./docker/prepare_env.sh - - mkdir -p uploads/s3/$S3_BUCKET - rm -rf uploads/gcs/$GCS_BUCKET - rm -rf Gemfile.lock - mkdir -p uploads/gcs/$GCS_BUCKET diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index a43b10d..db31384 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -20,14 +20,23 @@ services: - bundler-data:/bundle command: sh depends_on: - - s3 - - gcs + s3: + condition: service_healthy + gcs: + condition: service_started s3: - image: minio/minio:RELEASE.2025-04-22T22-12-26Z - volumes: - - ../uploads/s3:/data - command: server /data --json + image: docker.io/chrislusf/seaweedfs:4.48 + command: ["mini", "-dir=/data", "-webdav=false", "-admin.ui=false", + "-s3.port=9000", "-s3.port.iceberg=0", "-s3.port.lance=0", "-s3.autoCreateBucket=false", + "-bucket=${S3_BUCKET}"] + environment: + AWS_ACCESS_KEY_ID: minioadmin + AWS_SECRET_ACCESS_KEY: minioadmin + healthcheck: + test: ["CMD-SHELL", "for b in ${S3_BUCKET}; do curl -sfI --aws-sigv4 aws:amz:us-east-1:s3 --user \"$$AWS_ACCESS_KEY_ID:$$AWS_SECRET_ACCESS_KEY\" http://localhost:9000/$$b || exit 1; done"] + interval: 1s + retries: 30 gcs: image: fsouza/fake-gcs-server diff --git a/spec/cloud_storage/objects/gcs_spec.rb b/spec/cloud_storage/objects/gcs_spec.rb index b0a78c3..478189f 100644 --- a/spec/cloud_storage/objects/gcs_spec.rb +++ b/spec/cloud_storage/objects/gcs_spec.rb @@ -23,7 +23,7 @@ subject(:url) { obj.signed_url(expires_in: 30, issuer: 'max@tretyakov-ma.ru', signing_key: key, version: :v2) } it { is_expected.to match(%r{\A#{ENV.fetch('GCS_ENDPOINT')}#{ENV.fetch('GCS_BUCKET')}/test_1.txt}) } - it { is_expected.to match(/GoogleAccessId=/) } + it { is_expected.to include('GoogleAccessId=') } end end diff --git a/spec/cloud_storage/wrappers/s3_spec.rb b/spec/cloud_storage/wrappers/s3_spec.rb index c0351da..8f6ff95 100644 --- a/spec/cloud_storage/wrappers/s3_spec.rb +++ b/spec/cloud_storage/wrappers/s3_spec.rb @@ -135,6 +135,14 @@ it { expect(cli.exist?('file.txt')).to be(false) } end + + # Servers differ on an invalid bucket name (400 on AWS and MinIO, 404 on + # SeaweedFS), so the error branch is driven by a stubbed client. + context 'when S3 rejects the request' do + let(:cli) { described_class.new(bucket: 'invalid_bucket', stub_responses: { head_object: 'BadRequest' }) } + + it { expect(cli.exist?('file.txt')).to be(false) } + end end describe '#find' do @@ -168,6 +176,16 @@ expect { cli.find('test6.txt') }.to raise_error(CloudStorage::ObjectNotFound, /test6.txt/) end end + + # Servers differ on an invalid bucket name (400 on AWS and MinIO, 404 on + # SeaweedFS), so the error branch is driven by a stubbed client. + context 'when S3 rejects the request' do + let(:cli) { described_class.new(bucket: 'invalid_bucket', stub_responses: { head_object: 'BadRequest' }) } + + it do + expect { cli.find('test6.txt') }.to raise_error(CloudStorage::ObjectNotFound, /test6.txt/) + end + end end describe '#delete_files' do