Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,40 @@ on:
- 'stl-preview-base/**'

jobs:
build:
timeout-minutes: 10
name: build
permissions:
contents: read
id-token: write
runs-on: ${{ github.repository == 'stainless-sdks/cloudpayments-ruby' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: |-
github.repository == 'stainless-sdks/cloudpayments-ruby' &&
(github.event_name == 'push' || github.event.pull_request.head.repo.fork)
steps:
- uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: false
- run: |-
bundle install

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/cloudpayments-ruby'
id: github-oidc
uses: actions/github-script@v8
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Build and upload gem artifacts
if: github.repository == 'stainless-sdks/cloudpayments-ruby'
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
SHA: ${{ github.sha }}
PACKAGE_NAME: cloudpayments_ruby
run: ./scripts/utils/upload-artifact.sh
lint:
timeout-minutes: 10
name: lint
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.4.1"
".": "0.4.2"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 15
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hexlet%2Fcloudpayments-737bf804f9ef1282c03bc532fc392f69a6e00eb5d229fa39368ea8ca2ff02de1.yml
openapi_spec_hash: 68aafd72cb1fa7266ab697cc29f73583
config_hash: 33c8a1290e177bcab7a82d1fe4e9ecfd
config_hash: 7e3e36dabba4af552324a8ffefba23f5
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 0.4.2 (2026-03-04)

Full Changelog: [v0.4.1...v0.4.2](https://github.com/Hexlet/cloudpayments-ruby/compare/v0.4.1...v0.4.2)

### Bug Fixes

* properly mock time in ruby ci tests ([7cfd820](https://github.com/Hexlet/cloudpayments-ruby/commit/7cfd8204e2a9d7045d9a05045be6b525768455e0))


### Chores

* **ci:** add build step ([9287b3c](https://github.com/Hexlet/cloudpayments-ruby/commit/9287b3cf46dba9228ab6aa4472d7f0cc8a2e437d))
* **internal:** codegen related update ([2fc9917](https://github.com/Hexlet/cloudpayments-ruby/commit/2fc991731a559b659f2dbe3ae53c130fda957533))
* **internal:** remove mock server code ([e100d4f](https://github.com/Hexlet/cloudpayments-ruby/commit/e100d4f1eb3433101355817d309ae3008b0faa06))
* update mock server docs ([36a2a37](https://github.com/Hexlet/cloudpayments-ruby/commit/36a2a3788aa8b4638c9d41e2fe54a6cd4a939990))

## 0.4.1 (2026-02-13)

Full Changelog: [v0.4.0...v0.4.1](https://github.com/Hexlet/cloudpayments-ruby/compare/v0.4.0...v0.4.1)
Expand Down
6 changes: 0 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ $ bundle exec rake

## Running tests

Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.

```bash
$ npx prism mock path/to/your/openapi.yml
```

```bash
$ bundle exec rake test
```
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
cloudpayments-ruby (0.4.1)
cloudpayments-ruby (0.4.2)
cgi
connection_pool

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
<!-- x-release-please-start-version -->

```ruby
gem "cloudpayments-ruby", "~> 0.4.1"
gem "cloudpayments-ruby", "~> 0.4.2"
```

<!-- x-release-please-end -->
Expand Down
31 changes: 31 additions & 0 deletions lib/cloudpayments_ruby/internal/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,37 @@ def writable_enum(&blk)
JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}

class << self
# @api private
#
# @param query [Hash{Symbol=>Object}]
#
# @return [Hash{Symbol=>Object}]
def encode_query_params(query)
out = {}
query.each { write_query_param_element!(out, _1, _2) }
out
end

# @api private
#
# @param collection [Hash{Symbol=>Object}]
# @param key [String]
# @param element [Object]
#
# @return [nil]
private def write_query_param_element!(collection, key, element)
case element
in Hash
element.each do |name, value|
write_query_param_element!(collection, "#{key}[#{name}]", value)
end
in Array
collection[key] = element.map(&:to_s).join(",")
else
collection[key] = element.to_s
end
end

# @api private
#
# @param y [Enumerator::Yielder]
Expand Down
2 changes: 1 addition & 1 deletion lib/cloudpayments_ruby/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module CloudpaymentsRuby
VERSION = "0.4.1"
VERSION = "0.4.2"
end
20 changes: 20 additions & 0 deletions rbi/cloudpayments_ruby/internal/util.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,26 @@ module CloudpaymentsRuby
T.let(%r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}, Regexp)

class << self
# @api private
sig do
params(query: CloudpaymentsRuby::Internal::AnyHash).returns(
CloudpaymentsRuby::Internal::AnyHash
)
end
def encode_query_params(query)
end

# @api private
sig do
params(
collection: CloudpaymentsRuby::Internal::AnyHash,
key: String,
element: T.anything
).void
end
private def write_query_param_element!(collection, key, element)
end

# @api private
sig do
params(
Expand Down
41 changes: 0 additions & 41 deletions scripts/mock

This file was deleted.

46 changes: 0 additions & 46 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,7 @@ set -e

cd -- "$(dirname -- "$0")/.."

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

function prism_is_running() {
curl --silent "http://localhost:4010" >/dev/null 2>&1
}

kill_server_on_port() {
pids=$(lsof -t -i tcp:"$1" || echo "")
if [ "$pids" != "" ]; then
kill "$pids"
echo "Stopped $pids."
fi
}

function is_overriding_api_base_url() {
[ -n "$TEST_API_BASE_URL" ]
}

if ! is_overriding_api_base_url && ! prism_is_running ; then
# When we exit this script, make sure to kill the background mock server process
trap 'kill_server_on_port 4010' EXIT

# Start the dev server
./scripts/mock --daemon
fi

if is_overriding_api_base_url ; then
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
echo
elif ! prism_is_running ; then
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
echo -e "running against your OpenAPI spec."
echo
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the prism command:"
echo
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}"
echo

exit 1
else
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
echo
fi

echo "==> Running tests"
bundle exec rake test "$@"
113 changes: 113 additions & 0 deletions scripts/utils/upload-artifact.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/usr/bin/env bash

set -euo pipefail

# ANSI Color Codes
GREEN='\033[32m'
RED='\033[31m'
NC='\033[0m' # No Color

DIST_DIR="dist"

log_error() {
local msg="$1"
local headers="$2"
local body="$3"
echo -e "${RED}${msg}${NC}"
[[ -f "$headers" ]] && echo -e "${RED}Headers:$(cat "$headers")${NC}"
echo -e "${RED}Body: ${body}${NC}"
exit 1
}

upload_file() {
local file_name="$1"
local tmp_headers
tmp_headers=$(mktemp)

if [ -f "$file_name" ]; then
echo -e "${GREEN}Processing file: $file_name${NC}"
pkg_file_name="${file_name#"${DIST_DIR}/"}"

# Get signed URL for uploading artifact file
signed_url_response=$(curl -X POST -G "$URL" \
-sS --retry 5 \
-D "$tmp_headers" \
--data-urlencode "filename=$pkg_file_name" \
-H "Authorization: Bearer $AUTH" \
-H "Content-Type: application/json")

# Validate JSON and extract URL
if ! signed_url=$(echo "$signed_url_response" | jq -e -r '.url' 2>/dev/null) || [[ "$signed_url" == "null" ]]; then
log_error "Failed to get valid signed URL" "$tmp_headers" "$signed_url_response"
fi

# Set content-type based on file extension
local extension="${file_name##*.}"
local content_type
case "$extension" in
gem) content_type="application/octet-stream" ;;
gz) content_type="application/gzip" ;;
rz) content_type="application/octet-stream" ;;
html) content_type="text/html" ;;
*) content_type="application/octet-stream" ;;
esac

# Upload file
upload_response=$(curl -v -X PUT \
--retry 5 \
--retry-all-errors \
-D "$tmp_headers" \
-H "Content-Type: $content_type" \
--data-binary "@${file_name}" "$signed_url" 2>&1)

if ! echo "$upload_response" | grep -q "HTTP/[0-9.]* 200"; then
log_error "Failed to upload artifact file" "$tmp_headers" "$upload_response"
fi

# Insert small throttle to reduce rate limiting risk
sleep 0.1
fi
}

walk_tree() {
local current_dir="$1"

for entry in "$current_dir"/*; do
# Check that entry is valid
[ -e "$entry" ] || [ -h "$entry" ] || continue

if [ -d "$entry" ]; then
walk_tree "$entry"
else
upload_file "$entry"
fi
done
}

cd "$(dirname "$0")/../.."

echo "::group::Building gem"
VERSION_FILE="lib/${PACKAGE_NAME}/version.rb"
if [[ ! -f "$VERSION_FILE" ]]; then
echo -e "${RED}Version file not found: ${VERSION_FILE}${NC}"
exit 1
fi
SHORT_SHA="${SHA:0:7}"
sed -i.bak -E "s/(VERSION = \"[^\"]+)\"/\1.beta.${SHORT_SHA}\"/" "$VERSION_FILE"
rm -f "${VERSION_FILE}.bak"

gem build
mkdir -p "${DIST_DIR}/gems"
mv ./*.gem "${DIST_DIR}/gems/"
echo "::endgroup::"

echo "::group::Generating gem index"
gem generate_index --directory "$DIST_DIR"
echo "::endgroup::"

echo "::group::Uploading to pkg.stainless.com"
walk_tree "$DIST_DIR"
echo "::endgroup::"

echo -e "${GREEN}Gem artifacts uploaded to Stainless storage.${NC}"
echo -e "\033[32mInstallation: bundle remove cloudpayments-ruby && bundle add cloudpayments-ruby --source 'https://pkg.stainless.com/s/cloudpayments-ruby/$SHA'\033[0m"
Loading