Skip to content

Commit 5600f9f

Browse files
authored
Merge pull request #811 from line/dev
release: 6.2441.69
2 parents 6eb6631 + 3768377 commit 5600f9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4684
-2529
lines changed
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Integration Tests
2+
3+
on:
4+
pull_request:
5+
branches: [dev, main]
6+
7+
jobs:
8+
integration-test:
9+
runs-on: ubuntu-latest
10+
11+
services:
12+
mysql:
13+
image: mysql:8.0.39
14+
env:
15+
MYSQL_ROOT_PASSWORD: userfeedback
16+
MYSQL_DATABASE: e2e
17+
MYSQL_USER: userfeedback
18+
MYSQL_PASSWORD: userfeedback
19+
TZ: UTC
20+
ports:
21+
- 13307:3306
22+
options: >-
23+
--health-cmd="mysqladmin ping"
24+
--health-interval=10s
25+
--health-timeout=5s
26+
--health-retries=3
27+
28+
smtp:
29+
image: rnwood/smtp4dev:v3
30+
ports:
31+
- 5080:80
32+
- 25:25
33+
- 143:143
34+
35+
opensearch:
36+
image: opensearchproject/opensearch:2.17.1
37+
env:
38+
discovery.type: single-node
39+
bootstrap.memory_lock: "true"
40+
plugins.security.disabled: "true"
41+
OPENSEARCH_INITIAL_ADMIN_PASSWORD: "UserFeedback123!@#"
42+
options: >-
43+
--health-cmd="curl -s http://localhost:9200/_cluster/health | grep -q '\"status\":\"green\"'"
44+
--health-interval=10s
45+
--health-timeout=5s
46+
--health-retries=3
47+
ports:
48+
- 9200:9200
49+
50+
steps:
51+
- name: Check out repository code
52+
uses: actions/checkout@v4
53+
54+
- name: Setup integration test (with opensearch)
55+
run: |
56+
npx corepack enable
57+
pnpm install --frozen-lockfile
58+
pnpm build
59+
echo "BASE_URL=http://localhost:3000" >> ./apps/api/.env
60+
echo "JWT_SECRET=DEV" >> ./apps/api/.env
61+
echo "OPENSEARCH_USE=true" >> ./apps/api/.env
62+
echo "OPENSEARCH_NODE=http://localhost:9200" >> ./apps/api/.env
63+
echo "OPENSEARCH_USERNAME=''" >> ./apps/api/.env
64+
echo "OPENSEARCH_PASSWORD=''" >> ./apps/api/.env
65+
66+
- name: Run integration tests (with opensearch)
67+
run: |
68+
npm run test:integration
69+
70+
- name: Setup integration test (without opensearch)
71+
run: |
72+
echo "OPENSEARCH_USE=false" >> ./apps/api/.env
73+
74+
- name: Run integration tests (without opensearch)
75+
run: |
76+
npm run test:integration

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.17.0
1+
20.18.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright 2023 LINE Corporation
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
import mysql from 'mysql2/promise';
17+
18+
export async function createConnection() {
19+
return await mysql.createConnection({
20+
host: '127.0.0.1',
21+
port: 13307,
22+
user: 'root',
23+
password: 'userfeedback',
24+
});
25+
}
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* Copyright 2023 LINE Corporation
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
import { join } from 'path';
17+
import { createConnection } from 'typeorm';
18+
import { SnakeNamingStrategy } from 'typeorm-naming-strategies';
19+
20+
import { createConnection as connect } from './database-utils';
21+
22+
process.env.NODE_ENV = 'test';
23+
process.env.MYSQL_PRIMARY_URL =
24+
'mysql://root:userfeedback@localhost:13307/integration';
25+
process.env.MASTER_API_KEY = 'master-api-key';
26+
27+
async function createTestDatabase() {
28+
const connection = await connect();
29+
30+
await connection.query(`DROP DATABASE IF EXISTS integration;`);
31+
await connection.query(`CREATE DATABASE IF NOT EXISTS integration;`);
32+
await connection.end();
33+
}
34+
35+
async function runMigrations() {
36+
const connection = await createConnection({
37+
type: 'mysql',
38+
host: '127.0.0.1',
39+
port: 13307,
40+
username: 'root',
41+
password: 'userfeedback',
42+
database: 'integration',
43+
migrations: [
44+
join(
45+
__dirname,
46+
'../src/configs/modules/typeorm-config/migrations/*.{ts,js}',
47+
),
48+
],
49+
migrationsTableName: 'migrations',
50+
namingStrategy: new SnakeNamingStrategy(),
51+
timezone: '+00:00',
52+
});
53+
54+
await connection.runMigrations();
55+
await connection.close();
56+
}
57+
58+
module.exports = async () => {
59+
await createTestDatabase();
60+
await runMigrations();
61+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright 2023 LINE Corporation
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
import { createConnection as connect } from './database-utils';
17+
18+
async function dropTestDatabase() {
19+
const connection = await connect();
20+
21+
await connection.query(`DROP DATABASE IF EXISTS integration;`);
22+
await connection.end();
23+
}
24+
25+
module.exports = async () => {
26+
await dropTestDatabase();
27+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"displayName": "api-integration",
3+
"moduleFileExtensions": ["js", "json", "ts"],
4+
"rootDir": ".",
5+
"testEnvironment": "node",
6+
"moduleNameMapper": {
7+
"^@/(.*)$": ["<rootDir>/../src/$1"]
8+
},
9+
"testRegex": ".integration-spec.ts$",
10+
"transform": {
11+
"^.+\\.(t|j)s$": "ts-jest"
12+
},
13+
"setupFilesAfterEnv": [
14+
"<rootDir>/../integration-test/jest-integration.setup.ts"
15+
],
16+
"globalSetup": "<rootDir>/../integration-test/global.setup.ts",
17+
"globalTeardown": "<rootDir>/../integration-test/global.teardown.ts"
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright 2023 LINE Corporation
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
jest.mock('@nestjs-modules/mailer/dist/adapters/handlebars.adapter', () => {
17+
return {
18+
HandlebarsAdapter: jest.fn(),
19+
};
20+
});

0 commit comments

Comments
 (0)