Skip to content

Commit

Permalink
build: make ci testing conditional on engines field in package.json, …
Browse files Browse the repository at this point in the history
…move configs to Node 12 (#1418)

* build: make ci testing conditional on engines field in package.json, move configs to Node 12

Co-authored-by: Benjamin E. Coe <bencoe@google.com>
  • Loading branch information
2 people authored and Lo Ferris committed Apr 19, 2022
1 parent dbc1d4c commit 434798f
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12, 14, 16]
node: [{{metadata['engine'] | int}}, {{metadata['engine'] | int+2}}, {{metadata['engine'] | int+4}}]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion synthtool/gcp/templates/node_library/.kokoro/common.cfg

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion synthtool/gcp/templates/node_library/.kokoro/test.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion synthtool/languages/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import logging
import shutil

_REQUIRED_FIELDS = ["name", "repository"]
_REQUIRED_FIELDS = ["name", "repository", "engines"]
_TOOLS_DIRECTORY = "/synthtool"


Expand All @@ -48,6 +48,7 @@ def read_metadata():
data["repository"] = f'{repo["owner"]}/{repo["name"]}'
data["repository_name"] = repo["name"]
data["lib_install_cmd"] = f'npm install {data["name"]}'
data["engine"] = re.search(r"([0-9][0-9])", data["engines"]["node"]).group()

return data

Expand Down
72 changes: 72 additions & 0 deletions tests/fixtures/node_templates/standard/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "@google-cloud/dlp",
"description": "DLP API client for Node.js",
"version": "3.1.0",
"license": "Apache-2.0",
"author": "Google Inc",
"engines": {
"node": ">=10.0.0"
},
"repository": "googleapis/nodejs-dlp",
"main": "build/src/index.js",
"files": [
"build/protos",
"build/src"
],
"keywords": [
"google apis client",
"google api client",
"google apis",
"google api",
"google",
"google cloud platform",
"google cloud",
"cloud",
"google dlp",
"dlp",
"DLP API"
],
"scripts": {
"test": "c8 mocha build/test",
"samples-test": "cd samples/ && npm link ../ && npm install && npm test && cd ../",
"system-test": "mocha build/system-test",
"docs": "jsdoc -c .jsdoc.js",
"lint": "gts check",
"fix": "gts fix",
"docs-test": "linkinator docs",
"clean": "gts clean",
"compile": "tsc -p . && cp -r protos build/",
"compile-protos": "compileProtos src",
"predocs-test": "npm run docs",
"prepare": "npm run compile-protos && npm run compile",
"prelint": "cd samples; npm link ../; npm install",
"precompile": "gts clean",
"api-extractor": "api-extractor run --local",
"api-documenter": "api-documenter yaml --input-folder=temp"
},
"dependencies": {
"google-gax": "^2.9.2",
"protobufjs": "^6.8.0"
},
"devDependencies": {
"@types/mocha": "^8.0.0",
"@types/node": "^12.0.0",
"@types/sinon": "^9.0.0",
"c8": "^7.0.0",
"gts": "^2.0.0",
"jsdoc": "^3.5.5",
"jsdoc-fresh": "^1.0.1",
"jsdoc-region-tag": "^1.0.2",
"linkinator": "^2.0.0",
"mocha": "^8.0.0",
"null-loader": "^4.0.0",
"pack-n-play": "^1.0.0-2",
"sinon": "^10.0.0",
"ts-loader": "^8.0.0",
"typescript": "^3.8.3",
"webpack": "^5.0.0",
"webpack-cli": "^4.0.0",
"@microsoft/api-documenter": "^7.8.10",
"@microsoft/api-extractor": "^7.8.10"
}
}
6 changes: 6 additions & 0 deletions tests/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ def test_quickstart_metadata_with_snippet():
assert "samples/quickstart.js" in sample_names


def test_metadata_engines_field():
with util.chdir(FIXTURES / "node_templates" / "standard"):
metadata = node.template_metadata()
assert "10" in metadata["engine"]


def test_quickstart_metadata_without_snippet():
with util.chdir(FIXTURES / "node_templates" / "no_quickstart_snippet"):
metadata = node.template_metadata()
Expand Down

0 comments on commit 434798f

Please sign in to comment.