Skip to content

Commit 9606499

Browse files
Merge pull request #241 from Sebastian-Webster/240-remove-binarydirectorypath-internal-variable
Remove binaryDirectoryPath internal variable
2 parents 61af70d + cbbd750 commit 9606499

File tree

7 files changed

+40
-14
lines changed

7 files changed

+40
-14
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ jobs:
1313
steps:
1414
- name: Checkout
1515
uses: actions/checkout@v4
16+
1617
- name: Setup node 22.x
1718
uses: actions/setup-node@v4
1819
with:
1920
node-version: 22.x
21+
2022
- name: Install packages
2123
run: npm ci
24+
2225
- name: Build
2326
run: npx tsc
27+
2428
- name: Upload build to artifacts
2529
uses: actions/upload-artifact@v4
2630
with:

.github/workflows/ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,18 @@ jobs:
2323
run: npm ci
2424

2525
- name: Run tests
26-
run: npm run test
26+
run: npm run test
27+
28+
- name: Move MySQLMSN directory for GitHub Actions upload
29+
if: ${{ failure() }}
30+
env:
31+
MOVE_MYSQLMSN_TO: /tmp/mysqlmsn
32+
run: npx ts-node tests/ci/DirMoveGitHubActions.ts
33+
34+
- name: Upload mysqlmsn directory (Not Windows)
35+
if: ${{ failure() }}
36+
uses: actions/[email protected]
37+
with:
38+
name: ci-mysqlmsn-dir
39+
path: /tmp/mysqlmsn
40+
compression-level: 0

.github/workflows/os-compatibility.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ jobs:
3333
- name: Run tests
3434
env:
3535
VERSION_REQUIREMENT: ${{ matrix.version-requirement }}
36-
MOVE_MYSQLMSN_TO: ${{ runner.os == 'Windows' && 'C:\\Users\\RUNNER~1\\mysqlmsn' || '/tmp/mysqlmsn' }}
3736
run: npm run os-compat:ci
3837

38+
- name: Move MySQLMSN directory for GitHub Actions upload
39+
if: ${{ failure() }}
40+
env:
41+
MOVE_MYSQLMSN_TO: ${{ runner.os == 'Windows' && 'C:\\Users\\RUNNER~1\\mysqlmsn' || '/tmp/mysqlmsn' }}
42+
run: npx ts-node tests/ci/DirMoveGitHubActions.ts
43+
3944
- name: Upload mysqlmsn directory (Windows)
4045
if: ${{ failure() && runner.os == 'Windows' }}
4146
uses: actions/[email protected]

src/constants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ export const LOG_LEVELS = {
3131

3232
const internalOptions = {
3333
deleteDBAfterStopped: 'true',
34-
//mysqlmsn = MySQL Memory Server Node.js
35-
binaryDirectoryPath: `${tmpdir()}/mysqlmsn/binaries`,
3634
cli: 'false'
3735
}
3836

src/libraries/Downloader.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { randomUUID } from 'crypto';
88
import { execFile } from 'child_process';
99
import { BinaryInfo, InternalServerOptions } from '../../types';
1010
import { lockFile, waitForLock } from './FileLock';
11-
import { getInternalEnvVariable, MySQLCDNArchivesBaseURL, MySQLCDNDownloadsBaseURL } from '../constants';
11+
import { MySQLCDNArchivesBaseURL, MySQLCDNDownloadsBaseURL } from '../constants';
12+
import os from 'os';
1213

1314
function handleTarExtraction(filepath: string, extractedPath: string): Promise<void> {
1415
return new Promise((resolve, reject) => {
@@ -243,7 +244,7 @@ function extractBinary(url: string, archiveLocation: string, extractedLocation:
243244
export function downloadBinary(binaryInfo: BinaryInfo, options: InternalServerOptions, logger: Logger): Promise<string> {
244245
return new Promise(async (resolve, reject) => {
245246
const {url, version} = binaryInfo;
246-
const dirpath = getInternalEnvVariable('binaryDirectoryPath')
247+
const dirpath = `${os.tmpdir()}/mysqlmsn/binaries`
247248
logger.log('Binary path:', dirpath)
248249
await fsPromises.mkdir(dirpath, {recursive: true})
249250

tests/ci/DirMoveGitHubActions.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import os from 'os';
2+
import fs from 'fs';
3+
import fsPromises from 'fs/promises'
4+
5+
const originalPath = `${os.tmpdir()}/mysqlmsn`
6+
if (process.env.MOVE_MYSQLMSN_TO && fs.existsSync(originalPath) && originalPath !== process.env.MOVE_MYSQLMSN_TO) {
7+
console.log('Moving MySQLMSN directory to other path for GitHub Actions upload')
8+
await fsPromises.cp(originalPath, process.env.MOVE_MYSQLMSN_TO, {recursive: true, force: true, filter: source => !source.includes('.sock')})
9+
await fsPromises.rm(originalPath, {force: true, recursive: true, maxRetries: 50, retryDelay: 100})
10+
} else {
11+
console.log('Skipping MySQLMSN directory move as conditions are not met.')
12+
}

tests/versions.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,4 @@ for (const version of DOWNLOADABLE_MYSQL_VERSIONS.filter(v => satisfies(v, versi
6262
//binary, we need this test here just in case all the MySQL binaries are skipped
6363
test('dummy test', () => {
6464
expect(1 + 1).toBe(2)
65-
})
66-
67-
afterAll(async () => {
68-
const originalPath = `${os.tmpdir()}/mysqlmsn`
69-
if (process.env.MOVE_MYSQLMSN_TO && fs.existsSync(originalPath) && originalPath !== process.env.MOVE_MYSQLMSN_TO) {
70-
await fsPromises.cp(originalPath, process.env.MOVE_MYSQLMSN_TO, {recursive: true, force: true, filter: source => !source.includes('.sock')})
71-
await fsPromises.rm(originalPath, {force: true, recursive: true, maxRetries: 50, retryDelay: 100})
72-
}
7365
})

0 commit comments

Comments
 (0)