forked from loafle/openapi-generator-original
		
	python: run the Python samples tests with GitHub Actions (#16643)
This commit is contained in:
		
							parent
							
								
									29033bf62a
								
							
						
					
					
						commit
						e5a29b6328
					
				@ -1,12 +1,11 @@
 | 
				
			|||||||
name: Python Client (Echo API)
 | 
					name: Python Client (Echo API)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
on:
 | 
					on:
 | 
				
			||||||
  push:
 | 
					 | 
				
			||||||
    paths:
 | 
					 | 
				
			||||||
      - samples/client/echo_api/python/**
 | 
					 | 
				
			||||||
  pull_request:
 | 
					  pull_request:
 | 
				
			||||||
    paths:
 | 
					    paths:
 | 
				
			||||||
      - samples/client/echo_api/python/**
 | 
					      - samples/client/echo_api/python/**
 | 
				
			||||||
 | 
					      - .github/workflows/samples-python-nextgen-client-echo-api.yaml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
jobs:
 | 
					jobs:
 | 
				
			||||||
  build:
 | 
					  build:
 | 
				
			||||||
    name: Test Python client
 | 
					    name: Test Python client
 | 
				
			||||||
@ -17,11 +16,17 @@ jobs:
 | 
				
			|||||||
        sample:
 | 
					        sample:
 | 
				
			||||||
          # clients
 | 
					          # clients
 | 
				
			||||||
          - samples/client/echo_api/python
 | 
					          - samples/client/echo_api/python
 | 
				
			||||||
 | 
					        python-version:
 | 
				
			||||||
 | 
					          - "3.7"
 | 
				
			||||||
 | 
					          - "3.8"
 | 
				
			||||||
 | 
					          - "3.9"
 | 
				
			||||||
 | 
					          - "3.10"
 | 
				
			||||||
 | 
					          #- "3.11"
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
      - uses: actions/checkout@v4
 | 
					      - uses: actions/checkout@v4
 | 
				
			||||||
      - uses: actions/setup-python@v4
 | 
					      - uses: actions/setup-python@v4
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          python-version: '3.7'
 | 
					          python-version: ${{ matrix.python-version }}
 | 
				
			||||||
      - name: Setup node.js
 | 
					      - name: Setup node.js
 | 
				
			||||||
        uses: actions/setup-node@v3
 | 
					        uses: actions/setup-node@v3
 | 
				
			||||||
      - name: Run echo server
 | 
					      - name: Run echo server
 | 
				
			||||||
@ -33,6 +38,7 @@ jobs:
 | 
				
			|||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
          pip install -r requirements.txt
 | 
					          pip install -r requirements.txt
 | 
				
			||||||
          pip install -r test-requirements.txt
 | 
					          pip install -r test-requirements.txt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      - name: Test
 | 
					      - name: Test
 | 
				
			||||||
        working-directory: ${{ matrix.sample }}
 | 
					        working-directory: ${{ matrix.sample }}
 | 
				
			||||||
        run: python -m pytest
 | 
					        run: python -m pytest
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										59
									
								
								.github/workflows/samples-python-petstore.yaml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								.github/workflows/samples-python-petstore.yaml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,59 @@
 | 
				
			|||||||
 | 
					name: "Python Client: Petstore"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					on:
 | 
				
			||||||
 | 
					  pull_request:
 | 
				
			||||||
 | 
					    paths:
 | 
				
			||||||
 | 
					      - samples/openapi3/client/petstore/python-aiohttp/**
 | 
				
			||||||
 | 
					      - samples/openapi3/client/petstore/python/**
 | 
				
			||||||
 | 
					      - .github/workflows/samples-python-petstore.yaml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					  build:
 | 
				
			||||||
 | 
					    name: Test Python client
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    strategy:
 | 
				
			||||||
 | 
					      fail-fast: false
 | 
				
			||||||
 | 
					      matrix:
 | 
				
			||||||
 | 
					        python-version:
 | 
				
			||||||
 | 
					          - "3.7"
 | 
				
			||||||
 | 
					          - "3.8"
 | 
				
			||||||
 | 
					          - "3.9"
 | 
				
			||||||
 | 
					          - "3.10"
 | 
				
			||||||
 | 
					          #- "3.11"
 | 
				
			||||||
 | 
					        sample:
 | 
				
			||||||
 | 
					          - samples/openapi3/client/petstore/python-aiohttp
 | 
				
			||||||
 | 
					          - samples/openapi3/client/petstore/python
 | 
				
			||||||
 | 
					    services:
 | 
				
			||||||
 | 
					      petstore-api:
 | 
				
			||||||
 | 
					        image: swaggerapi/petstore
 | 
				
			||||||
 | 
					        ports:
 | 
				
			||||||
 | 
					          - 80:8080
 | 
				
			||||||
 | 
					        env:
 | 
				
			||||||
 | 
					          SWAGGER_HOST: http://petstore.swagger.io
 | 
				
			||||||
 | 
					          SWAGGER_BASE_PATH: /v2
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					      - uses: actions/checkout@v4
 | 
				
			||||||
 | 
					      - uses: actions/setup-python@v4
 | 
				
			||||||
 | 
					        id: py
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          python-version: ${{ matrix.python-version }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - name: Cache
 | 
				
			||||||
 | 
					        uses: actions/cache@v3
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          key: ${{ runner.os }}-python-${{ steps.py.outputs.python-version }}-
 | 
				
			||||||
 | 
					          path: |
 | 
				
			||||||
 | 
					            ~/.cache/pypoetry/virtualenvs/
 | 
				
			||||||
 | 
					            ~/.local/pipx/venvs/poetry/
 | 
				
			||||||
 | 
					            .mypy_cache/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - name: Install poetry
 | 
				
			||||||
 | 
					        run: pipx install --python '${{ steps.py.outputs.python-path }}' poetry
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - name: Install
 | 
				
			||||||
 | 
					        working-directory: ${{ matrix.sample }}
 | 
				
			||||||
 | 
					        run: poetry install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      - name: Test
 | 
				
			||||||
 | 
					        working-directory: ${{ matrix.sample }}
 | 
				
			||||||
 | 
					        run: poetry run pytest -v
 | 
				
			||||||
@ -19,7 +19,7 @@ from dateutil.parser import parse
 | 
				
			|||||||
import petstore_api
 | 
					import petstore_api
 | 
				
			||||||
import petstore_api.configuration
 | 
					import petstore_api.configuration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HOST = 'http://petstore.swagger.io/v2'
 | 
					HOST = 'http://localhost/v2'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ApiClientTests(unittest.TestCase):
 | 
					class ApiClientTests(unittest.TestCase):
 | 
				
			||||||
 | 
				
			|||||||
@ -24,7 +24,7 @@ import json
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import urllib3
 | 
					import urllib3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HOST = 'http://petstore.swagger.io/v2'
 | 
					HOST = 'http://localhost/v2'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TimeoutWithEqual(urllib3.Timeout):
 | 
					class TimeoutWithEqual(urllib3.Timeout):
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user