diff --git a/.ci/scripts/validate_commit_message.py b/.ci/scripts/validate_commit_message.py index 181729c..7930faf 100644 --- a/.ci/scripts/validate_commit_message.py +++ b/.ci/scripts/validate_commit_message.py @@ -1,46 +1,54 @@ -# WARNING: DO NOT EDIT! -# -# This file was generated by plugin_template, and is managed by it. Please use -# './plugin-template --github pulp_file' to update this file. -# -# For more info visit https://github.com/pulp/plugin_template - +import os import re -import requests import subprocess import sys +import tomllib from pathlib import Path -KEYWORDS = ["fixes", "closes", "re", "ref"] -NO_ISSUE = "[noissue]" -STATUSES = ["NEW", "ASSIGNED", "POST", "MODIFIED"] -REDMINE_URL = "https://pulp.plan.io" -CHANGELOG_EXTS = [".feature", ".bugfix", ".doc", ".removal", ".misc", ".deprecation"] +from github import Github + +with open("pyproject.toml", "rb") as fp: + PYPROJECT_TOML = tomllib.load(fp) +KEYWORDS = ["fixes", "closes"] +BLOCKING_REGEX = [ + r"^DRAFT", + r"^WIP", + r"^NOMERGE", + r"^DO\s*NOT\s*MERGE", + r"^EXPERIMENT", + r"^FIXUP", + r"Apply suggestions from code review", +] +try: + CHANGELOG_EXTS = [ + f".{item['directory']}" for item in PYPROJECT_TOML["tool"]["towncrier"]["type"] + ] +except KeyError: + CHANGELOG_EXTS = [".feature", ".bugfix", ".doc", ".removal", ".misc"] +NOISSUE_MARKER = "[noissue]" sha = sys.argv[1] -project = "" message = subprocess.check_output(["git", "log", "--format=%B", "-n 1", sha]).decode("utf-8") +if NOISSUE_MARKER in message: + sys.exit(f"Do not add '{NOISSUE_MARKER}' in the commit message.") + +if any((re.match(pattern, message, re.IGNORECASE) for pattern in BLOCKING_REGEX)): + sys.exit("This PR is not ready for consumption.") -def __check_status(issue): - response = requests.get(f"{REDMINE_URL}/issues/{issue}.json") - response.raise_for_status() - bug_json = response.json() - status = bug_json["issue"]["status"]["name"] - if status not in STATUSES: - sys.exit( - "Error: issue #{issue} has invalid status of {status}. Status must be one of " - "{statuses}.".format(issue=issue, status=status, statuses=", ".join(STATUSES)) - ) +g = Github(os.environ.get("GITHUB_TOKEN")) +repo = g.get_repo("pulp/pulp-openapi-generator") - if project: - project_id = bug_json["issue"]["project"]["id"] - project_json = requests.get(f"{REDMINE_URL}/projects/{project_id}.json").json() - if project_json["project"]["identifier"] != project: - sys.exit(f"Error: issue {issue} is not in the {project} project.") +def check_status(issue): + gi = repo.get_issue(int(issue)) + if gi.pull_request: + sys.exit(f"Error: issue #{issue} is a pull request.") + if gi.closed_at: + sys.exit(f"Error: issue #{issue} is closed.") -def __check_changelog(issue): + +def check_changelog(issue): matches = list(Path("CHANGES").rglob(f"{issue}.*")) if len(matches) < 1: @@ -53,22 +61,15 @@ def __check_changelog(issue): print("Checking commit message for {sha}.".format(sha=sha[0:7])) # validate the issue attached to the commit -regex = r"(?:{keywords})[\s:]+#(\d+)".format(keywords=("|").join(KEYWORDS)) -pattern = re.compile(regex, re.IGNORECASE) - -issues = pattern.findall(message) +issue_regex = r"(?:{keywords})[\s:]+#(\d+)".format(keywords=("|").join(KEYWORDS)) +issues = re.findall(issue_regex, message, re.IGNORECASE) +cherry_pick_regex = r"^\s*\(cherry picked from commit [0-9a-f]*\)\s*$" +cherry_pick = re.search(cherry_pick_regex, message, re.MULTILINE) if issues: - for issue in pattern.findall(message): - __check_status(issue) - # __check_changelog(issue) -else: - if NO_ISSUE in message: - print("Commit {sha} has no issues but is tagged {tag}.".format(sha=sha[0:7], tag=NO_ISSUE)) - else: - sys.exit( - "Error: no attached issues found for {sha}. If this was intentional, add " - " '{tag}' to the commit message.".format(sha=sha[0:7], tag=NO_ISSUE) - ) + for issue in issues: + if not cherry_pick: + check_status(issue) + check_changelog(issue) print("Commit message for {sha} passed.".format(sha=sha[0:7])) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c9cc2b..2ec700d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,56 +1,63 @@ --- -name: pulp-openapi-generator PR CI -on: pull_request +name: "pulp-openapi-generator PR CI" +on: + pull_request: -jobs: +concurrency: + group: ${{ github.ref_name }}-${{ github.workflow }} + cancel-in-progress: true - lint: - runs-on: ubuntu-latest +defaults: + run: + working-directory: "pulp-openapi-generator" +jobs: + check-commits: + runs-on: "ubuntu-latest" steps: - - uses: actions/checkout@v2 + - uses: "actions/checkout@v4" with: - # by default, it uses a depth of 1 - # this fetches all history so that we can read each commit fetch-depth: 0 - - - uses: actions/setup-python@v2 + path: "pulp-openapi-generator" + - uses: "actions/setup-python@v5" with: - python-version: "3.8" - - - name: Check commit message + python-version: "3.11" + - name: "Install python dependencies" + run: | + pip install requests pygithub + - name: "Check commit message" if: github.event_name == 'pull_request' env: - GITHUB_CONTEXT: ${{ github.event.pull_request.commits_url }} + PY_COLORS: "1" + ANSIBLE_FORCE_COLOR: "1" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_CONTEXT: "${{ github.event.pull_request.commits_url }}" run: | - pip install requests - sh .github/workflows/scripts/check_commit.sh + .github/workflows/scripts/check_commit.sh docs: - uses: "./.github/workflows/docs-ci.yml" + uses: "./.github/workflows/docs.yml" - pulp: - runs-on: ubuntu-latest + test: + runs-on: "ubuntu-latest" # run only after lint and docs finishes needs: - - lint - - docs + - "docs" strategy: fail-fast: false matrix: env: - - TEST: pulp + - TEST: "pulp" steps: - - uses: actions/checkout@v2 + - uses: "actions/checkout@v4" with: - # by default, it uses a depth of 1 - # this fetches all history so that we can read each commit fetch-depth: 0 + path: "pulp-openapi-generator" - - uses: actions/setup-python@v2 + - uses: "actions/setup-python@v5" with: - python-version: "3.8" + python-version: "3.11" - uses: ruby/setup-ruby@v1 with: @@ -93,3 +100,20 @@ jobs: docker logs pulp || true docker exec pulp ls -latr /etc/yum.repos.d/ || true docker exec pulp cat /etc/yum.repos.d/* || true + + ready-to-ship: + # This is a dummy dependent task to have a single entry for the branch protection rules. + runs-on: "ubuntu-latest" + needs: + - "check-commits" + - "test" + - "docs" + if: "always()" + steps: + - name: "Collect needed jobs results" + working-directory: "." + run: | + echo '${{toJson(needs)}}' | jq -r 'to_entries[]|select(.value.result!="success")|.key + ": " + .value.result' + echo '${{toJson(needs)}}' | jq -e 'to_entries|map(select(.value.result!="success"))|length == 0' + echo "CI says: Looks good!" +... diff --git a/.github/workflows/docs-ci.yml b/.github/workflows/docs.yml similarity index 84% rename from .github/workflows/docs-ci.yml rename to .github/workflows/docs.yml index ccd6215..3f466b2 100644 --- a/.github/workflows/docs-ci.yml +++ b/.github/workflows/docs.yml @@ -15,5 +15,6 @@ jobs: - name: "Install Test Dependencies" run: | pip install -r doc_requirements.txt - - name: Build docs - run: make docs + - name: "Build docs" + run: | + make docs diff --git a/.github/workflows/scripts/before_install.sh b/.github/workflows/scripts/before_install.sh index 45adf6a..c360e1d 100755 --- a/.github/workflows/scripts/before_install.sh +++ b/.github/workflows/scripts/before_install.sh @@ -7,9 +7,20 @@ # # For more info visit https://github.com/pulp/plugin_template +# make sure this script runs at the repo root +cd "$(dirname "$(realpath -e "$0")")"/../../.. + set -mveuo pipefail # Intall requirements for ansible playbooks pip install docker netaddr boto3 ansible -ansible-galaxy collection install amazon.aws +for i in {1..3} +do + ansible-galaxy collection install "amazon.aws:8.1.0" && s=0 && break || s=$? && sleep 3 +done +if [[ $s -gt 0 ]] +then + echo "Failed to install amazon.aws" + exit $s +fi diff --git a/.github/workflows/scripts/check_commit.sh b/.github/workflows/scripts/check_commit.sh index 3d36c59..62fe94b 100755 --- a/.github/workflows/scripts/check_commit.sh +++ b/.github/workflows/scripts/check_commit.sh @@ -1,23 +1,11 @@ #!/bin/bash -# WARNING: DO NOT EDIT! -# -# This file was generated by plugin_template, and is managed by it. Please use -# './plugin-template --github pulp_file' to update this file. -# -# For more info visit https://github.com/pulp/plugin_template +# make sure this script runs at the repo root +cd "$(dirname "$(realpath -e "$0")")/../../.." set -euv -echo ::group::REQUESTS -pip3 install requests -echo ::endgroup:: - -for sha in $(curl $GITHUB_CONTEXT | jq '.[].sha' | sed 's/"//g') +for SHA in $(curl -H "Authorization: token $GITHUB_TOKEN" "$GITHUB_CONTEXT" | jq -r '.[].sha') do - python3 .ci/scripts/validate_commit_message.py $sha - VALUE=$? - if [ "$VALUE" -gt 0 ]; then - exit $VALUE - fi + python3 .ci/scripts/validate_commit_message.py "$SHA" done diff --git a/.github/workflows/scripts/install.sh b/.github/workflows/scripts/install.sh index 8b49505..ec8d4bc 100755 --- a/.github/workflows/scripts/install.sh +++ b/.github/workflows/scripts/install.sh @@ -7,11 +7,11 @@ # # For more info visit https://github.com/pulp/plugin_template -set -euv - # make sure this script runs at the repo root cd "$(dirname "$(realpath -e "$0")")"/../../.. +set -euv + TAG="${TAG:-latest}" mkdir -p .ci/ansible/vars diff --git a/.github/workflows/scripts/test_bindings.py b/.github/workflows/scripts/test_bindings.py index 621eebc..2bb0697 100644 --- a/.github/workflows/scripts/test_bindings.py +++ b/.github/workflows/scripts/test_bindings.py @@ -152,8 +152,7 @@ def upload_file_in_chunks(file_path): pprint(repository_version_1) # Create an artifact from a local file -file_path = os.path.join(os.environ["GITHUB_WORKSPACE"], ".github/workflows/scripts/test_bindings.py") -artifact = artifacts.create(file=file_path) +artifact = artifacts.create(file=__file__) pprint(artifact) # Create a FileContent from the artifact diff --git a/.github/workflows/scripts/test_bindings.rb b/.github/workflows/scripts/test_bindings.rb index c69fd68..d0b9b74 100644 --- a/.github/workflows/scripts/test_bindings.rb +++ b/.github/workflows/scripts/test_bindings.rb @@ -40,7 +40,6 @@ def monitor_task(task_href) # # Returns: # list[str]: List of hrefs that identify resource created by the task - completed = [] task = @tasks_api.read(task_href) until ["completed", "failed", "canceled"].include? task.state sleep(2) @@ -86,8 +85,8 @@ def upload_file_in_chunks(file_path) filechunk.write(chunk) filechunk.flush() actual_chunk_size = File.size(filechunk) - response = @uploads_api.update(content_range(offset, offset + actual_chunk_size -1, total_size), upload_href, filechunk) - offset += actual_chunk_size -1 + response = @uploads_api.update(content_range(offset, offset + actual_chunk_size - 1, total_size), upload_href, filechunk) + offset += actual_chunk_size - 1 ensure filechunk.close filechunk.unlink @@ -100,7 +99,7 @@ def upload_file_in_chunks(file_path) end -artifact = upload_file_in_chunks(File.join(ENV['GITHUB_WORKSPACE'], 'README.rst')) +artifact = upload_file_in_chunks(File.new(File.expand_path(__FILE__))) # Create a File Remote remote_url = 'https://fixtures.pulpproject.org/file/PULP_MANIFEST' @@ -120,12 +119,8 @@ def upload_file_in_chunks(file_path) repository_version_1 = @repoversions_api.read(created_resources[0]) -# Create an artifact from a local file -file_path = File.join(ENV['GITHUB_WORKSPACE'], '.github/workflows/scripts/test_bindings.rb') -artifact = @artifacts_api.create(File.new(file_path)) - -# Create a FileContent from the artifact -filecontent_response = @filecontent_api.create('foo.tar.gz', {artifact: artifact.pulp_href}) +# Create a FileContent from a local file +filecontent_response = @filecontent_api.create('foo.tar.gz', {file: File.new(File.expand_path(__FILE__))}) created_resources = monitor_task(filecontent_response.task) diff --git a/staging_docs/admin/guides/.gitkeep b/docs/admin/guides/.gitkeep similarity index 100% rename from staging_docs/admin/guides/.gitkeep rename to docs/admin/guides/.gitkeep diff --git a/staging_docs/admin/learn/.gitkeep b/docs/admin/learn/.gitkeep similarity index 100% rename from staging_docs/admin/learn/.gitkeep rename to docs/admin/learn/.gitkeep diff --git a/staging_docs/admin/reference/.gitkeep b/docs/admin/reference/.gitkeep similarity index 100% rename from staging_docs/admin/reference/.gitkeep rename to docs/admin/reference/.gitkeep diff --git a/staging_docs/admin/tutorials/.gitkeep b/docs/admin/tutorials/.gitkeep similarity index 100% rename from staging_docs/admin/tutorials/.gitkeep rename to docs/admin/tutorials/.gitkeep diff --git a/staging_docs/dev/guides/.gitkeep b/docs/dev/guides/.gitkeep similarity index 100% rename from staging_docs/dev/guides/.gitkeep rename to docs/dev/guides/.gitkeep diff --git a/staging_docs/dev/learn/.gitkeep b/docs/dev/learn/.gitkeep similarity index 100% rename from staging_docs/dev/learn/.gitkeep rename to docs/dev/learn/.gitkeep diff --git a/staging_docs/dev/reference/.gitkeep b/docs/dev/reference/.gitkeep similarity index 100% rename from staging_docs/dev/reference/.gitkeep rename to docs/dev/reference/.gitkeep diff --git a/staging_docs/dev/tutorials/.gitkeep b/docs/dev/tutorials/.gitkeep similarity index 100% rename from staging_docs/dev/tutorials/.gitkeep rename to docs/dev/tutorials/.gitkeep diff --git a/staging_docs/user/guides/.gitkeep b/docs/user/guides/.gitkeep similarity index 100% rename from staging_docs/user/guides/.gitkeep rename to docs/user/guides/.gitkeep diff --git a/staging_docs/user/guides/generate-bindings.md b/docs/user/guides/generate-bindings.md similarity index 100% rename from staging_docs/user/guides/generate-bindings.md rename to docs/user/guides/generate-bindings.md diff --git a/staging_docs/user/index.md b/docs/user/index.md similarity index 100% rename from staging_docs/user/index.md rename to docs/user/index.md diff --git a/staging_docs/user/learn/.gitkeep b/docs/user/learn/.gitkeep similarity index 100% rename from staging_docs/user/learn/.gitkeep rename to docs/user/learn/.gitkeep diff --git a/staging_docs/user/reference/.gitkeep b/docs/user/reference/.gitkeep similarity index 100% rename from staging_docs/user/reference/.gitkeep rename to docs/user/reference/.gitkeep diff --git a/staging_docs/user/tutorials/.gitkeep b/docs/user/tutorials/.gitkeep similarity index 100% rename from staging_docs/user/tutorials/.gitkeep rename to docs/user/tutorials/.gitkeep diff --git a/gen-client.sh b/gen-client.sh index 8c51982..97f5e5b 100755 --- a/gen-client.sh +++ b/gen-client.sh @@ -34,7 +34,10 @@ if language.lower() == "python": else: print("v4.3.1") elif language.lower() == "ruby": - print("v4.3.1") + if core_version >= Version("3.70.dev"): + print("v7.10.0") + else: + print("v4.3.1") elif language.lower() == "typescript": print("v5.2.1") else: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e69de29 diff --git a/templates/ruby/v7.10.0/gemspec.mustache b/templates/ruby/v7.10.0/gemspec.mustache new file mode 100644 index 0000000..3503583 --- /dev/null +++ b/templates/ruby/v7.10.0/gemspec.mustache @@ -0,0 +1,42 @@ +# -*- encoding: utf-8 -*- + +=begin +{{> api_info}} +=end + +$:.push File.expand_path("../lib", __FILE__) +require "{{gemName}}/version" + +Gem::Specification.new do |s| + s.name = "{{gemName}}{{^gemName}}{{{appName}}}{{/gemName}}" + s.version = {{moduleName}}::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ["{{gemAuthor}}{{^gemAuthor}}OpenAPI-Generator{{/gemAuthor}}"] + s.email = ["{{gemAuthorEmail}}{{^gemAuthorEmail}}{{infoEmail}}{{/gemAuthorEmail}}"] + s.homepage = "{{gemHomepage}}{{^gemHomepage}}https://openapi-generator.tech{{/gemHomepage}}" + s.summary = "{{gemSummary}}{{^gemSummary}}{{{appName}}} Ruby Gem{{/gemSummary}}" + s.description = "{{gemDescription}}{{^gemDescription}}{{{appDescription}}}{{^appDescription}}{{{appName}}} Ruby Gem{{/appDescription}}{{/gemDescription}}" + s.license = "{{{gemLicense}}}{{^gemLicense}}Unlicense{{/gemLicense}}" + s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 2.7{{/gemRequiredRubyVersion}}" + s.metadata = {{{gemMetadata}}}{{^gemMetadata}}{}{{/gemMetadata}} + + {{#isFaraday}} + s.add_runtime_dependency 'faraday-net_http', '>= 2.0', '< 3.1' + s.add_runtime_dependency 'faraday', '>= 1.0.1', '< 2.9' + s.add_runtime_dependency 'faraday-multipart' + s.add_runtime_dependency 'marcel' + {{/isFaraday}} + {{#isTyphoeus}} + s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' + {{/isTyphoeus}} + {{#isHttpx}} + s.add_runtime_dependency 'httpx', '~> 1.0', '>= 1.0.0' + {{/isHttpx}} + + s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0' + + s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? } + s.test_files = `find spec/*`.split("\n") + s.executables = [] + s.require_paths = ["lib"] +end diff --git a/test_bindings.rb b/test_bindings.rb new file mode 100644 index 0000000..3f7fb94 --- /dev/null +++ b/test_bindings.rb @@ -0,0 +1,148 @@ +require 'pulpcore_client' +require 'pulp_file_client' +require 'tempfile' +require 'digest' + + +PulpcoreClient.configure do |config| + config.host= "http://localhost:5001" + config.username= 'admin' + config.password= 'password' + config.debugging=true +end + +PulpFileClient.configure do |config| + config.host= "http://localhost:5001" + config.username= 'admin' + config.password= 'password' + config.debugging=true +end + + +@artifacts_api = PulpcoreClient::ArtifactsApi.new +@filerepositories_api = PulpFileClient::RepositoriesFileApi.new +@repoversions_api = PulpFileClient::RepositoriesFileVersionsApi.new +@filecontent_api = PulpFileClient::ContentFilesApi.new +@filedistributions_api = PulpFileClient::DistributionsFileApi.new +@filepublications_api = PulpFileClient::PublicationsFileApi.new +@fileremotes_api = PulpFileClient::RemotesFileApi.new +@tasks_api = PulpcoreClient::TasksApi.new +@uploads_api = PulpcoreClient::UploadsApi.new + + +def monitor_task(task_href) + # Polls the Task API until the task is in a completed state. + # + # Prints the task details and a success or failure message. Exits on failure. + # + # Args: + # task_href(str): The href of the task to monitor + # + # Returns: + # list[str]: List of hrefs that identify resource created by the task + task = @tasks_api.read(task_href) + until ["completed", "failed", "canceled"].include? task.state + sleep(2) + task = @tasks_api.read(task_href) + end + if task.state == 'completed' + task.created_resources + else + print("Task failed. Exiting.\n") + exit(2) + end +end + +def content_range(start, finish, total) + finish = finish > total ? total : finish + "bytes #{start}-#{finish}/#{total}" +end + +def upload_file_in_chunks(file_path) + # Uploads a file using the Uploads API + # + # The file located at 'file_path' is uploaded in chunks of 200kb. + # + # Args: + # file_path (str): path to the file being uploaded to Pulp + # + # Returns: + # upload object + response = "" + File.open(file_path, "rb") do |file| + total_size = File.size(file) + upload_data = PulpcoreClient::Upload.new({size: total_size}) + response = @uploads_api.create(upload_data) + upload_href = response.pulp_href + chunksize = 200000 + offset = 0 + sha256 = Digest::SHA256.new + until file.eof? + chunk = file.read(chunksize) + sha256.update(chunk) + begin + filechunk = Tempfile.new('fred') + filechunk.write(chunk) + filechunk.flush() + actual_chunk_size = File.size(filechunk) + response = @uploads_api.update(content_range(offset, offset + actual_chunk_size - 1, total_size), upload_href, filechunk) + offset += actual_chunk_size - 1 + ensure + filechunk.close + filechunk.unlink + end + end + upload_commit_response = @uploads_api.commit(upload_href, {sha256: sha256.hexdigest}) + created_resources = monitor_task(upload_commit_response.task) + @artifacts_api.read(created_resources[0]) + end +end + + +artifact = upload_file_in_chunks(File.new(File.expand_path(__FILE__))) + +# Create a File Remote +remote_url = 'https://fixtures.pulpproject.org/file/PULP_MANIFEST' +remote_data = PulpFileClient::FileFileRemote.new({name: 'bar38', url: remote_url}) +file_remote = @fileremotes_api.create(remote_data) + +# Create a Repository +repository_data = PulpFileClient::FileFileRepository.new({name: 'foo38'}) +file_repository = @filerepositories_api.create(repository_data) + +# Sync a Repository +repository_sync_data = PulpFileClient::RepositorySyncURL.new({remote: file_remote.pulp_href}) +sync_response = @filerepositories_api.sync(file_repository.pulp_href, repository_sync_data) + +# Monitor the sync task +created_resources = monitor_task(sync_response.task) + +repository_version_1 = @repoversions_api.read(created_resources[0]) + +# Create a FileContent from a local file +filecontent_response = @filecontent_api.create('foo.tar.gz', {file: File.new(File.expand_path(__FILE__))}) + +created_resources = monitor_task(filecontent_response.task) + +# Add the new FileContent to a repository version +repo_version_data = {add_content_units: [created_resources[0]]} +repo_version_response = @filerepositories_api.modify(file_repository.pulp_href, repo_version_data) + +# Monitor the repo version creation task +created_resources = monitor_task(repo_version_response.task) + +repository_version_2 = @repoversions_api.read(created_resources[0]) + +# List all the repository versions +@repoversions_api.list(file_repository.pulp_href) + +# Create a publication from the latest version of the repository +publish_data = PulpFileClient::FileFilePublication.new({repository: file_repository.pulp_href}) +publish_response = @filepublications_api.create(publish_data) + +# Monitor the publish task +created_resources = monitor_task(publish_response.task) +publication_href = created_resources[0] + +distribution_data = PulpFileClient::FileFileDistribution.new({name: 'baz38', base_path: 'foo38', publication: publication_href}) +distribution = @filedistributions_api.create(distribution_data) diff --git a/test_ruby.sh b/test_ruby.sh new file mode 100755 index 0000000..5d4193e --- /dev/null +++ b/test_ruby.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# coding=utf-8 + +# WARNING: DO NOT EDIT! +# +# This file was generated by plugin_template, and is managed by it. Please use +# './plugin-template --github pulp_file' to update this file. +# +# For more info visit https://github.com/pulp/plugin_template + +set -mveuo pipefail + +# make sure this script runs at the repo root + +# Needed for both starting the service and building the docs. +# Gets set in .github/settings.yml, but doesn't seem to inherited by +# this script. +# export DJANGO_SETTINGS_MODULE="pulpcore.app.settings" +# export PULP_SETTINGS="$PWD/.ci/ansible/settings/settings.py" +export PULP_URL="http://localhost:5001" +# export CONTENT_ORIGIN="http://pulp:80" + +# Configure "isolated" ruby on host machine +# https://stackoverflow.com/a/17413767 +TMPDIR="/tmp/ruby-venv" +rm -rf $TMPDIR +mkdir -p $TMPDIR/local/gems +export GEM_HOME=$TMPDIR/local/gems + +# ./generate.sh pulpcore python +# pip install ./pulpcore-client +# ./generate.sh pulp_file python +# pip install ./pulp_file-client + +# python .github/workflows/scripts/test_bindings.py + +rm -rf ./pulpcore-client +./generate.sh pulpcore ruby +pushd pulpcore-client + gem build pulpcore_client + gem install --both ./pulpcore_client-*.gem +popd + +rm -rf ./pulp_file-client +./generate.sh pulp_file ruby +pushd pulp_file-client +gem build pulp_file_client +gem install --both ./pulp_file_client-*.gem +popd + +ruby test_bindings.rb