19
19
echo 'export MODULAR_HOME="/home/runner/.modular"' >> "$BASHRC"
20
20
echo 'export PATH="/home/runner/.modular/pkg/packages.modular.com_mojo/bin:$PATH"' >> "$BASHRC"
21
21
source "$BASHRC"
22
- mojo --version
22
+ mojo --version
23
+
24
+ - name : Filter files changed
25
+ uses : dorny/paths-filter
26
+ id : filter
27
+ with :
28
+ # Enable listing of files matching each filter.
29
+ # Paths to files will be available in `${FILTER_NAME}_files` output variable.
30
+ # Paths will be escaped and space-delimited.
31
+ # Output is usable as command-line argument list in Linux shell.
32
+ list-files : shell
33
+
34
+ filters : |
35
+ mojo:
36
+ - added|modified: '**/*.mojo'
37
+ - added|modified: '**/*.🔥'
38
+
39
+ # While this may seem like debugging, it's useful to see what's going on
40
+ # at a glance in this workflow.
41
+ - name : Print file changes
42
+ run : |
43
+ echo "Mojo files changed below:"
44
+ echo ${{ steps.filter.outputs.mojo_files }}
45
+
46
+ - name : mojo-formatting
47
+ if : ${{ steps.filter.outputs.mojo == 'true' }}
48
+ run : |
49
+ shopt -s expand_aliases
50
+ VERBOSE=1 source $GITHUB_WORKSPACE/utils/start-modular.sh
51
+
52
+ # The list of files from the filter step is relative to the checkout
53
+ # root.
54
+ cd $GITHUB_WORKSPACE
55
+
56
+ mojo format ${{ steps.filter.outputs.mojo_files }}
57
+
58
+ # Check if any lines were formatted. If any were, fail this step.
59
+ if [ $(git diff | wc -l) -gt 0 ]; then
60
+ echo -e "\nError! Mojo code not formatted. Run `mojo format` ...\n"
61
+ echo -e "\nFiles that don't match the proper formatting:\n"
62
+ git diff --name-only
63
+ echo -e "\nFull diff:\n"
64
+ git diff
65
+ exit 1
66
+ fi
67
+
68
+ # TODO: Support linting of markdown files using markdown-lint
0 commit comments