Skip to content
Merged
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
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup node 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x

- name: Install packages
run: npm ci

- name: Build
run: npx tsc

- name: Upload build to artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,18 @@ jobs:
run: npm ci

- name: Run tests
run: npm run test
run: npm run test

- name: Move MySQLMSN directory for GitHub Actions upload
if: ${{ failure() }}
env:
MOVE_MYSQLMSN_TO: /tmp/mysqlmsn
run: npx ts-node tests/ci/DirMoveGitHubActions.ts

- name: Upload mysqlmsn directory (Not Windows)
if: ${{ failure() }}
uses: actions/upload-artifact@v4.3.5
with:
name: ci-mysqlmsn-dir
path: /tmp/mysqlmsn
compression-level: 0
7 changes: 6 additions & 1 deletion .github/workflows/os-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ jobs:
- name: Run tests
env:
VERSION_REQUIREMENT: ${{ matrix.version-requirement }}
MOVE_MYSQLMSN_TO: ${{ runner.os == 'Windows' && 'C:\\Users\\RUNNER~1\\mysqlmsn' || '/tmp/mysqlmsn' }}
run: npm run os-compat:ci

- name: Move MySQLMSN directory for GitHub Actions upload
if: ${{ failure() }}
env:
MOVE_MYSQLMSN_TO: ${{ runner.os == 'Windows' && 'C:\\Users\\RUNNER~1\\mysqlmsn' || '/tmp/mysqlmsn' }}
run: npx ts-node tests/ci/DirMoveGitHubActions.ts

- name: Upload mysqlmsn directory (Windows)
if: ${{ failure() && runner.os == 'Windows' }}
uses: actions/upload-artifact@v4.3.5
Expand Down
2 changes: 0 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ export const LOG_LEVELS = {

const internalOptions = {
deleteDBAfterStopped: 'true',
//mysqlmsn = MySQL Memory Server Node.js
binaryDirectoryPath: `${tmpdir()}/mysqlmsn/binaries`,
cli: 'false'
}

Expand Down
5 changes: 3 additions & 2 deletions src/libraries/Downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { randomUUID } from 'crypto';
import { execFile } from 'child_process';
import { BinaryInfo, InternalServerOptions } from '../../types';
import { lockFile, waitForLock } from './FileLock';
import { getInternalEnvVariable, MySQLCDNArchivesBaseURL, MySQLCDNDownloadsBaseURL } from '../constants';
import { MySQLCDNArchivesBaseURL, MySQLCDNDownloadsBaseURL } from '../constants';
import os from 'os';

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

Expand Down
12 changes: 12 additions & 0 deletions tests/ci/DirMoveGitHubActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os from 'os';
import fs from 'fs';
import fsPromises from 'fs/promises'

const originalPath = `${os.tmpdir()}/mysqlmsn`
if (process.env.MOVE_MYSQLMSN_TO && fs.existsSync(originalPath) && originalPath !== process.env.MOVE_MYSQLMSN_TO) {
console.log('Moving MySQLMSN directory to other path for GitHub Actions upload')
await fsPromises.cp(originalPath, process.env.MOVE_MYSQLMSN_TO, {recursive: true, force: true, filter: source => !source.includes('.sock')})
await fsPromises.rm(originalPath, {force: true, recursive: true, maxRetries: 50, retryDelay: 100})
} else {
console.log('Skipping MySQLMSN directory move as conditions are not met.')
}
8 changes: 0 additions & 8 deletions tests/versions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,4 @@ for (const version of DOWNLOADABLE_MYSQL_VERSIONS.filter(v => satisfies(v, versi
//binary, we need this test here just in case all the MySQL binaries are skipped
test('dummy test', () => {
expect(1 + 1).toBe(2)
})

afterAll(async () => {
const originalPath = `${os.tmpdir()}/mysqlmsn`
if (process.env.MOVE_MYSQLMSN_TO && fs.existsSync(originalPath) && originalPath !== process.env.MOVE_MYSQLMSN_TO) {
await fsPromises.cp(originalPath, process.env.MOVE_MYSQLMSN_TO, {recursive: true, force: true, filter: source => !source.includes('.sock')})
await fsPromises.rm(originalPath, {force: true, recursive: true, maxRetries: 50, retryDelay: 100})
}
})