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

ci(imagemagick): add test isolation for functions imagemagick #3987

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 0 additions & 2 deletions .github/config/nodejs-prod.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@
"eventarc/pubsub", // (untested) Environment Variable 'SERVICE_NAME' not found
"functions/billing", // Error: Request failed with status code 500
"functions/http/uploadFile", // npm error Missing script: "test"
"functions/imagemagick", // Error: A bucket name is needed to use Cloud Storage
"functions/ocr/app", // Error: Bucket not provided. Make sure you have a "bucket" property in your request
"functions/slack", // TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of type ... Received undefined
"functions/v2/imagemagick", // Error: A bucket name is needed to use Cloud Storage.
"healthcare/fhir", // Error: Cannot find module 'whatwg-url'
"iam/deny", // PERMISSION_DENIED: Permission iam.googleapis.com/denypolicies.create denied on resource cloudresourcemanager.googleapis.com/projects/long-door-651
"recaptcha_enterprise/snippets", // Cannot use import statement outside a module
Expand Down
6 changes: 6 additions & 0 deletions functions/imagemagick/ci-setup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"env": {
"FUNCTIONS_BUCKET": "nodejs-docs-samples-tests",
"BLURRED_BUCKET_NAME": "nodejs-docs-samples-tests-imagick"
}
}
9 changes: 7 additions & 2 deletions functions/imagemagick/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'use strict';

const assert = require('assert');
const {spawn} = require('child_process');
const {execSync, spawn} = require('child_process');
const {Storage} = require('@google-cloud/storage');
const sinon = require('sinon');
const {request} = require('gaxios');
Expand Down Expand Up @@ -47,13 +47,18 @@ async function startFF(port) {
let stderr = '';
ffProc.stdout.on('data', data => (stdout += data));
ffProc.stderr.on('data', data => (stderr += data));
ffProc.on('error', reject);
ffProc.on('error', c => (c === 0 ? resolve(stdout) : reject(stderr)));
ffProc.on('exit', c => (c === 0 ? resolve(stdout) : reject(stderr)));
});
await waitPort({host: 'localhost', port});
return {ffProc, ffProcHandler};
}

// ImageMagick is available by default in Cloud Run Functions environments
// https://cloud.google.com/functions/1stgendocs/tutorials/imagemagick-1st-gen.md#importing_dependencies
// Manually install it for testing only.
execSync('sudo apt-get install imagemagick -y');

describe('functions/imagemagick tests', () => {
before(async () => {
let exists;
Expand Down
6 changes: 6 additions & 0 deletions functions/v2/imagemagick/ci-setup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"env": {
"FUNCTIONS_BUCKET": "nodejs-docs-samples-tests",
"BLURRED_BUCKET_NAME": "nodejs-docs-samples-tests-imagick"
}
}
6 changes: 6 additions & 0 deletions functions/v2/imagemagick/test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
'use strict';

const assert = require('assert');
const {execSync} = require('child_process');
const {Storage} = require('@google-cloud/storage');
const sinon = require('sinon');
const supertest = require('supertest');
Expand All @@ -33,6 +34,11 @@ const testFiles = {

require('../index');

// ImageMagick is available by default in Cloud Run Functions environments
// https://cloud.google.com/functions/1stgendocs/tutorials/imagemagick-1st-gen.md#importing_dependencies
// Manually install it for testing only.
execSync('sudo apt-get install imagemagick -y');

describe('functions/imagemagick tests', () => {
before(async () => {
let exists;
Expand Down
Loading