Skip to content

Commit 2fcb326

Browse files
fix: postman by force using compiled js instead of tsx (#786)
* fix: test different branch * fix: clean cache * fix: add debug logging * fix: add debug logging * fix: add debug logging * fix: add debug logging * fix: force compiled js instead of relying on tsx * fix: remove ref * fix: tests --------- Co-authored-by: svcAPLBot <[email protected]>
1 parent 41f8382 commit 2fcb326

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

.github/workflows/postman.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ jobs:
5555
nvm use
5656
node -v
5757
npm install
58-
npm run server > $GITHUB_WORKSPACE/core.log 2>&1 &
58+
npm run compile
59+
NODE_PATH="/usr/local/lib/node_modules" npm run server > $GITHUB_WORKSPACE/core.log 2>&1 &
5960
- name: Start api
6061
run: |
6162
npm install

src/otomi-stack.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { CoreV1Api, User as k8sUser, KubeConfig, V1ObjectReference } from '@kube
22
import Debug from 'debug'
33

44
import { getRegions, ObjectStorageKeyRegions } from '@linode/api-v4'
5-
import { existsSync, pathExists, rmSync, unlink } from 'fs-extra'
5+
import { existsSync, rmSync } from 'fs'
6+
import { pathExists, unlink } from 'fs-extra'
67
import { readdir, readFile, writeFile } from 'fs/promises'
78
import { generate as generatePassword } from 'generate-password'
89
import { cloneDeep, filter, isEmpty, map, mapValues, merge, omit, pick, set, unset } from 'lodash'

src/utils/workloadUtils.test.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// workloadUtils.test.ts
22
import axios from 'axios'
3+
import * as fs from 'fs'
34
import * as fsExtra from 'fs-extra'
45
import * as fsPromises from 'fs/promises'
56
import path from 'path'
@@ -24,13 +25,15 @@ jest.mock('fs/promises', () => ({
2425
writeFile: jest.fn(),
2526
readdir: jest.fn(),
2627
}))
27-
jest.mock('fs-extra', () => ({
28-
readFile: jest.fn(),
28+
jest.mock('fs', () => ({
2929
existsSync: jest.fn(),
3030
mkdirSync: jest.fn(),
3131
renameSync: jest.fn(),
3232
rmSync: jest.fn(),
3333
}))
34+
jest.mock('fs-extra', () => ({
35+
readFile: jest.fn(),
36+
}))
3437
jest.mock('simple-git', () => ({
3538
__esModule: true,
3639
default: jest.fn(() => ({
@@ -354,7 +357,7 @@ describe('sparseCloneChart', () => {
354357
// Set up environment variables for tests
355358
process.env = { ...originalEnv, GIT_USER: 'git-user', GIT_PASSWORD: 'git-password' }
356359
// Mock necessary function responses
357-
;(fsExtra.existsSync as jest.Mock).mockReturnValue(false)
360+
;(fs.existsSync as jest.Mock).mockReturnValue(false)
358361
})
359362

360363
afterEach(() => {
@@ -390,16 +393,16 @@ describe('sparseCloneChart', () => {
390393
)
391394

392395
expect(result).toBe(true)
393-
expect(fsExtra.mkdirSync).toHaveBeenCalledWith(localHelmChartsDir, { recursive: true })
394-
expect(fsExtra.mkdirSync).toHaveBeenCalledWith(`${localHelmChartsDir}-newChart`, { recursive: true })
396+
expect(fs.mkdirSync).toHaveBeenCalledWith(localHelmChartsDir, { recursive: true })
397+
expect(fs.mkdirSync).toHaveBeenCalledWith(`${localHelmChartsDir}-newChart`, { recursive: true })
395398
expect(mockGit.clone).toHaveBeenCalledTimes(2) // Once for catalog repo, once for chart repo
396399
expect(mockGit.listRemote).toHaveBeenCalled()
397400
expect(mockGit.raw).toHaveBeenCalledWith(['sparse-checkout', 'init', '--cone'])
398401
expect(mockGit.raw).toHaveBeenCalledWith(['sparse-checkout', 'set', 'main/bitnami/cassandra/'])
399402
expect(mockGit.checkout).toHaveBeenCalled()
400-
expect(fsExtra.renameSync).toHaveBeenCalled()
401-
expect(fsExtra.rmSync).toHaveBeenCalledWith(`${localHelmChartsDir}-newChart`, { recursive: true, force: true })
402-
expect(fsExtra.rmSync).toHaveBeenCalledWith(`${localHelmChartsDir}/${chartTargetDirName}/.git`, {
403+
expect(fs.renameSync).toHaveBeenCalled()
404+
expect(fs.rmSync).toHaveBeenCalledWith(`${localHelmChartsDir}-newChart`, { recursive: true, force: true })
405+
expect(fs.rmSync).toHaveBeenCalledWith(`${localHelmChartsDir}/${chartTargetDirName}/.git`, {
403406
recursive: true,
404407
force: true,
405408
})
@@ -491,7 +494,7 @@ describe('sparseCloneChart', () => {
491494
listRemote: jest.fn().mockResolvedValue(''),
492495
}
493496
;(simpleGit as jest.Mock).mockReturnValue(mockGit)
494-
;(fsExtra.existsSync as jest.Mock).mockReturnValueOnce(false)
497+
;(fs.existsSync as jest.Mock).mockReturnValueOnce(false)
495498

496499
await sparseCloneChart(
497500
gitRepositoryUrl,
@@ -504,7 +507,7 @@ describe('sparseCloneChart', () => {
504507
allowTeams,
505508
)
506509

507-
expect(fsExtra.mkdirSync).toHaveBeenCalledWith(localHelmChartsDir, { recursive: true })
510+
expect(fs.mkdirSync).toHaveBeenCalledWith(localHelmChartsDir, { recursive: true })
508511
})
509512

510513
test('returns false if git provider detection fails', async () => {
@@ -535,7 +538,7 @@ describe('fetchWorkloadCatalog', () => {
535538
beforeEach(() => {
536539
jest.clearAllMocks()
537540
process.env = { ...originalEnv, GIT_USER: 'git-user', GIT_PASSWORD: 'git-password' }
538-
;(fsExtra.existsSync as jest.Mock).mockReturnValue(false)
541+
;(fs.existsSync as jest.Mock).mockReturnValue(false)
539542

540543
// Mock directory structure
541544
const files = ['.git', 'chart1', 'chart2', 'README.md', 'rbac.yaml']
@@ -597,7 +600,7 @@ describe('fetchWorkloadCatalog', () => {
597600

598601
const result = await fetchWorkloadCatalog(url, helmChartsDir, 'admin')
599602

600-
expect(fsExtra.mkdirSync).toHaveBeenCalledWith(helmChartsDir, { recursive: true })
603+
expect(fs.mkdirSync).toHaveBeenCalledWith(helmChartsDir, { recursive: true })
601604
expect(mockGit.clone).toHaveBeenCalledWith(
602605
'https://git-user:[email protected]/otomi/charts.git',
603606
helmChartsDir,
@@ -780,7 +783,7 @@ describe('chartRepo', () => {
780783
expect(mockGit.raw).toHaveBeenCalledWith(['sparse-checkout', 'init', '--cone'])
781784
expect(mockGit.raw).toHaveBeenCalledWith(['sparse-checkout', 'set', 'charts/my-chart'])
782785
expect(mockGit.checkout).toHaveBeenCalledWith('main')
783-
expect(fsExtra.renameSync).toHaveBeenCalledWith(path.join(localPath, 'charts/my-chart'), finalDestinationPath)
786+
expect(fs.renameSync).toHaveBeenCalledWith(path.join(localPath, 'charts/my-chart'), finalDestinationPath)
784787
})
785788

786789
test('addConfig method sets git config', async () => {

src/utils/workloadUtils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import axios from 'axios'
22
import Debug from 'debug'
3-
import { existsSync, mkdirSync, readFile, renameSync, rmSync } from 'fs-extra'
3+
import { existsSync, mkdirSync, renameSync, rmSync } from 'fs'
4+
import { readFile } from 'fs-extra'
45
import { readdir, writeFile } from 'fs/promises'
56
import path from 'path'
67
import simpleGit, { SimpleGit } from 'simple-git'

0 commit comments

Comments
 (0)