Skip to content

Commit

Permalink
chore: remove build step from test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
msudgh committed Aug 10, 2024
1 parent 25ccaf3 commit 031aa30
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
with:
node-version: ${{ matrix.node_version }}
cache: 'pnpm'
- run: pnpm run build
- run: pnpm run test:coverage
- name: SonarCloud Scan
if: matrix.os == 'ubuntu-latest'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"postpack": "shx rm -f oclif.manifest.json",
"posttest": "pnpm run lint",
"prepack": "oclif manifest && pnpm run build:release && pnpm run test:unit",
"test:unit": "pnpm run build && CI=1 mocha",
"test:unit": "pnpm run build && mocha",
"test:coverage": "nyc npm run test:unit"
},
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions src/commands/config/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { expect } from 'chai'
import { existsSync } from 'fs'
import { destroyConfigMockFile, getTmpConfigFilePath, runCommand } from '../../utils/testing'

process.env.CI = 'true'

describe('Command: config init', () => {
beforeEach(async () => {
const tmpConfigFilePath = getTmpConfigFilePath()
Expand Down
25 changes: 21 additions & 4 deletions src/utils/testing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { exec, ExecException } from 'child_process'
import { rm } from 'fs/promises'
import { tmpdir } from 'os'
import { platform, tmpdir } from 'os'
import path from 'path'
import { OVM_CONFIG_FILENAME } from './constants'

Expand All @@ -13,8 +13,22 @@ export const runCommand = async (
command: string,
dev = false,
): Promise<CommandResult | (ExecException | null)> => {
const formattedCommand = `./bin/${dev ? 'dev' : 'run'}.js ${command}`
return new Promise((resolve, reject) => {
const detectedPlatform = platform()
const runnerExt = detectedPlatform === 'win32' ? 'cmd' : 'js'
const runnerType = dev ? 'dev' : 'run'
const runnerFilePath = `${runnerType}.${runnerExt}`
const formattedCommand =
detectedPlatform === 'win32'
? path.win32.normalize(
path.join(
__dirname,
'..',
'..',
`bin/${runnerFilePath} ${command}`,
),
)
: `./bin/${runnerFilePath} ${command}`
exec(formattedCommand, (error, stdout, stderr) => {
if (error) {
reject(error)
Expand All @@ -28,7 +42,10 @@ export const getTmpConfigFilePath = () => {
return path.join(tmpdir(), OVM_CONFIG_FILENAME)
}


export const destroyConfigMockFile = async (path: string) => {
await rm(path, { force: true })
if (platform() === 'win32') {
return await rm(path.normalize(path), { force: true })
}

return await rm(path, { force: true })
}

0 comments on commit 031aa30

Please sign in to comment.