Skip to content

Commit 90312ac

Browse files
authored
ci(metadata, analytics): migrate to new CI (GoogleCloudPlatform#4004)
* ci(metadata/flexible): migrate to new CI * migrate esmodule * add other appengine migration * module * move working tests to dev
1 parent 9a866b8 commit 90312ac

File tree

8 files changed

+42
-14
lines changed

8 files changed

+42
-14
lines changed

.github/config/nodejs-dev.jsonc

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
"appengine/hello-world/flexible_nodejs16_and_earlier",
8686
"appengine/hello-world/standard",
8787
"appengine/memcached",
88+
"appengine/analytics",
89+
"appengine/metadata/flexible",
8890
"appengine/metadata/flexible_nodejs16_and_earlier",
8991
"appengine/metadata/standard",
9092
"appengine/pubsub",

.github/config/nodejs-prod.jsonc

-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@
7676

7777
// TODO: fix these
7878
"ai-platform/snippets", // PERMISSION_DENIED: Permission denied: Consumer 'projects/undefined' has been suspended.
79-
"appengine/analytics", // [ERR_REQUIRE_ESM]: require() of ES Module
80-
"appengine/metadata/flexible", // [ERR_REQUIRE_ESM]: require() of ES Module
8179
"automl", // (untested) FAILED_PRECONDITION: Google Cloud AutoML Natural Language was retired on March 15, 2024. Please migrate to Vertex AI instead
8280
"cloud-sql/mysql/mysql", // (untested) Error: expected 200 "OK", got 500 "Internal Server Error"
8381
"cloud-sql/mysql/mysql2", // (untested) Error: Cannot find module './connect-connector-with-iam-authn.js'

appengine/analytics/app.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
'use strict';
1616

1717
// [START gae_flex_analytics_track_event]
18-
const express = require('express');
19-
const fetch = require('node-fetch');
18+
import express from 'express';
19+
import fetch from 'node-fetch';
2020

2121
const app = express();
2222
app.enable('trust proxy');
@@ -77,4 +77,4 @@ app.listen(PORT, () => {
7777

7878
// [END gae_flex_analytics_track_event]
7979

80-
module.exports = app;
80+
export default app;

appengine/analytics/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"type": "git",
1010
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
1111
},
12+
"type": "module",
1213
"engines": {
1314
"node": "20.x"
1415
},

appengine/analytics/test/app.test.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
const supertest = require('supertest');
2-
const path = require('path');
3-
const app = require(path.join(__dirname, '../', 'app.js'));
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import supertest from 'supertest';
16+
import app from '../app.js';
417

518
describe('gae_flex_analytics_track_event', () => {
619
it('should be listening', async () => {

appengine/metadata/flexible/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"type": "git",
1010
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
1111
},
12+
"type": "module",
1213
"engines": {
1314
"node": ">= 18.x.x"
1415
},

appengine/metadata/flexible/server.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
'use strict';
1616

1717
// [START gae_flex_metadata]
18-
const express = require('express');
19-
const fetch = require('node-fetch');
18+
import express from 'express';
19+
import fetch from 'node-fetch';
2020

2121
const app = express();
2222
app.enable('trust proxy');
@@ -58,4 +58,4 @@ app.listen(PORT, () => {
5858
console.log('Press Ctrl+C to quit.');
5959
});
6060
// [END gae_flex_metadata]
61-
module.exports = app;
61+
export default app;

appengine/metadata/flexible/test/server.test.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
const path = require('path');
2-
const app = require(path.join(__dirname, '../', 'server.js'));
3-
const supertest = require('supertest');
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import supertest from 'supertest';
16+
import app from '../server.js';
417

518
describe('gae_flex_metadata', () => {
619
it('should be listening', async () => {

0 commit comments

Comments
 (0)