|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "39d4fdb7-8441-4060-8048-3fc389f37cbd", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "# **Efficent Workflows with Makim's Working Directory**" |
| 9 | + ] |
| 10 | + }, |
| 11 | + { |
| 12 | + "cell_type": "markdown", |
| 13 | + "id": "eca10ec0-50fe-4ef2-a80f-75ab15beb60c", |
| 14 | + "metadata": {}, |
| 15 | + "source": [ |
| 16 | + "Welcome to the world of [Makim](https://github.com/osl-incubator/makim), your go-to command-line companion for project automation. In our ongoing effort to enhance Makim's capabilities, we've introduced an exciting new feature—the Working Directory. This feature brings a new level of control and flexibility to your project workflows.\n", |
| 17 | + "\n", |
| 18 | + "In this blog post, we'll explore the Working Directory feature, understand its syntax, and witness its power in action through real-world examples. Whether you're a Makim veteran or a newcomer, this feature is designed to make your command-line experience more flexible and tailored to your project's needs. Let's dive into the details and unleash the potential of Makim's Working Directory feature!" |
| 19 | + ] |
| 20 | + }, |
| 21 | + { |
| 22 | + "cell_type": "markdown", |
| 23 | + "id": "a445f2d9-e743-4b24-9b47-2f00455898de", |
| 24 | + "metadata": {}, |
| 25 | + "source": [ |
| 26 | + "## Unveiling the Power of Working Directories" |
| 27 | + ] |
| 28 | + }, |
| 29 | + { |
| 30 | + "cell_type": "markdown", |
| 31 | + "id": "1f75b9ef-ce06-4003-ac8f-308b853a27f5", |
| 32 | + "metadata": {}, |
| 33 | + "source": [ |
| 34 | + "In the bustling realm of project management, one of the key challenges is orchestrating a seamless workflow while ensuring command executions are precisely where they need to be. This is where Makim's **Working Directory** steps into the spotlight, offering a robust solution for organizing, customizing, and optimizing your project commands." |
| 35 | + ] |
| 36 | + }, |
| 37 | + { |
| 38 | + "cell_type": "markdown", |
| 39 | + "id": "1a214ca5-810a-4ef9-84d6-93b3c37e1882", |
| 40 | + "metadata": {}, |
| 41 | + "source": [ |
| 42 | + "## Syntax and Scopes" |
| 43 | + ] |
| 44 | + }, |
| 45 | + { |
| 46 | + "cell_type": "markdown", |
| 47 | + "id": "56c3a561-48b0-4047-b155-db00bf11eb07", |
| 48 | + "metadata": {}, |
| 49 | + "source": [ |
| 50 | + "The Working Directory feature in Makim operates across three distinct scopes: Global, Group, and Target.\n", |
| 51 | + "1. **Global Scope**\n", |
| 52 | + " \n", |
| 53 | + " At the global scope, setting the working directory impacts all targets and groups within the Makim configuration. It provides a top-level directive to establish a standardized execution environment.\n", |
| 54 | + "```yaml\n", |
| 55 | + "version: 1.0\n", |
| 56 | + "working-directory: /path/to/global/directory\n", |
| 57 | + "\n", |
| 58 | + "# ... other configuration ...\n", |
| 59 | + "```\n", |
| 60 | + "\n", |
| 61 | + "2. **Group Scope**\n", |
| 62 | + " Moving a level deeper, the group scope allows you to tailor the working directory for all targets within a specific group.\n", |
| 63 | + "```yaml\n", |
| 64 | + "version: 1.0\n", |
| 65 | + "\n", |
| 66 | + "groups:\n", |
| 67 | + " my-group:\n", |
| 68 | + " working-directory: /path/to/group/directory\n", |
| 69 | + " targets:\n", |
| 70 | + " target-1:\n", |
| 71 | + " run: |\n", |
| 72 | + " # This target operates within the /path/to/group/directory\n", |
| 73 | + "```\n", |
| 74 | + "3. **Target Scope**\n", |
| 75 | + " For fine-grained control over individual targets, the working directory can be specified at the target scope.\n", |
| 76 | + "```yaml\n", |
| 77 | + "version: 1.0\n", |
| 78 | + "\n", |
| 79 | + "groups:\n", |
| 80 | + " my-group:\n", |
| 81 | + " targets:\n", |
| 82 | + " my-target:\n", |
| 83 | + " working-directory: /path/to/target/directory\n", |
| 84 | + " run: |\n", |
| 85 | + " # This target operates within the /path/to/target/directory\n", |
| 86 | + "```\n", |
| 87 | + "\n", |
| 88 | + "The flexibility provided by these scopes ensures that your commands are executed in precisely the right context, maintaining a clean and organized project structure." |
| 89 | + ] |
| 90 | + }, |
| 91 | + { |
| 92 | + "cell_type": "markdown", |
| 93 | + "id": "05c11ec2-7749-4db0-832b-0738d63c22c0", |
| 94 | + "metadata": {}, |
| 95 | + "source": [ |
| 96 | + "## Why is it helpful?" |
| 97 | + ] |
| 98 | + }, |
| 99 | + { |
| 100 | + "cell_type": "markdown", |
| 101 | + "id": "ae7bdee0-f8e5-4844-9dbd-1dafb0622b4d", |
| 102 | + "metadata": {}, |
| 103 | + "source": [ |
| 104 | + "Embracing the Working Directory feature in Makim brings forth a multitude of advantages, enhancing the overall project management experience. Let's delve into why this feature is a game-changer for your Makim configurations:\n", |
| 105 | + "1. **Isolation of Commands:**\n", |
| 106 | + " Users can isolate commands within specific directories, avoiding potential conflicts and ensuring that commands run in the expected environment.\n", |
| 107 | + "\n", |
| 108 | + "2. **Flexibility in Configuration:**\n", |
| 109 | + " Different targets or groups may require different execution environments. The working-directory attribute provides the flexibility to customize these environments, tailoring them to the unique needs of each segment of your project.\n", |
| 110 | + "\n", |
| 111 | + "3. **Ease of Use:**\n", |
| 112 | + " Users can easily understand and manage the execution context of commands within the Makim configuration. This makes the configuration more readable and maintainable, especially when dealing with complex project structures.\n", |
| 113 | + "\n", |
| 114 | + "4. **Support for Absolute and Relative Paths:**\n", |
| 115 | + " The feature supports both absolute and relative paths, allowing users to specify directories based on their requirements. This flexibility ensures compatibility with diverse project structures and simplifies the configuration process." |
| 116 | + ] |
| 117 | + }, |
| 118 | + { |
| 119 | + "cell_type": "markdown", |
| 120 | + "id": "35312475-67f7-4108-a328-7235b032cc8c", |
| 121 | + "metadata": {}, |
| 122 | + "source": [ |
| 123 | + "## Real-Life Example" |
| 124 | + ] |
| 125 | + }, |
| 126 | + { |
| 127 | + "cell_type": "markdown", |
| 128 | + "id": "e5dbbc1a-59d1-4028-9575-d21f2e2e12ef", |
| 129 | + "metadata": {}, |
| 130 | + "source": [ |
| 131 | + "Consider a scenario where a development team is working on a project that involves multiple programming languages and technologies. The project structure looks like this:" |
| 132 | + ] |
| 133 | + }, |
| 134 | + { |
| 135 | + "cell_type": "raw", |
| 136 | + "id": "edeab9cc-5fa2-44ac-b1fb-5570c5f5753c", |
| 137 | + "metadata": {}, |
| 138 | + "source": [ |
| 139 | + "multi_language_project/\n", |
| 140 | + "│\n", |
| 141 | + "├── backend/\n", |
| 142 | + "│ ├── python/\n", |
| 143 | + "│ │ └── src/\n", |
| 144 | + "│ └── java/\n", |
| 145 | + "│ └── src/\n", |
| 146 | + "│\n", |
| 147 | + "└── frontend/\n", |
| 148 | + " ├── react/\n", |
| 149 | + " │ └── src/\n", |
| 150 | + " └── vue/\n", |
| 151 | + " └── src/\n" |
| 152 | + ] |
| 153 | + }, |
| 154 | + { |
| 155 | + "cell_type": "markdown", |
| 156 | + "id": "5dcf2f8e-d41c-4684-b305-16c382af2216", |
| 157 | + "metadata": {}, |
| 158 | + "source": [ |
| 159 | + "The project consists of a backend with components implemented in both Python and Java, and a frontend with components using React and Vue.js. To efficiently manage and run tasks for each language or framework, the Working Directory feature proves invaluable.\n", |
| 160 | + "\n", |
| 161 | + "Let's create a Makim configuration file (makim.yaml) that showcases the flexibility of the Working Directory feature in managing tasks for different languages.\n", |
| 162 | + "\n", |
| 163 | + "```yaml\n", |
| 164 | + "version: 1.0\n", |
| 165 | + "working-directory: \"/multi_language_project\"\n", |
| 166 | + "groups:\n", |
| 167 | + " backend_python:\n", |
| 168 | + " working-directory: \"backend/python\"\n", |
| 169 | + " targets:\n", |
| 170 | + " test:\n", |
| 171 | + " run: |\n", |
| 172 | + " echo \"Running Python backend tests...\"\n", |
| 173 | + " # Add commands to run Python backend tests\n", |
| 174 | + " lint:\n", |
| 175 | + " run: |\n", |
| 176 | + " echo \"Linting Python code...\"\n", |
| 177 | + " # Add commands for linting Python code\n", |
| 178 | + "\n", |
| 179 | + " backend_java:\n", |
| 180 | + " working-directory: \"backend/java\"\n", |
| 181 | + " targets:\n", |
| 182 | + " test:\n", |
| 183 | + " working-directory: \"src\"\n", |
| 184 | + " run: |\n", |
| 185 | + " echo \"Running Java backend tests...\"\n", |
| 186 | + " # Add commands to run Java backend tests\n", |
| 187 | + " build:\n", |
| 188 | + " run: |\n", |
| 189 | + " echo \"Building Java artifacts...\"\n", |
| 190 | + " # Add commands for building Java artifacts\n", |
| 191 | + "\n", |
| 192 | + " frontend_react:\n", |
| 193 | + " working-directory: \"frontend/react\"\n", |
| 194 | + " targets:\n", |
| 195 | + " test:\n", |
| 196 | + " run: |\n", |
| 197 | + " echo \"Running React frontend tests...\"\n", |
| 198 | + " # Add commands to run React frontend tests\n", |
| 199 | + " build:\n", |
| 200 | + " run: |\n", |
| 201 | + " echo \"Building React frontend...\"\n", |
| 202 | + " # Add commands for building React frontend\n", |
| 203 | + "\n", |
| 204 | + " frontend_vue:\n", |
| 205 | + " working-directory: \"frontend/vue\"\n", |
| 206 | + " targets:\n", |
| 207 | + " test:\n", |
| 208 | + " run: |\n", |
| 209 | + " echo \"Running Vue.js frontend tests...\"\n", |
| 210 | + " # Add commands to run Vue.js frontend tests\n", |
| 211 | + " build:\n", |
| 212 | + " working-directory: \"src\"\n", |
| 213 | + " run: |\n", |
| 214 | + " echo \"Building Vue.js frontend...\"\n", |
| 215 | + " # Add commands for building Vue.js frontend\n", |
| 216 | + "\n", |
| 217 | + "```" |
| 218 | + ] |
| 219 | + }, |
| 220 | + { |
| 221 | + "cell_type": "code", |
| 222 | + "execution_count": 3, |
| 223 | + "id": "726bcf5a-7cc5-4448-af62-0564e2cbe1a1", |
| 224 | + "metadata": {}, |
| 225 | + "outputs": [ |
| 226 | + { |
| 227 | + "name": "stdout", |
| 228 | + "output_type": "stream", |
| 229 | + "text": [ |
| 230 | + "Writing .makim.yaml\n" |
| 231 | + ] |
| 232 | + } |
| 233 | + ], |
| 234 | + "source": [ |
| 235 | + "%%writefile .makim.yaml\n", |
| 236 | + "version: 1.0\n", |
| 237 | + "working-directory: \"/multi_language_project\"\n", |
| 238 | + "groups:\n", |
| 239 | + " backend_python:\n", |
| 240 | + " working-directory: \"backend/python\"\n", |
| 241 | + " targets:\n", |
| 242 | + " test:\n", |
| 243 | + " run: |\n", |
| 244 | + " echo \"Running Python backend tests...\"\n", |
| 245 | + " # Add commands to run Python backend tests\n", |
| 246 | + " lint:\n", |
| 247 | + " run: |\n", |
| 248 | + " echo \"Linting Python code...\"\n", |
| 249 | + " # Add commands for linting Python code\n", |
| 250 | + "\n", |
| 251 | + " backend_java:\n", |
| 252 | + " working-directory: \"backend/java\"\n", |
| 253 | + " targets:\n", |
| 254 | + " test:\n", |
| 255 | + " working-directory: \"src\"\n", |
| 256 | + " run: |\n", |
| 257 | + " echo \"Running Java backend tests...\"\n", |
| 258 | + " # Add commands to run Java backend tests\n", |
| 259 | + " build:\n", |
| 260 | + " run: |\n", |
| 261 | + " echo \"Building Java artifacts...\"\n", |
| 262 | + " # Add commands for building Java artifacts\n", |
| 263 | + "\n", |
| 264 | + " frontend_react:\n", |
| 265 | + " working-directory: \"frontend/react\"\n", |
| 266 | + " targets:\n", |
| 267 | + " test:\n", |
| 268 | + " run: |\n", |
| 269 | + " echo \"Running React frontend tests...\"\n", |
| 270 | + " # Add commands to run React frontend tests\n", |
| 271 | + " build:\n", |
| 272 | + " run: |\n", |
| 273 | + " echo \"Building React frontend...\"\n", |
| 274 | + " # Add commands for building React frontend\n", |
| 275 | + "\n", |
| 276 | + " frontend_vue:\n", |
| 277 | + " working-directory: \"frontend/vue\"\n", |
| 278 | + " targets:\n", |
| 279 | + " test:\n", |
| 280 | + " run: |\n", |
| 281 | + " echo \"Running Vue.js frontend tests...\"\n", |
| 282 | + " # Add commands to run Vue.js frontend tests\n", |
| 283 | + " build:\n", |
| 284 | + " working-directory: \"src\"\n", |
| 285 | + " run: |\n", |
| 286 | + " echo \"Building Vue.js frontend...\"\n", |
| 287 | + " # Add commands for building Vue.js frontend" |
| 288 | + ] |
| 289 | + }, |
| 290 | + { |
| 291 | + "cell_type": "code", |
| 292 | + "execution_count": 4, |
| 293 | + "id": "6896833c-7464-4d8d-b419-4f2991f00dcb", |
| 294 | + "metadata": {}, |
| 295 | + "outputs": [ |
| 296 | + { |
| 297 | + "data": { |
| 298 | + "text/plain": [ |
| 299 | + "2" |
| 300 | + ] |
| 301 | + }, |
| 302 | + "execution_count": 4, |
| 303 | + "metadata": {}, |
| 304 | + "output_type": "execute_result" |
| 305 | + } |
| 306 | + ], |
| 307 | + "source": [ |
| 308 | + "1 + 1" |
| 309 | + ] |
| 310 | + }, |
| 311 | + { |
| 312 | + "cell_type": "code", |
| 313 | + "execution_count": null, |
| 314 | + "id": "708e264b-fcf8-4515-bef7-08410a4026c4", |
| 315 | + "metadata": {}, |
| 316 | + "outputs": [], |
| 317 | + "source": [] |
| 318 | + } |
| 319 | + ], |
| 320 | + "metadata": { |
| 321 | + "kernelspec": { |
| 322 | + "display_name": "Python 3 (ipykernel)", |
| 323 | + "language": "python", |
| 324 | + "name": "python3" |
| 325 | + }, |
| 326 | + "language_info": { |
| 327 | + "codemirror_mode": { |
| 328 | + "name": "ipython", |
| 329 | + "version": 3 |
| 330 | + }, |
| 331 | + "file_extension": ".py", |
| 332 | + "mimetype": "text/x-python", |
| 333 | + "name": "python", |
| 334 | + "nbconvert_exporter": "python", |
| 335 | + "pygments_lexer": "ipython3", |
| 336 | + "version": "3.8.1" |
| 337 | + } |
| 338 | + }, |
| 339 | + "nbformat": 4, |
| 340 | + "nbformat_minor": 5 |
| 341 | +} |
0 commit comments