Skip to content

Commit

Permalink
feat: separate test and build steps
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Feb 8, 2024
1 parent 806d6e3 commit 3024a60
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ GH_TOKEN=ghtoken GH_USER=username NPM_TOKEN=npmtoken npx zx-bulk-release [opts]
| `--include-private` | Include `private` packages | `false` |
| `--concurrency` | `build/publish` threads limit | `os.cpus.length` |
| `--no-build` | Skip `buildCmd` invoke | |
| `--no-test` | Disable `testCmd` run | |
| `--no-npm-fetch` | Disable npm artifacts fetching | |
| `--only-workspace-deps` | Recognize only `workspace:` deps as graph edges | |
| `--dry-run` / `--no-publish` | Disable any publish logic | |
Expand Down
2 changes: 1 addition & 1 deletion src/main/js/processor/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {log} from '../log.js'
import {$} from 'zx-extra'

export const exec = async (pkg, name) => {
const cmd = tpl(pkg.config[name], {...pkg, ...pkg.context})
const cmd = tpl(pkg.context.flags[name] ?? pkg.config[name], {...pkg, ...pkg.context})
const now = Date.now()

if (cmd) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/js/processor/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {analyze} from '../steps/analyze.js'
import {build} from '../steps/build.js'
import {publish} from '../steps/publish.js'
import {clean} from '../steps/clean.js'
import {test} from '../steps/test.js'

export const run = async ({cwd = process.cwd(), env, flags = {}} = {}) => within(async () => {
const {version: zbrVersion} = createRequire(import.meta.url)('../../../../package.json')
Expand Down Expand Up @@ -54,6 +55,10 @@ export const run = async ({cwd = process.cwd(), env, flags = {}} = {}) => within
report.setStatus('building', name)
await build(pkg, _exec)
}
if (flags.test !== false) {
report.setStatus('testing', name)
await test(pkg, _exec)
}
if (!flags.dryRun && flags.publish !== false) {
report.setStatus('publishing', name)
await publish(pkg, _exec)
Expand Down
2 changes: 1 addition & 1 deletion src/main/js/steps/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const build = memoizeBy(async (pkg, run = exec, flags = {}, self = build)

if (!pkg.fetched) {
await run(pkg, 'buildCmd')
await run(pkg, 'testCmd')
// await run(pkg, 'testCmd')
}

pkg.built = true
Expand Down
16 changes: 16 additions & 0 deletions src/main/js/steps/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {$, within} from 'zx-extra'
import {memoizeBy} from '../util.js'
import {exec} from '../processor/exec.js'
// import {traverseDeps} from "../processor/deps.js";

export const test = memoizeBy(async (pkg, run = exec, flags = {}, self = test) => within(async () => {
$.scope = pkg.name

// await traverseDeps({pkg, packages: pkg.context.packages, cb: async({pkg}) => self(pkg, run, flags, self)})

if (!pkg.fetched) {
await run(pkg, 'testCmd')
}

pkg.tested = true
}))

0 comments on commit 3024a60

Please sign in to comment.