diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 36e1a86..0076996 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0ec89b..cb78ed7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,4 +23,18 @@ jobs: run: npm ci - name: Run tests - run: npm run test \ No newline at end of file + 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 \ No newline at end of file diff --git a/.github/workflows/os-compatibility.yml b/.github/workflows/os-compatibility.yml index e5e3525..7dc1186 100644 --- a/.github/workflows/os-compatibility.yml +++ b/.github/workflows/os-compatibility.yml @@ -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 diff --git a/src/constants.ts b/src/constants.ts index ac54144..619a363 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -31,8 +31,6 @@ export const LOG_LEVELS = { const internalOptions = { deleteDBAfterStopped: 'true', - //mysqlmsn = MySQL Memory Server Node.js - binaryDirectoryPath: `${tmpdir()}/mysqlmsn/binaries`, cli: 'false' } diff --git a/src/libraries/Downloader.ts b/src/libraries/Downloader.ts index a5ccfa2..27b251a 100644 --- a/src/libraries/Downloader.ts +++ b/src/libraries/Downloader.ts @@ -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 { return new Promise((resolve, reject) => { @@ -243,7 +244,7 @@ function extractBinary(url: string, archiveLocation: string, extractedLocation: export function downloadBinary(binaryInfo: BinaryInfo, options: InternalServerOptions, logger: Logger): Promise { 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}) diff --git a/tests/ci/DirMoveGitHubActions.ts b/tests/ci/DirMoveGitHubActions.ts new file mode 100644 index 0000000..c2caa3c --- /dev/null +++ b/tests/ci/DirMoveGitHubActions.ts @@ -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.') +} \ No newline at end of file diff --git a/tests/versions.test.ts b/tests/versions.test.ts index c3f995d..e6ed27e 100644 --- a/tests/versions.test.ts +++ b/tests/versions.test.ts @@ -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}) - } }) \ No newline at end of file