Skip to content
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

build: make tests run faster #4205

Merged
merged 98 commits into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from 96 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
138e231
attempt1
sofisl Apr 24, 2023
0a4110a
retry
sofisl Apr 24, 2023
e3aede8
retry
sofisl Apr 24, 2023
2852e1e
retry
sofisl Apr 24, 2023
ee931df
retry
sofisl Apr 24, 2023
11ea3dc
retry
sofisl Apr 24, 2023
b3d5f5a
retry
sofisl Apr 25, 2023
e334f94
delete old jobs
sofisl Apr 25, 2023
e585fc1
retry
sofisl Apr 25, 2023
ad992e2
Update deletecloudbuild.sh
sofisl Apr 25, 2023
2dcaec5
merge conflict
sofisl Apr 25, 2023
0324464
retry dockerfile
sofisl Apr 25, 2023
f5a30cc
update single test
sofisl Apr 25, 2023
d621b15
use curl to install pnpm
sofisl Apr 25, 2023
4222139
retry
sofisl Apr 25, 2023
39cc661
retry
sofisl Apr 25, 2023
77d53f2
retry
sofisl Apr 25, 2023
8f07616
retry
sofisl Apr 25, 2023
72b8e50
retry
sofisl Apr 25, 2023
c560514
which pnpm
sofisl Apr 25, 2023
e586ef4
retry
sofisl Apr 25, 2023
1706f3a
retry
sofisl Apr 26, 2023
fac653b
retry
sofisl Apr 26, 2023
9c5ceff
retry
sofisl Apr 26, 2023
3eb9a94
retry
sofisl Apr 26, 2023
64ab9b8
retry
sofisl Apr 26, 2023
0439945
retry
sofisl Apr 26, 2023
37eca92
retry
sofisl Apr 26, 2023
d4a0f34
retry
sofisl Apr 26, 2023
c15c2d6
retry
sofisl Apr 26, 2023
f9493f7
retry
sofisl Apr 26, 2023
2e9671c
retry
sofisl Apr 26, 2023
ba72dd6
retry
sofisl Apr 26, 2023
c4871c0
retry
sofisl Apr 26, 2023
09ce8be
retry
sofisl Apr 26, 2023
b25218c
retry
sofisl Apr 26, 2023
1b14c6b
retry
sofisl Apr 26, 2023
c2c607f
retry
sofisl Apr 26, 2023
a620295
retry
sofisl Apr 26, 2023
70c7500
retry
sofisl Apr 26, 2023
32889c2
retry
sofisl Apr 26, 2023
e2cd3f4
update package.json
sofisl Apr 26, 2023
20a31e0
retretry
sofisl Apr 26, 2023
6ea9768
retry
sofisl Apr 26, 2023
b51c842
retry
sofisl Apr 26, 2023
8a3c36d
retry
sofisl Apr 26, 2023
5d31751
retry
sofisl Apr 26, 2023
5773d2b
retry
sofisl Apr 26, 2023
ab8dcb1
retry
sofisl Apr 26, 2023
a5097c9
retry
sofisl Apr 26, 2023
9159e18
retry
sofisl Apr 26, 2023
28f3766
retry
sofisl Apr 26, 2023
ae04c8e
mretry
sofisl Apr 26, 2023
b59fdbf
retry
sofisl Apr 27, 2023
27bba5f
retry
sofisl Apr 27, 2023
56a86c6
retry
sofisl Apr 27, 2023
26c4946
remove lockfile
sofisl Apr 27, 2023
496ae1b
revert change to tsconfig
sofisl Apr 27, 2023
aa876d0
retry
sofisl Apr 27, 2023
507a1cd
retry
sofisl Apr 27, 2023
dcb17f9
retry
sofisl Apr 27, 2023
c485713
retry
sofisl Apr 27, 2023
07f8157
retry
sofisl Apr 27, 2023
c46717a
retry
sofisl Apr 27, 2023
73b7c35
retry
sofisl Apr 27, 2023
dcab75d
retry
sofisl Apr 27, 2023
0c6d3c5
retry
sofisl Apr 27, 2023
044835c
retry
sofisl Apr 27, 2023
893fa57
retry
sofisl Apr 27, 2023
2df831d
retry
sofisl Apr 27, 2023
72153c5
changes to all package.json
sofisl Apr 28, 2023
da84cb7
undo changes to gapic-node-templating
sofisl Apr 28, 2023
ae0845b
undo changes to protos
sofisl Apr 28, 2023
3c0c1cb
modify conditional tests
sofisl Apr 28, 2023
0720375
retry
sofisl Apr 28, 2023
3dc3236
undo changes to tsconfig
sofisl Apr 28, 2023
0983ffc
fix up outlier packageJsons
sofisl Apr 28, 2023
5f29fcf
update npm link command
sofisl Apr 28, 2023
5464443
update test commands
sofisl Apr 28, 2023
eb78ffd
change testing to actions
sofisl Apr 29, 2023
a312cca
update presubmit
sofisl Apr 29, 2023
b02415a
less tests for lint
sofisl Apr 29, 2023
1a40715
retry
sofisl Apr 29, 2023
5360579
retry lint
sofisl Apr 29, 2023
c31d454
retry
sofisl May 1, 2023
3b55548
retry
sofisl May 1, 2023
bbd4f4c
retry
sofisl May 1, 2023
99812ca
potentially remove an extra step
sofisl May 1, 2023
0ac43c9
remove soon-ton-to-be deprecated packages
sofisl May 1, 2023
c3d2e62
update snapshot
sofisl May 1, 2023
3529c3c
move unit tests to github actions
sofisl May 1, 2023
c94e1b7
update header check
sofisl May 1, 2023
006d556
fix lint issue
sofisl May 1, 2023
cffd1c2
make change back to system
sofisl May 2, 2023
2864bc3
fix lint and reduce system package command
sofisl May 2, 2023
0f3c66c
update SRS
sofisl May 2, 2023
52675ff
cleanup changes
sofisl May 3, 2023
2c02339
Update deletecloudbuild.sh
sofisl May 3, 2023
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
6 changes: 3 additions & 3 deletions .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ branchProtectionRules:
- "samples-presubmit-node14-with-credentials (long-door-651)"
- "samples-presubmit-node14 (long-door-651)"
- "units (14)"
- "unit-presubmit-node16 (long-door-651)"
- "unit-presubmit-node18 (long-door-651)"
- "unit-presubmit-node12 (long-door-651)"
- "units (12)"
- "units (16)"
- "units (18)"
# List of explicit permissions to add (additive only)
permissionRules:
# Team slug to add to repository permissions
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/continuous.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
node: [14]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: pnpm/action-setup@v2
with:
node-version: ${{ matrix.node }}
version: 7.32.2
- run: node --version
- run: ci/run_conditional_tests.sh
name: Check lint
Expand All @@ -24,12 +24,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [14]
node: [12, 14, 16, 18]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: pnpm/action-setup@v2
with:
node-version: ${{ matrix.node }}
version: ^6.24.1
- run: node --version
- run: ci/run_conditional_tests.sh
name: Run unit tests
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/presubmit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
node: [14]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: pnpm/action-setup@v2
with:
node-version: ${{ matrix.node }}
version: 7.32.2
- run: node --version
- run: ci/run_conditional_tests.sh
name: Check lint
Expand All @@ -22,12 +22,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [14]
node: [12, 14, 16, 18]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: pnpm/action-setup@v2
with:
node-version: ${{ matrix.node }}
version: ^6.24.1
- run: node --version
- run: ci/run_conditional_tests.sh
name: Run unit tests
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ packages/*/CONTRIBUTORS
packages/*/COPYING
package-lock.json
__pycache__
packages/*/pnpm-lock.yaml
containers/*/pnpm-lock.yaml
12 changes: 9 additions & 3 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,22 @@ RUN curl https://github.com/googleapis/repo-automation-bots/releases/download/fl
-o /bin/flakybot -s -L \
&& chmod +x /bin/flakybot

FROM node:${NODE_VERSION}-alpine
# RUN mkdir -p /usr/local/pnpm
# RUN curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=6.34.0 sh -
ENV PNPM_VERSION=7.32.2
RUN curl https://get.pnpm.io/install.sh | ENV="$HOME/.shrc" SHELL="$(which sh)" sh -

COPY --from=build /bin/flakybot /bin/flakybot
FROM node:${NODE_VERSION}-alpine

# Hack for not found error with flakybot
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2

COPY --from=build /usr/local/gcloud /usr/local/gcloud
COPY --from=build /bin/flakybot /bin/flakybot
COPY --from=build /root/.local/share/pnpm /root/.local/share/pnpm

RUN apk add --no-cache git bash python3

ENV PATH $PATH:/usr/local/gcloud/google-cloud-sdk/bin
# ENV PATH=$PATH:/usr/local/gcloud/google-cloud-sdk/bin
ENV PNPM_HOME=/root/.local/share/pnpm
ENV PATH=$PNPM_HOME:$PATH
5 changes: 5 additions & 0 deletions ci/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ steps:
'--push-retry=3',
'--image-fs-extract-retry=3'
]
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: "bash"
args: ["ci/deletecloudbuild.sh"]
env:
- 'REF_NAME=${REF_NAME}'
- name: gcr.io/${PROJECT_ID}/google-cloud-node-${_NODE_VERSION}
id: "run-tests"
timeout: 32400s
Expand Down
5 changes: 5 additions & 0 deletions ci/deletecloudbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
now=$(date -u -d "-15 min" +"%Y-%m-%dT%H:%M:%SZ")
gcloud builds list --format="value(id)" --filter="substitutions.REF_NAME="$REF_NAME" AND status="WORKING" AND create_time<"$now"" | while IFS= read -r line ; do
echo "gcloud builds cancel "$line""
gcloud builds cancel "$line"
done
19 changes: 0 additions & 19 deletions ci/export/unit-presubmit-node12.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions ci/export/unit-presubmit-node16.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions ci/export/unit-presubmit-node18.yaml

This file was deleted.

10 changes: 1 addition & 9 deletions ci/export_triggers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,4 @@ for NODE_VERSION in ${NODE_VERSIONS[@]}; do
gcloud beta builds triggers export "samples-nightly-node${NODE_VERSION}" --destination "ci/export/samples-nightly-node${NODE_VERSION}.yaml"
echo "exporting presubmit build for node${NODE_VERSION} with credentials"
gcloud beta builds triggers export "samples-presubmit-node${NODE_VERSION}-with-credentials" --destination "ci/export/samples-presubmit-node${NODE_VERSION}-with-credentials.yaml"
done

# Since we don't want to run nightly, presubmit, and continuous for node 16 and node 18, adding these outside of the loop
echo "exporting presubmit unit build for node12 unit tests"
gcloud beta builds triggers export "unit-presubmit-node12" --destination "ci/export/unit-presubmit-node12.yaml"
echo "exporting presubmit unit build for node16 unit tests"
gcloud beta builds triggers export "unit-presubmit-node16" --destination "ci/export/unit-presubmit-node16.yaml"
echo "exporting presubmit unit build for node18 unit tests"
gcloud beta builds triggers export "unit-presubmit-node18" --destination "ci/export/unit-presubmit-node18.yaml"
done
10 changes: 1 addition & 9 deletions ci/import_triggers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,4 @@ for NODE_VERSION in ${NODE_VERSIONS[@]}; do
gcloud beta builds triggers import --source "ci/export/samples-nightly-node${NODE_VERSION}.yaml"
echo "importing presubmit build for node${NODE_VERSION} with credentials"
gcloud beta builds triggers import --source "ci/export/samples-presubmit-node${NODE_VERSION}-with-credentials.yaml"
done

# Since we don't want to run nightly, and continuous for node 16 and node 18, adding these outside of the loop
echo "importing presubmit unit build for node12 unit tests"
gcloud beta builds triggers import --source "ci/export/unit-presubmit-node12.yaml"
echo "importing presubmit unit build for node16 unit tests"
gcloud beta builds triggers import --source "ci/export/unit-presubmit-node16.yaml"
echo "importing presubmit unit build for node18 unit tests"
gcloud beta builds triggers import --source "ci/export/unit-presubmit-node18.yaml"
done
6 changes: 4 additions & 2 deletions ci/run_conditional_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ for subdir in ${subdirs[@]}; do
if [[ "${changed}" -eq 0 ]]; then
echo "no change detected in ${d}, skipping"
else
if [[ "${TEST_TYPE}" == "system" ]]; then
if [[ "${TEST_TYPE}" == "system" ]] || [[ "${TEST_TYPE}" == "lint" ]] || [[ "${TEST_TYPE}" == "units" ]]; then
echo "change detected in ${d} for system test"
should_test=true
elif [[ "${tests_with_credentials[*]}" =~ "${d}" ]] && [[ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]]; then
Expand All @@ -97,7 +97,7 @@ for subdir in ${subdirs[@]}; do
fi
else
# If GIT_DIFF_ARG is empty, run all the tests.
if [[ "${TEST_TYPE}" == "system" ]]; then
if [[ "${TEST_TYPE}" == "system" ]] || [[ "${TEST_TYPE}" == "lint" ]] || [[ "${TEST_TYPE}" == "units" ]]; then
echo "run system test for ${d}"
should_test=true
elif [[ "${tests_with_credentials[*]}" =~ "${d}" ]] && [[ -n "${GOOGLE_APPLICATION_CREDENTIALS}" ]]; then
Expand All @@ -118,6 +118,8 @@ for subdir in ${subdirs[@]}; do
set -e
if [ ${ret} -ne 0 ]; then
RETVAL=${ret}
# Since there are so many APIs, we should exit early if there's an error
break
fi
popd
fi
Expand Down
15 changes: 8 additions & 7 deletions ci/run_single_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,37 @@ if [ ${BUILD_TYPE} != "presubmit" ]; then
fi

# Install dependencies
if [[ "${tests_without_node12[*]}" =~ "${PROJECT}" ]] && [[ ${NODE_VERSION} == "12.22.12" ]]; then
if [[ "${tests_without_node12[*]}" =~ "${PROJECT}" ]] && [[ ${NODE_VERSION} == "12.22.12" ]] && [[ ${TEST_TYPE} != "lint" ]]; then
echo "not running tests for Node 12"
elif [[ ${NODE_VERSION} == "12.22.12" ]]; then
echo "npm install --unsafe-perm --ignore-scripts --engine-strict --only=prod; npm install --unsafe-perm"
npm install --unsafe-perm --ignore-scripts --engine-strict --only=prod; npm install --unsafe-perm
else
echo "npm install --ignore-scripts --engine-strict --omit=dev; npm install"
npm install --ignore-scripts --engine-strict --omit=dev; npm install
echo "pnpm install --ignore-scripts --engine-strict --prod; pnpm install"
pnpm install --ignore-scripts --engine-strict --prod; pnpm install
fi

retval=0

set +e
case ${TEST_TYPE} in
lint)
npm run lint
pnpm prelint
pnpm lint
retval=$?
;;
samples)
npm run samples-test
pnpm samples-test
retval=$?
;;
system)
npm run system-test
pnpm system-test
retval=$?
;;
units)
# Skipping Node 12 tests for projects outside of gapic autogenerated libraries that don't need to run on Node 12
if ! [[ "${tests_without_node12[*]}" =~ "${PROJECT}" ]] || [[ ${NODE_VERSION} != "12.22.12" ]]; then
npm test
pnpm test
retval=$?
fi
;;
Expand Down
2 changes: 1 addition & 1 deletion containers/node-bootstrap-container/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"homepage": "https://github.com/googleapis/google-cloud-node#readme",
"dependencies": {
"@octokit/rest": "^19.0.0"
"@octokit/rest": "19.0.0"
},
"devDependencies": {
"mocha": "^9.0.0",
Expand Down
28 changes: 28 additions & 0 deletions make-change-to-package.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const fs = require('fs');
const path = require('path');
const cp = require('child_process');
const dirsToSkip = ['gapic-node-templating', 'typeless-sample-bot'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what purpose does this script serve?

Copy link
Contributor Author

@sofisl sofisl May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will delete it! Shouldn't be in here. I'll wait once this is approved to delete it so tests won't rerun.


async function main() {
const dirs = fs.readdirSync(path.join(__dirname, 'packages'));
for (const dir of dirs) {
if (!dirsToSkip.includes(dir)) {
let rewrite = false;
let packageJson = JSON.parse(fs.readFileSync(path.join('packages', dir, 'package.json'), 'utf-8'));
if (packageJson.scripts.hasOwnProperty("samples-test")) {
packageJson.scripts["samples-test"] = "cd samples/ && npm link ../ && npm i && npm test"
rewrite = true;
}
if (packageJson.scripts.hasOwnProperty("system-test")) {
packageJson.scripts["system-test"] = "c8 mocha build/system-test"
rewrite = true;
}
if (rewrite) {
fs.writeFileSync(path.join('packages', dir, 'package.json'), JSON.stringify(packageJson, null, 2));
}
}

}
}

main();
3 changes: 1 addition & 2 deletions packages/gapic-node-templating/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"author": "Google LLC",
"license": "Apache-2.0",
"devDependencies": {
"@octokit/rest": "^19.0.0",
"@types/js-yaml": "^4.0.5",
"@types/mocha": "^9.1.1",
"@types/node": "^18.0.0",
Expand All @@ -40,7 +39,7 @@
},
"dependencies": {
"@google-cloud/storage": "^6.1.0",
"@octokit/rest": "^19.0.0",
"@octokit/rest": "19.0.0",
"js-yaml": "^4.1.0",
"nunjucks": "^3.2.3",
"yargs": "^17.5.1"
Expand Down
13 changes: 7 additions & 6 deletions packages/google-analytics-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@
],
"scripts": {
"clean": "gts clean",
"compile": "tsc -p . && cp -r protos build/ && minifyProtoJson",
"compile": "tsc -p . && cp -r protos build/",
"compile-protos": "compileProtos src",
"docs": "jsdoc -c .jsdoc.js",
"predocs-test": "npm run docs",
"docs-test": "linkinator docs",
"fix": "gts fix",
"lint": "gts check",
"prelint": "cd samples; npm link ../; npm i",
"prepare": "npm run compile-protos && npm run compile",
"samples-test": "npm run compile && cd samples/ && npm link ../ && npm i && npm test",
"system-test": "npm run compile && c8 mocha build/system-test",
"prelint": "cd samples; npm link ../; npm i",
"postpack": "minifyProtoJson",
"samples-test": "cd samples/ && npm link ../ && npm i && npm test",
"system-test": "c8 mocha build/system-test",
"test": "c8 mocha build/test"
},
"dependencies": {
Expand All @@ -58,6 +59,7 @@
"jsdoc-fresh": "^2.0.0",
"jsdoc-region-tag": "^2.0.0",
"linkinator": "^4.0.0",
"long": "^5.2.3",
"mocha": "^9.2.2",
"null-loader": "^4.0.0",
"pack-n-play": "^1.0.0-2",
Expand All @@ -69,5 +71,4 @@
"node": ">=12.0.0"
},
"homepage": "https://github.com/googleapis/google-cloud-node/tree/main/packages/google-analytics-admin"
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// 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.
Expand Down Expand Up @@ -29,6 +30,6 @@ const cwd = path.join(__dirname, '..');
describe('Quickstart', async () => {
it('should run quickstart', async () => {
const output = execSync('node quickstart.js', {cwd});
assert(output != null);
assert(output !== null);
});
});
Loading