Skip to content

fixed bash for loop, now testing using env variable instead of modify… #117

fixed bash for loop, now testing using env variable instead of modify…

fixed bash for loop, now testing using env variable instead of modify… #117

Workflow file for this run

name: Run clang-format Linter
on:
push:
branches:
- main
- dev
- issue-128-2
pull_request_target:
branches:
- main
- dev
- issue-128-2
workflow_dispatch:
jobs:
format:
runs-on: ubuntu-latest
outputs:
changed_files: ${{ steps.process-list.outputs.changed_files}}
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- uses: actions/checkout@v3
with:
# check out HEAD on the branch
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
# make sure the parent commit is grabbed as well, because
# that's what will get formatted (i.e. the most recent commit)
fetch-depth: 2
# format the latest commit
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v28.0.0
with:
files: |
src/Features/*.cpp
src/Features/*.h
**/*.hlsl
**/*.hlsli
separator: ","
- name: List all changed files
id: process-list
run: |
echo ${{ steps.changed-files.outputs.all_changed_files }}
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file was changed"
done
ALL_CHANGED_FILES=(${{ steps.changed-files.outputs.all_changed_files }})
echo "${ALL_CHANGED_FILES[@]}"
LIST_LENGTH=${#ALL_CHANGED_FILES[*]}
echo $LIST_LENGTH
PROCESS_OUTPUT=""
# for (( i=0; i<${LIST_LENGTH}; i++ ));
# do
# PROCESS_OUTPUT+=\'
# PROCESS_OUTPUT+="${ALL_CHANGED_FILES[$i]}"
# if [[ $i != "$(($LIST_LENGTH - 1))" ]];
# then
# PROCESS_OUTPUT+=' '
# fi
# done
# echo $PROCESS_OUTPUT
IFS=$',' read -a MODIFIED_FILES_ARRAY <<< "${{ steps.changed-files.outputs.all_changed_files }}"
for file in "${MODIFIED_FILES_ARRAY[@]}"; do
echo $file
done
PROCESS_OUTPUT="${PROCESS_OUTPUT// /\\ }"
echo $PROCESS_OUTPUT
echo "::set-outputs name=changed_files::${PROCESS_OUTPUT}"
echo ${{ steps.changed-files.outputs.all_changed_files }}
my_changed_files=""
echo "my_changed_files=${PROCESS_OUTPUT}"
echo "changed_files=${PROCESS_OUTPUT}" >> "$GITHUB_OUTPUT"
echo "$changed_files"
echo ${{ env.changed_files }}
- name: Format changed files
if: steps.changed-files.outputs.any_changed == 'true'
uses: DoozyX/clang-format-lint-action@v0.16.2
with:
# source: ${{ steps.process-list.outputs.all_changed_files }}
source: ${{ steps.process-list.outputs.changed_files }}
exclude: "extern include"
extensions: "h,cpp,c,hlsl,hlsli"
clangFormatVersion: 16
inplace: True # commit the changes (if there are any)
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "style: 🎨 apply clang-format changes"
branch: ${{ github.head_ref }}