Use

In Mint task definitions, use defines the file system contents and environment variables that will be available when the task runs.

File System

Mint tracks which files are produced by which tasks and will merge them together in the order specified in use.

In the following example, one, and two run independently and in parallel, but cat-files will have both one.txt and two.txt available on disk.

tasks:
  - key: one
    run: echo task one generated this file | tee one.txt

  - key: two
    run: echo task two generated this file | tee two.txt

  - key: cat-files
    use: [one, two]
    run: |
      ls *.txt
      cat *.txt

cat-files will output:

one.txt
two.txt
task one generated this file
task two generated this file

Conflicts

If two tasks generate the same file, the last task listed under use will "win."

tasks:
  - key: one
    run: echo task one wrote this | tee file.txt

  - key: two
    run: echo task two wrote this | tee file.txt

  - key: cat-file
    use: [one, two]
    run: cat file.txt

Here, task cat-file will output:

task two wrote this

If you change cat-file to use: [two, one] then the logs will contain:

task one wrote this

In practice, it's uncommon to have multiple tasks that generate the same file, but you may need to be aware of this behavior.

Environment Variables

The use declaration will also make environment variables exported from tasks available in subsequent tasks.

tasks:
  - key: set-env-one
    run: echo hello >> $MINT_ENV/ONE

  - key: set-env-two
    run: echo world >> $MINT_ENV/TWO

  - key: print-env
    use: [set-env-one, set-env-two]
    run: |
      echo $ONE $TWO
      env | grep -E 'ONE|TWO'

The print-env task will output:

hello world
ONE=hello
TWO=world

For more details on environment variables, see the environment variables docs.