From 9ed02497f59885bb65b6f4997b90d83068ab84d9 Mon Sep 17 00:00:00 2001 From: ossaleon Date: Tue, 28 May 2024 10:17:58 +0200 Subject: [PATCH] build of sdk moved to sdk repo --- .bin/json_merge_generator.py | 23 --------- .github/workflows/update_client.yaml | 71 ++++------------------------ 2 files changed, 10 insertions(+), 84 deletions(-) delete mode 100644 .bin/json_merge_generator.py diff --git a/.bin/json_merge_generator.py b/.bin/json_merge_generator.py deleted file mode 100644 index d409fed..0000000 --- a/.bin/json_merge_generator.py +++ /dev/null @@ -1,23 +0,0 @@ -import os -import json - -# Directory containing the YAML files -yaml_directory = "./docs/api" - -# Output JSON file -output_json_file = "./openapi-merge.json" - -# Gather all YAML files in the directory -yaml_files = [os.path.join(yaml_directory, f) for f in os.listdir(yaml_directory) if f.endswith('.yaml')] - -# Construct the JSON structure -json_data = { - "inputs": [{"inputFile": yaml_file} for yaml_file in yaml_files], - "output": "./wordliftApiSpec.yaml" -} - -# Write the JSON data to the output file -with open(output_json_file, 'w') as json_file: - json.dump(json_data, json_file, indent=2) - -print(f"JSON file has been generated and saved to {output_json_file}") \ No newline at end of file diff --git a/.github/workflows/update_client.yaml b/.github/workflows/update_client.yaml index aaabe61..97ebb5f 100644 --- a/.github/workflows/update_client.yaml +++ b/.github/workflows/update_client.yaml @@ -7,13 +7,9 @@ on: - main paths: - "api/**" - pull_request: - types: [closed] - paths: - - "api/**" jobs: - run-commands: + update_api: # Define the OS and environment the job will run on runs-on: ubuntu-latest @@ -21,75 +17,28 @@ jobs: steps: # Step 1: Checkout the first repository - name: Checkout repository - uses: actions/checkout@v3 - with: - repository: wordlift/docs - path: "./docs" + uses: actions/checkout@v4 # Step 2: Checkout the second repository - name: Checkout second repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - repository: wordlift/wordlift-sdk - path: "./wordlift-sdk" + repository: wordlift/python-client + path: "./python-client" # step 3: Patch middleware api specification - name: Apply patch to middleware.yaml - run: | - cd docs - git apply fix_middleware_spec.patch - cd .. - - # Step 4: Set up Node.js - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: "18" # Specify the Node.js version to use - - # Step 5: Install openapi-merge-cli and openapi-generator-cli - - name: Install openapi-merge-cli - run: | - npm i openapi-merge-cli - npm i @openapitools/openapi-generator-cli + run: git apply ./patch/fix_middleware_spec.patch - # Step 6: Set up Python - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.x" - - # Step 7: Install Python dependencies - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install pytest - - # Step 8: Run the Python script to generate json for openApi-merge - - name: generate json for openApi-merge - run: python3 ./docs/bin/json_merge_generator.py - - # Step 9: Merge the YAML files - - name: Merge the yaml files - run: npx openapi-merge-cli --config ./openapi-merge.json - - # Step 10: Generate the SDK - - name: Generate the SDK - run: npx @openapitools/openapi-generator-cli generate -i ./wordliftApiSpec.yaml -o ./wordlift-sdk -g python --package-name 'Wordlift_client' --library 'asyncio' --additional-properties='generateSourceCodeOnly=true' - - # Step 11: Run tests - - name: Run tests - run: | - cd docs - pytest - cd .. + - name: Copy content from current repo to another repo + run: cp api/* python-client/api # Step 12: Commit and push the changes to the repository - name: Commit and push changes run: | - cd wordlift-sdk + cd python-client git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' git add . - git commit -m "Updated SDK" + git commit -m "Update api" git push origin main