Skip to content

Commit

Permalink
build: fix OwlBot configuration (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe authored Apr 7, 2021
1 parent 6a3dadf commit 0db54a1
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 81 deletions.
21 changes: 5 additions & 16 deletions packages/google-cloud-documentai/.github/.OwlBot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,9 @@
docker:
image: gcr.io/repo-automation-bots/owlbot-nodejs:latest

deep-remove-regex:
- /owl-bot-staging

deep-copy-regex:
# Source Code:
- source: /google/cloud/documentai/.*/documentai-.*-nodejs/src/(.*)
dest: /src/$1
rm-dest: /src/.*
# Protos:
- source: /google/cloud/documentai/.*/documentai-.*-nodejs/protos/google/cloud/documentai/(.*)
dest: /protos/google/cloud/documentai/$1
rm-dest: /protos/google/cloud/documentai/*
# Unit tests:
- source: /google/cloud/documentai/.*/documentai-.*-nodejs/test/(.*)
dest: /test/$1
rm-dest: /test/$1
# TypeScript integration tests:
- source: /google/cloud/documentai/.*/documentai-.*-nodejs/system-test/(.*)
dest: /system-test/$1
rm-dest: /system-test/$1
- source: /google/cloud/documentai/(.*)/.*-nodejs/(.*)
dest: /owl-bot-staging/$1/$2
3 changes: 2 additions & 1 deletion packages/google-cloud-documentai/.repo-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"distribution_name": "@google-cloud/documentai",
"api_id": "documentai.googleapis.com",
"requires_billing": true,
"codeowner_team": "@googleapis/ml-apis"
"codeowner_team": "@googleapis/ml-apis",
"default_version": "v1beta3"
}
31 changes: 24 additions & 7 deletions packages/google-cloud-documentai/owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,32 @@
import synthtool as s
import synthtool.gcp as gcp
import synthtool.languages.node as node
import json
import logging
from pathlib import Path

# Infer version from src directory:
versions = []
default_version = 'v1beta3'
for directory in os.listdir('./src'):
if os.path.isdir(os.path.join('./src', directory)):
versions.append(directory)
name = 'documentai'
# Load the default version defined in .repo-metadata.json.
default_version = json.load(open(".repo-metadata.json", "rt"))["default_version"]
staging = Path("owl-bot-staging")

if staging.is_dir():
# Collect the subdirectories of the staging directory.
versions = [v.name for v in staging.iterdir() if v.is_dir()]
# Reorder the versions so the default version always comes last.
versions = [v for v in versions if v != default_version] + [default_version]
# Copy each version directory into the root.
for version in versions:
library = staging / version
_tracked_paths.add(library)
s_copy([library], excludes=["README.md", "package.json", "src/index.ts"])
# The staging directory should never be merged into the main branch.
shutil.rmtree(staging)
else:
# Collect the subdirectories of the src directory.
src = Path("src")
versions = [v.name for v in src.iterdir() if v.is_dir()]
# Reorder the versions so the default version always comes last.
versions = [v for v in versions if v != default_version] + [default_version]

## Note: this API only supports regional endpoints and does not support default scopes.
s.replace(f"src/*/document_*_service_client.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/google-cloud-documentai/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
// ** https://github.com/googleapis/synthtool **
// ** All changes to this file may be overwritten. **

import * as v1beta3 from './v1beta3';
import * as v1beta2 from './v1beta2';
import * as v1beta3 from './v1beta3';

const DocumentProcessorServiceClient = v1beta3.DocumentProcessorServiceClient;
type DocumentProcessorServiceClient = v1beta3.DocumentProcessorServiceClient;

export {v1beta3, v1beta2, DocumentProcessorServiceClient};
export default {v1beta3, v1beta2, DocumentProcessorServiceClient};
export {v1beta2, v1beta3, DocumentProcessorServiceClient};
export default {v1beta2, v1beta3, DocumentProcessorServiceClient};
import * as protos from '../protos/protos';
export {protos};
54 changes: 0 additions & 54 deletions packages/google-cloud-documentai/synth.py

This file was deleted.

0 comments on commit 0db54a1

Please sign in to comment.