1
Fork 0
mirror of https://github.com/thegeneralist01/twitter-openapi synced 2026-01-11 23:50:26 +01:00

update github acction

Signed-off-by: ふぁ <yuki@yuki0311.com>
This commit is contained in:
ふぁ 2023-07-30 05:55:44 +09:00
parent 86315f25a0
commit 0b34065deb
No known key found for this signature in database
GPG key ID: 83A8A5E74872A8AA
7 changed files with 114 additions and 26 deletions

87
.github/workflows/test-build.yaml vendored Normal file
View file

@ -0,0 +1,87 @@
name: build-test
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# 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://github.com/fa0311/openapi-generator/releases/download/twitter_openapi_python_1.2.0/openapi-generator-cli.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
run: |
java -jar openapi-generator-cli.jar generate -c test/python/openapi-generator-config.yaml -g python
java -jar openapi-generator-cli.jar generate -c test/dart-dio/openapi-generator-config.yaml -g dart-dio
java -jar openapi-generator-cli.jar generate -c test/typescript-fetch/openapi-generator-config.yaml -g typescript-fetch

View file

@ -1,21 +1,12 @@
name: test-python
on:
# auto review
pull_request:
paths-ignore:
- "test/**"
- ".github/**"
branches:
- master
env:
TWITTER_SESSION: ${{secrets.TWITTER_SESSION}}
on: ["pull_request_target"]
jobs:
test:
name: Test
build_and_preview:
runs-on: ubuntu-latest
name: Test
environment: twitter_session
steps:
- uses: actions/checkout@v3
@ -43,13 +34,14 @@ jobs:
- name: Get Openapi Generator
run: |
wget https://github.com/fa0311/openapi-generator/releases/download/twitter_openapi_python_1.2.0/openapi-generator-cli.jar -O openapi-generator-cli.jar --no-verbose --show-progress --no-clobber
wget https://github.com/fa0311/openapi-generator/releases/download/twitter_openapi_python_1.2.0/openapi-generator-cli.jar -O openapi-generator-cli.jar --no-verbose
if: steps.openapi-generator-cache.outputs.cache-hit != 'true'
# Python Setup
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: "3.10"
architecture: "x64"
- name: Get Python version
@ -96,4 +88,4 @@ jobs:
run: |
python test/python/test_serialize.py
env:
TWITTER_SESSION: ${{secrets.TWITTER_SESSION}}
TWITTER_SESSION: ${{ secrets.TWITTER_SESSION }}

View file

@ -0,0 +1,2 @@
inputSpec: dist/compatible/openapi-3.0.yaml
outputDir: dart_dio_generated

View file

@ -1,4 +1,5 @@
import json
import base64
from tweepy_authlib import CookieSessionUserHandler
auth_handler = CookieSessionUserHandler(
@ -9,4 +10,5 @@ auth_handler = CookieSessionUserHandler(
cookies = auth_handler.get_cookies()
print(json.dumps(cookies.get_dict()))
data = json.dumps(cookies.get_dict())
print(base64.b64encode(data.encode("utf-8")).decode("utf-8"))

View file

@ -1,8 +1,4 @@
inputSpec: dist/compatible/openapi-3.0.yaml
outputDir: python_generated
packageName: python_generated
packageVersion: 0.0.1
projectName: python_generated
useOneOfDiscriminatorLookup: true

View file

@ -1,7 +1,8 @@
import json
import os
import logging
import python_generated as pt
import base64
import openapi_client as pt
from pathlib import Path
@ -12,7 +13,8 @@ if Path("cookie.json").exists():
with open("cookie.json", "r") as f:
cookies = json.load(f)
else:
cookies = json.loads(os.environ["TWITTER_SESSION"])
data = base64.b64decode(os.environ["TWITTER_SESSION"]).decode("utf-8")
cookies = json.loads(data)
cookies_str = "; ".join([f"{k}={v}" for k, v in cookies.items()])
@ -65,6 +67,9 @@ for x in [pt.DefaultApi, pt.TweetApi, pt.UserApi, pt.UserListApi]:
except Exception as e:
logger.error(f"{key}")
logger.error(e)
import traceback
logger.error(traceback.print_exc())
error_count += 1
if error_count > 0:

View file

@ -0,0 +1,4 @@
inputSpec: dist/compatible/openapi-3.0.yaml
outputDir: typescript_fetch_generated
legacyDiscriminatorBehavior: false