Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/spec_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Spec Update
on:
workflow_dispatch:
schedule:
- cron: 0 0 * * *

jobs:
Update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python environment
uses: actions/setup-python@v2.1.2
with:
python-version: 2.7
- name: Get current time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY_MM_DD
utcOffset: "-08:00"
- name: Install SDK
run: |
npm install
- name: Update Modules
run: |
git submodule init
git submodule update --remote --recursive
- name: Generate Branch Name
id: git-branch
run: |
echo "::set-output name=branch::spec_update_${{ steps.current-time.outputs.formattedTime }}"
- name: Generate Num Diffs
id: git-diff-num
run: |
diffs=$(git diff --submodule spec | grep ">" | wc -l)
echo "Number of Spec diffs: $diffs"
echo "::set-output name=num-diff::$diffs"
- name: Generate Diff
id: git-diff
run: |
cd spec
gitdiff=$(git log -n ${{ steps.git-diff-num.outputs.num-diff }} --pretty="format:%n %H %n%n %b")
commit="Automated Spec Update $gitdiff"
commit="${commit//'%'/'%25'}"
commit="${commit//$'\n'/'%0A'}"
commit="${commit//$'\r'/'%0D'}"
echo "Commit Message: $commit"
echo "::set-output name=commit::$commit"
cd ..
- name: Generate New Routes
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python generate_base_client.py
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3.3.0
if: steps.git-diff-num.outputs.num-diff != 0
with:
token: ${{ secrets.SPEC_UPDATE_TOKEN }}
commit-message: |
${{ steps.git-diff.outputs.commit}}
branch: ${{ steps.git-branch.outputs.branch }}
delete-branch: true
title: 'Automated Spec Update'
body: |
${{ steps.git-diff.outputs.commit}}
base: 'master'
team-reviewers: |
owners
maintainers
draft: false
19 changes: 3 additions & 16 deletions generate_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
type=str,
help='Path to API specifications. Each must have a .stone extension.',
)
_cmdline_parser.add_argument(
'-s',
'--stone',
type=str,
help='Path to clone of stone repository.',
)

def main():
"""The entry point for the program."""
Expand All @@ -46,10 +40,6 @@ def main():

specs = [os.path.join(os.getcwd(), s) for s in specs]

stone_path = os.path.abspath('stone')
if args.stone:
stone_path = args.stone

dropbox_pkg_path = os.path.abspath(
os.path.join(os.path.dirname(sys.argv[0]), 'dropbox'))
if verbose:
Expand All @@ -60,25 +50,22 @@ def main():
subprocess.check_output(
(['python', '-m', 'stone.cli', 'python_types', dropbox_pkg_path] +
specs + ['-a', 'host', '-a', 'style'] +
['--', '-r', 'dropbox.dropbox.Dropbox.{ns}_{route}']),
cwd=stone_path)
['--', '-r', 'dropbox.dropbox.Dropbox.{ns}_{route}']))

if verbose:
print('Generating Python client')

o = subprocess.check_output(
(['python', '-m', 'stone.cli', 'python_client', dropbox_pkg_path] +
specs + ['-a', 'host', '-a', 'style', '-a', 'auth'] +
['--', '-w', 'user,app,noauth', '-m', 'base', '-c', 'DropboxBase', '-t', 'dropbox']),
cwd=stone_path)
['--', '-w', 'user,app,noauth', '-m', 'base', '-c', 'DropboxBase', '-t', 'dropbox']))
if o:
print('Output:', o)

o = subprocess.check_output(
(['python', '-m', 'stone.cli', 'python_client', dropbox_pkg_path] +
specs + ['-a', 'host', '-a', 'style', '-a', 'auth'] +
['--', '-w', 'team', '-m', 'base_team', '-c', 'DropboxTeamBase', '-t', 'dropbox']),
cwd=stone_path)
['--', '-w', 'team', '-m', 'base_team', '-c', 'DropboxTeamBase', '-t', 'dropbox']))
if o:
print('Output:', o)

Expand Down