-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: add TypeScript samples support #3029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 20 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
1c6785f
chore: add owlbot
kweinmeister 9146d04
add new lines
kweinmeister 3f8f03b
Add owlbot.py
kweinmeister f79385c
Merge branch 'main' into owlbot
kweinmeister bf97dd6
Rename .Owlbot.yaml to .OwlBot.yaml
kweinmeister 5a2bd95
Rename .Owlbot.lock.yaml to .OwlBot.lock.yaml
kweinmeister 1ccd206
updates
kweinmeister 76805b9
test typeless bot
kweinmeister 8894f66
cleanup owlbot.py
kweinmeister 1584b87
add typescript support for tests
kweinmeister d966485
update copyright year
kweinmeister 264762e
update copyright year
kweinmeister c9f5e20
add ts-node dependency
kweinmeister 369b892
update ts support
kweinmeister 47b39c7
linting
kweinmeister ee4c11d
remove comment
kweinmeister 56c1781
add npm build step
kweinmeister d99e884
change build cmd
kweinmeister 84402f2
test updating pr
kweinmeister 40d3af9
update comments
kweinmeister 009643d
updated owlbot yaml
kweinmeister 436d73d
Update .github/.OwlBot.lock.yaml
kweinmeister 1283f94
Update .OwlBot.lock.yaml
kweinmeister 7572152
update owlbot yaml
kweinmeister 8e9a978
Merge branch 'owlbot' of https://github.com/GoogleCloudPlatform/nodej…
kweinmeister b0adc93
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] bc3ce86
remove extra comment
kweinmeister a5f4b43
Merge branch 'owlbot' of https://github.com/GoogleCloudPlatform/nodej…
kweinmeister bb7620f
Update createJob.js
kweinmeister 4376bd7
update tsconfig
kweinmeister 3cd9308
Merge branch 'owlbot' of https://github.com/GoogleCloudPlatform/nodej…
kweinmeister e8a0f70
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] eaaf2dc
add export filter
kweinmeister a243bfb
update filter
kweinmeister b72636d
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] 98aeea7
owlbot update
kweinmeister 3f31f87
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] c76278f
owlbot update
kweinmeister ed3e3d1
Merge branch 'owlbot' of https://github.com/GoogleCloudPlatform/nodej…
kweinmeister 691d6e3
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] daa6f0b
final updates
kweinmeister 701ed63
license
kweinmeister 26a48aa
update linter
kweinmeister acf9c9a
add build step
kweinmeister 670b4aa
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] 608e912
Merge branch 'main' into owlbot
kweinmeister 950a2df
more updates
kweinmeister 67c815d
updates
kweinmeister 2a6ec44
eslint
kweinmeister 629c488
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] e0e6709
fix gts check
kweinmeister 79008da
Merge branches 'owlbot' and 'owlbot' of https://github.com/GoogleClou…
kweinmeister 550d1e9
reduce ecmascript version
kweinmeister 002a9bc
fixes
kweinmeister 059cb4c
add express types
kweinmeister f324630
skiplibcheck
kweinmeister 179febb
remove global tsconfig
kweinmeister 8a531d6
use root gts rules
kweinmeister 82f4b0b
add root=true
kweinmeister 9a7ea47
add extends to individual dirs
kweinmeister 1ab5bba
update workflow
kweinmeister 798e752
reorganize
kweinmeister e2422fd
update ts workflow
kweinmeister 870e716
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] 9512d97
revert ccai change
kweinmeister d2ddeb7
Merge branch 'owlbot' of https://github.com/GoogleCloudPlatform/nodej…
kweinmeister 2876193
revert ccai change part deux
kweinmeister a543a43
fix spacing
kweinmeister f26148f
appengine include ts only
kweinmeister 283462e
eslintignore
kweinmeister 7dfaee8
update package json
kweinmeister d28c73f
exclude test files
kweinmeister 8ade82e
Merge branch 'main' into owlbot
kweinmeister 5fb2233
fix newline
kweinmeister 61b0563
updates based on feedback
kweinmeister 9ab4f3d
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] a85d7b8
Merge branch 'main' into owlbot
kweinmeister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
docker: | ||
image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs-mono-repo:latest | ||
digest: sha256:85bf089b45ad70d1ec02d9d628a0051a06bb63fb79f6b740f787d1a34347f732 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
docker: | ||
image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs-mono-repo:latest | ||
|
||
deep-remove-regex: | ||
- /owl-bot-staging | ||
|
||
deep-copy-regex: | ||
- source: (.*)/(.*).js | ||
dest: /owl-bot-staging/$1/$2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import re | ||
import subprocess | ||
from pathlib import Path | ||
|
||
from synthtool import shell | ||
from synthtool.log import logger | ||
|
||
_TOOLS_DIRECTORY = "/synthtool" | ||
_EXCLUDED_DIRS = [r"node_modules", r"^\."] | ||
|
||
|
||
def walk_through_owlbot_dirs(dir: Path, search_for_changed_files: bool) -> list[str]: | ||
""" | ||
Walks through all sample directories | ||
Returns: | ||
A list of directories | ||
""" | ||
owlbot_dirs: list[str] = [] | ||
packages_to_exclude = _EXCLUDED_DIRS | ||
if search_for_changed_files: | ||
try: | ||
# Need to run this step first in the post processor since we only clone | ||
# the branch the PR is on in the Docker container | ||
output = subprocess.run( | ||
["git", "fetch", "origin", "main:main", "--deepen=200"] | ||
) | ||
output.check_returncode() | ||
except subprocess.CalledProcessError as e: | ||
if e.returncode == 128: | ||
logger.info(f"Error: ${e.output}; skipping fetching main") | ||
else: | ||
raise e | ||
for path_object in dir.glob("**/package.json"): | ||
object_dir = str(Path(path_object).parents[0]) | ||
if path_object.is_file() and object_dir != str(dir) and not re.search( | ||
"(?:% s)" % "|".join(packages_to_exclude), str(Path(path_object)) | ||
): | ||
if search_for_changed_files: | ||
if ( | ||
subprocess.run( | ||
[ | ||
"git", | ||
"diff", | ||
"--quiet", | ||
"main...", | ||
object_dir | ||
] | ||
).returncode | ||
== 1 | ||
): | ||
owlbot_dirs.append(object_dir) | ||
else: | ||
owlbot_dirs.append(object_dir) | ||
for path_object in dir.glob("owl-bot-staging/*"): | ||
owlbot_dirs.append( | ||
f"{Path(path_object).parents[1]}/packages/{Path(path_object).name}" | ||
) | ||
return owlbot_dirs | ||
|
||
|
||
def typeless_samples_hermetic(output_path: str, targets: str, hide_output: bool=False) -> None: | ||
""" | ||
Converts TypeScript samples in the current Node.js library | ||
to JavaScript samples. Run this step before fix() and friends. | ||
Assumes that typeless-sample-bot is already installed in a well | ||
known location on disk (node_modules/.bin). | ||
This is currently an optional, opt-in part of an individual repo's | ||
OwlBot.py, and must be called from there before calling owlbot_main. | ||
""" | ||
logger.debug("Run typeless sample bot") | ||
shell.run( | ||
[ | ||
f"{_TOOLS_DIRECTORY}/node_modules/.bin/typeless-sample-bot", | ||
"--outputpath", | ||
output_path, | ||
"--targets", | ||
targets, | ||
"--recursive", | ||
], | ||
check=False, | ||
hide_output=hide_output, | ||
) | ||
|
||
|
||
# Retrieve list of directories | ||
dirs: list[str] = walk_through_owlbot_dirs(Path.cwd(), search_for_changed_files=True) | ||
for d in dirs: | ||
logger.debug(f"Directory: {d}") | ||
# Run typeless bot to convert from TS -> JS | ||
typeless_samples_hermetic(output_path=d, targets=d) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"strict": true, | ||
"noImplicitAny": false, | ||
"moduleResolution": "node", | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.