diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e0ebe68f..5a4a8fddd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,6 +42,29 @@ jobs: check-path: ${{ matrix.path }} fallback-style: 'Mozilla' # optional + check_ark: + name: ArkScript formatting check + runs-on: ubuntu-24.04 + + strategy: + fail-fast: false + matrix: + path: + - /src/examples + - /src/tests/arkscript + + container: + image: arkscript/nightly + volumes: + - ${{ github.workspace }}:/src + + steps: + - uses: actions/checkout@v4 + - name: Format check + uses: ./.github/workflows/format-check-arkscript + with: + folder: ${{ matrix.path }} + repo_visualizer: runs-on: ubuntu-24.04 needs: [ check ] diff --git a/.github/workflows/format-check-arkscript/action.yaml b/.github/workflows/format-check-arkscript/action.yaml new file mode 100644 index 000000000..3efdd6f18 --- /dev/null +++ b/.github/workflows/format-check-arkscript/action.yaml @@ -0,0 +1,22 @@ +--- +name: 'Format check ArkScript code' +description: 'Given a folder, find all .ark files and check that they are correctly formatted' +inputs: + folder: + description: 'Folder with .ark files to check' + required: true + +runs: + using: 'composite' + steps: + - name: Check + shell: sh + run: | + failures=0 + while read -rd $'\0' file; do + if ! arkscript --format "$file" --check; then + echo "❌ $(basename $file) is not formatted correctly" + failures=$((failures+1)) + fi + done < <(find "${{ inputs.folder }}" -type f -name "*.ark" -print0) + [ $failures -gt 0 ] && exit 1