Skip to content

CI comparing ioki-ruby with OpenAPI json files from docs #916

CI comparing ioki-ruby with OpenAPI json files from docs

CI comparing ioki-ruby with OpenAPI json files from docs #916

Workflow file for this run

name: CI comparing ioki-ruby with OpenAPI json files from docs
# Expects:
on: workflow_dispatch
permissions:
contents: write
pull-requests: write
jobs:
process-openapi-json:
runs-on: ubuntu-22.04
steps:
- name: Pull repository
uses: actions/checkout@v6
- name: Bundle install and cache result
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Download OpenAPI JSON
run: |
mkdir spec/fixtures/open_api_definitions
cd spec/fixtures/open_api_definitions
curl -o driver_api.json --url "${{ secrets.GITLAB_BASE_URL }}public%2Frefs%2Fmain%2Fdriver-api%2F${{ env.DRIVER_API_VERSION }}%2Ejson/raw?ref=main" --header "PRIVATE-TOKEN: ${{ secrets.GITLAB_API_DOCS_ACCESS_TOKEN }}"
curl -o operator_api.json --url "${{ secrets.GITLAB_BASE_URL }}public%2Frefs%2Fmain%2Foperator-api%2F${{ env.OPERATOR_API_VERSION }}%2Ejson/raw?ref=main" --header "PRIVATE-TOKEN: ${{ secrets.GITLAB_API_DOCS_ACCESS_TOKEN }}"
curl -o passenger_api.json --url "${{ secrets.GITLAB_BASE_URL }}public%2Frefs%2Fmain%2Fpassenger-api%2F${{ env.PASSENGER_API_VERSION }}%2Ejson/raw?ref=main" --header "PRIVATE-TOKEN: ${{ secrets.GITLAB_API_DOCS_ACCESS_TOKEN }}"
curl -o platform_api.json --url "${{ secrets.GITLAB_BASE_URL }}public%2Frefs%2Fmain%2Fplatform-api%2F${{ env.PLATFORM_API_VERSION }}%2Ejson/raw?ref=main" --header "PRIVATE-TOKEN: ${{ secrets.GITLAB_API_DOCS_ACCESS_TOKEN }}"
curl -o webhooks_api.json --url "${{ secrets.GITLAB_BASE_URL }}public%2Frefs%2Fmain%2Fwebhooks%2F${{ env.WEBHOOKS_API_VERSION }}%2Ejson/raw?ref=main" --header "PRIVATE-TOKEN: ${{ secrets.GITLAB_API_DOCS_ACCESS_TOKEN }}"
env:
DRIVER_API_VERSION: v2
OPERATOR_API_VERSION: v20210101
PASSENGER_API_VERSION: v1
PLATFORM_API_VERSION: v20210101
WEBHOOKS_API_VERSION: v20210101
shell: bash
- name: Run rspec
id: rspec_tests
continue-on-error: true
run: |
source .github/ci_workflow.env
bundle exec rspec
shell: bash
- name: Define Target Branch Name
if: steps.rspec_tests.outcome == 'failure'
id: pr_vars
run: echo "branch_name=actions/automated-open-api-failure-pr" >> $GITHUB_OUTPUT
shell: bash
- name: Repair OpenAPI
if: steps.rspec_tests.outcome == 'failure'
run: |
echo "RSpec tests failed. Running 'rake ioki:openapi:repair' to attempt fixes..."
bundle exec rake ioki:openapi:repair
shell: bash
- name: Create or Update Pull Request
if: steps.rspec_tests.outcome == 'failure'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "fix: Automated PR due to RSpec test failures"
title: "Automated OpenAPI Fix: Inconsistency Detected"
body: |
🚨 **Action Required: OpenAPI RSpec Tests Failed (Workflow Run #${{ github.run_id }})** 🚨
This Pull Request was automatically created/updated on the branch `${{ steps.pr_vars.outputs.branch_name }}` because the OpenAPI RSpec tests failed during the latest workflow run.
The commit in this PR includes **automated fixes generated by the `rake ioki:openapi:repair` task**. These changes are an attempt to address the discrepancies that likely caused the RSpec test failures.
**⚠️ Important - Please Review Carefully:**
* **Verify Changes:** Thoroughly review the automated changes to ensure they are correct and accurately reflect the intended API behavior.
* **Check RSpec Logs:** Consult the RSpec logs from the GitHub Actions workflow run for detailed error messages and context.
* **Potential Imperfections:** The automated fixes are based on predefined rules and may not be perfect in all scenarios. Human oversight is crucial.
* **Specific Caution for Parameters:** Be aware that the repair task might set parameter attributes to include `read`, `create`, and `update` by default. Please verify if these are appropriate for each affected parameter and adjust as necessary.
Your attention is needed to validate these automated changes and ensure the API specification is accurate.
Please create a new subbranch from this PR to avoid overwriting the changes in this PR.
branch: ${{ steps.pr_vars.outputs.branch_name }}
base: main
labels: "PR: ready for review,PR: do not merge"