or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

environment.mdexecution.mdextensions.mdgeneration.mdgraphs.mdindex.mdmaintenance.mdproject-task.mdquery.mdtoolchain.md

execution.mddocs/

0

# Task Execution

1

2

Commands for running builds, tests, and other tasks across projects in the moon workspace with smart caching and dependency resolution.

3

4

## Capabilities

5

6

### Check Projects

7

8

Run all build and test related tasks for projects to verify their health.

9

10

```bash { .api }

11

moon check [ids...] [--all] [--summary] [--update-cache]

12

```

13

14

**Arguments:**

15

- `ids` (optional) - List of project IDs to explicitly check

16

17

**Options:**

18

- `--all` - Run check for all projects in the workspace

19

- `--summary` - Include a summary of all actions processed in the pipeline

20

- `--update-cache` - Bypass cache and force update any existing items

21

22

**Usage Examples:**

23

24

```bash

25

# Check current project

26

moon check

27

28

# Check specific projects

29

moon check my-app shared-utils

30

31

# Check all projects in workspace

32

moon check --all

33

34

# Check with cache bypass

35

moon check --update-cache

36

37

# Check with execution summary

38

moon check --summary

39

```

40

41

### CI Execution

42

43

Run all affected projects and tasks in a CI environment with optimizations for continuous integration.

44

45

```bash { .api }

46

moon ci [targets...] [--base <REF>] [--head <REF>] [--job <INDEX>] [--job-total <TOTAL>] [--stdin]

47

```

48

49

**Arguments:**

50

- `targets` (optional) - List of specific targets to run

51

52

**Options:**

53

- `--base <REF>` - Base branch, commit, or revision to compare against (for affected detection)

54

- `--head <REF>` - Current branch, commit, or revision to compare with

55

- `--job <INDEX>` - Index of the current job in a distributed CI setup (0-based)

56

- `--job-total <TOTAL>` - Total number of jobs running in parallel

57

- `--stdin` - Accept list of touched files from stdin for affected checks

58

59

**Usage Examples:**

60

61

```bash

62

# Run CI for affected projects

63

moon ci

64

65

# Run CI comparing against main branch

66

moon ci --base main

67

68

# Run CI with specific targets

69

moon ci build test lint

70

71

# Distributed CI execution (job 1 of 4)

72

moon ci --job 0 --job-total 4

73

74

# Use stdin for touched files

75

git diff --name-only HEAD~1 | moon ci --stdin

76

```

77

78

### Run Tasks

79

80

Execute one or more project tasks along with their dependencies in the correct order.

81

82

```bash { .api }

83

moon run <targets...> [--dependents] [--force] [--interactive] [--query <QUERY>] [--summary]

84

```

85

86

**Arguments:**

87

- `targets` (required) - List of targets to run in the format `project:task` or `:task`

88

89

**Options:**

90

- `--dependents` - Also run dependents of the primary targets

91

- `--force` - Force run and ignore touched files and cache status

92

- `--interactive` - Run the target interactively (for tasks that require user input)

93

- `--query <QUERY>` - Focus targets based on the result of a project query

94

- `--summary` - Include a summary of all actions processed in the pipeline

95

96

**Usage Examples:**

97

98

```bash

99

# Run a single task

100

moon run my-app:build

101

102

# Run multiple tasks

103

moon run my-app:build my-app:test

104

105

# Run with dependents

106

moon run my-app:build --dependents

107

108

# Force run ignoring cache

109

moon run my-app:test --force

110

111

# Interactive task execution

112

moon run my-app:dev --interactive

113

114

# Run tasks matching a query

115

moon run build --query "language=typescript"

116

117

# Run with execution summary

118

moon run build test --summary

119

```

120

121

## Target Syntax

122

123

Moon uses a flexible target syntax for specifying tasks:

124

125

- `project:task` - Run a specific task in a project

126

- `:task` - Run a task in all projects (workspace task)

127

- `project:` - Run all tasks in a project

128

- `^:task` - Run a task only in dependencies

129

- `~:task` - Run a task in the current project

130

131

**Examples:**

132

```bash

133

# Specific task in specific project

134

moon run web-app:build

135

136

# Run build task in all projects

137

moon run :build

138

139

# Run all tasks in a project

140

moon run shared-utils:

141

142

# Run tests in dependencies only

143

moon run ^:test

144

145

# Run lint in current project context

146

moon run ~:lint

147

```

148

149

## Task Dependencies

150

151

Moon automatically resolves and executes task dependencies:

152

153

```yaml

154

# In project moon.yml

155

tasks:

156

build:

157

command: 'npm run build'

158

deps: ['~:type-check', 'shared-utils:build']

159

160

test:

161

command: 'npm test'

162

deps: ['~:build']

163

```

164

165

When running `moon run my-app:test`, moon will:

166

1. Run `my-app:type-check`

167

2. Run `shared-utils:build`

168

3. Run `my-app:build`

169

4. Run `my-app:test`

170

171

## Caching and Incremental Builds

172

173

Moon uses smart caching to avoid unnecessary work:

174

175

- **Input-based caching** - Tasks are cached based on input file hashes

176

- **Remote caching** - Share cache across team members and CI

177

- **Incremental builds** - Only rebuild what has changed

178

179

```bash

180

# Force bypass cache

181

moon run build --force

182

183

# Update cache entries

184

moon check --update-cache

185

```

186

187

## Parallel Execution

188

189

Moon executes tasks in parallel when possible:

190

191

- Tasks with no dependencies run immediately

192

- Independent tasks run simultaneously

193

- Dependency constraints are respected

194

- Thread pool limits can be configured

195

196

```bash

197

# Control concurrency

198

moon run build --concurrency 4

199

200

# Environment variable

201

MOON_CONCURRENCY=8 moon run test

202

```

203

204

## Task Output and Logging

205

206

Moon provides detailed execution information:

207

208

```bash

209

# Show execution summary

210

moon run build --summary

211

212

# Increase log verbosity

213

moon run test --log debug

214

215

# Quiet mode (errors only)

216

moon run build --quiet

217

```

218

219

## CI/CD Integration

220

221

Moon is optimized for CI/CD environments:

222

223

```bash

224

# Typical CI workflow

225

moon ci --base origin/main --summary

226

227

# Distributed CI across multiple jobs

228

moon ci --job $CI_JOB_INDEX --job-total $CI_JOB_TOTAL

229

230

# Cache sharing in CI

231

export MOON_CACHE=write

232

moon run build test

233

```