@@ -21,43 +21,15 @@ concurrency:
2121 cancel-in-progress : ${{ github.ref != 'refs/heads/main' }}
2222
2323jobs :
24- style_format :
25- name : Style/format
26- runs-on : ${{ matrix.job.os }}
27- strategy :
28- fail-fast : false
29- matrix :
30- job :
31- - { os: ubuntu-latest, features: feat_os_unix }
24+ fmt :
25+ name : cargo fmt --all -- --check
26+ runs-on : ubuntu-latest
3227 steps :
3328 - uses : actions/checkout@v4
34- - uses : dtolnay/rust-toolchain@master
35- with :
36- toolchain : stable
37- components : rustfmt
29+ - uses : dtolnay/rust-toolchain@stable
3830 - uses : Swatinem/rust-cache@v2
39- - name : Initialize workflow variables
40- id : vars
41- shell : bash
42- run : |
43- ## VARs setup
44- outputs() { step_id="${{ github.action }}"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
45- # failure mode
46- unset FAIL_ON_FAULT ; case '${{ env.STYLE_FAIL_ON_FAULT }}' in
47- ''|0|f|false|n|no|off) FAULT_TYPE=warning ;;
48- *) FAIL_ON_FAULT=true ; FAULT_TYPE=error ;;
49- esac;
50- outputs FAIL_ON_FAULT FAULT_TYPE
51- - name : " `cargo fmt` testing"
52- shell : bash
53- run : |
54- ## `cargo fmt` testing
55- unset fault
56- fault_type="${{ steps.vars.outputs.FAULT_TYPE }}"
57- fault_prefix=$(echo "$fault_type" | tr '[:lower:]' '[:upper:]')
58- # * convert any errors/warnings to GHA UI annotations; ref: <https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-a-warning-message>
59- S=$(cargo fmt -- --check) && printf "%s\n" "$S" || { printf "%s\n" "$S" ; printf "%s\n" "$S" | sed -E -n -e "s/^Diff[[:space:]]+in[[:space:]]+${PWD//\//\\/}\/(.*)[[:space:]]+at[[:space:]]+[^0-9]+([0-9]+).*$/::${fault_type} file=\1,line=\2::${fault_prefix}: \`cargo fmt\`: style violation (file:'\1', line:\2; use \`cargo fmt -- \"\1\"\`)/p" ; fault=true ; }
60- if [ -n "${{ steps.vars.outputs.FAIL_ON_FAULT }}" ] && [ -n "$fault" ]; then exit 1 ; fi
31+ - run : rustup component add rustfmt
32+ - run : cargo fmt --all -- --check
6133
6234 style_lint :
6335 name : Style/lint
0 commit comments