.rwx dir
The RWX CLI will automatically pick up the contents of your .rwx
directory.
This allows you to test changes locally without having to commit and push.
In addition to the specific file that you're running with --file
, you can place other files in the .rwx
directory.
This is especially helpful with docker compose, embedded runs, and dynamic tasks.
Embedded Runs
.rwx/greeting.yml
tasks:
- key: greeting
run: echo "Hello $NAME!"
env:
NAME: ${{ init.name }}
.rwx/example.yml
tasks:
- key: greet-world
call: ${{ run.dir }}/greeting.yml
init:
name: 'World'
- key: greet-rwx
call: ${{ run.dir }}/greeting.yml
init:
name: 'RWX'
rwx run --file .rwx/example.yml --open
Dynamic Tasks
If you generate dynamic tasks, you may want to place the scripts to generate the tasks in the .rwx
directory.
This will enable you to work on the scripts without having to commit and push to test them.
.rwx/support/generate-tasks.js
const yaml = require('yaml')
const tasks = ['a', 'b', 'c'].map((letter) => {
return {
key: letter,
run: 'echo "this is task $LETTER"',
env: {
LETTER: letter,
},
}
})
process.stdout.write(yaml.stringify(tasks))
.rwx/example.yml
tasks:
- key: dynamic-tasks-node
call: nodejs/install 1.1.4
with:
node-version: '22.12.0'
- key: dynamic-tasks-deps
use: dynamic-tasks-node
run: |
npm install -g [email protected]
npm root -g > $RWX_ENV/NODE_PATH
- key: generate-tasks
use: dynamic-tasks-deps
run: |
node ${{ run.dir }}/support/generate-tasks.js | tee $RWX_DYNAMIC_TASKS/tasks.yml
Caching
When using ${{ run.dir }}
, the entire contents of the .rwx
directory is provided to the task.
Therefore, any change within the .rwx
directory will affect the cache key for the task.
To prevent cache busting every task that uses the .rwx
dir every time any file in the .rwx
dir changes, add a filter
to your task.
You do not need to do this for embedded runs that use call
, you only need it do it for tasks that use ${{ run.dir }}
within run
or env
In the previous example with dynamic tasks, you'd actually want to specify the task like this:
- key: generate-tasks
use: dynamic-tasks-deps
run: |
node ${{ run.dir }}/support/generate-tasks.js | tee $RWX_DYNAMIC_TASKS/tasks.yml
filter:
${{ run.dir }}:
- support/generate-tasks.js