mirror of
https://github.com/thegeneralist01/twitter-openapi
synced 2026-01-09 23:00:24 +01:00
100 lines
2.8 KiB
YAML
100 lines
2.8 KiB
YAML
name: test-python
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [labeled]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build_and_preview:
|
|
runs-on: ubuntu-latest
|
|
name: Test
|
|
if: contains(github.event.pull_request.labels.*.name, 'safe to test')
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
ref: "${{ github.event.pull_request.merge_commit_sha }}"
|
|
|
|
# Openapi Generator Setup
|
|
- name: Get OpenJDK 11
|
|
uses: actions/setup-java@v2
|
|
with:
|
|
distribution: "temurin"
|
|
java-version: 11
|
|
|
|
- name: Get Java version
|
|
run: java -version
|
|
|
|
- name: Get Openapi Generator cache file
|
|
id: openapi-generator-cache
|
|
run: echo "file=openapi-generator-cli.jar" >> $GITHUB_OUTPUT
|
|
|
|
- name: Openapi Generator cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ steps.openapi-generator-cache.outputs.file }}
|
|
key: ${{ runner.os }}-openapi-generator-${{ hashFiles('openapi-generator-cli.jar') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-openapi-generator-
|
|
|
|
- name: Get Openapi Generator
|
|
run: |
|
|
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.13.0/openapi-generator-cli-7.13.0.jar -O openapi-generator-cli.jar --no-verbose
|
|
if: steps.openapi-generator-cache.outputs.cache-hit != 'true'
|
|
|
|
# Python Setup
|
|
- name: Set up Python 3.10
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: "3.10"
|
|
architecture: "x64"
|
|
|
|
- name: Get Python version
|
|
run: python -V
|
|
|
|
- name: Get pip cache dir
|
|
id: pip-cache
|
|
run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
|
|
|
|
- name: pip cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ${{ steps.pip-cache.outputs.dir }}
|
|
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pip-
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
|
|
# generate
|
|
- name: Build twitter-openapi
|
|
run: |
|
|
python tools/build.py
|
|
|
|
# clean up dependencies
|
|
- name: Clean up dependencies
|
|
run: |
|
|
pip uninstall -y -r requirements.txt
|
|
|
|
# generate
|
|
- name: Generate Python client
|
|
run: |
|
|
java -jar openapi-generator-cli.jar generate -c test/python/openapi-generator-config.yaml -g python
|
|
|
|
# test
|
|
- name: Test Python client
|
|
run: |
|
|
pip install ./python_generated
|
|
|
|
- name: Run Python client test
|
|
run: |
|
|
python test/python/test_serialize.py
|
|
env:
|
|
TWITTER_SESSION: ${{ secrets.TWITTER_SESSION }}
|
|
ERROR_UNCATCHED: "False"
|
|
SLEEP_TIME: 2
|
|
CUESOR_TEST_COUNT: 5
|