Skip to content

Commit

Permalink
Merge pull request #10 from RafikFarhad/develop
Browse files Browse the repository at this point in the history
Fix Exclude Input Identifier Error
  • Loading branch information
RafikFarhad committed Nov 12, 2023
2 parents 212967e + 8318a01 commit 4a04d8e
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 3 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/entrypoint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Entrypoint Tests

on:
push:
branches:
- master
pull_request:
branches:
- master

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test-entrypoint:
runs-on: ubuntu-22.04
container:
image: silkeh/clang:14
steps:
- uses: actions/checkout@v2
- name: Basic command works
env:
INPUT_SOURCES: 'examples/*.c'
INPUT_EXCLUDES: 'examples/file2.c'
INPUT_STYLE: "LLVM"
run: |
./entrypoint.sh | tee output || true
count1=$(grep -c "Checking file: ./examples/file1.c" output) || true
if [ $count1 -ne 1 ]; then
echo "file1.c should be checked"
exit 8
fi
count2=$(grep -c "Checking file: ./examples/file2.c" output) || true
if [ $count2 -ne 0 ]; then
echo "file2.c should not be checked"
exit 9
fi
echo "Basic command works"
10 changes: 7 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ function main() {
log "Action started"
resolve_inputs
log "Sources to check: $INPUT_SOURCES"
log "Excluding: $INPUT_EXCLUDES\n"
find_cmd $INPUT_SOURCES $INPUT_EXCLUDES FIND_CMD
if [ -n "$INPUT_EXCLUDES" ]; then
log "Excluding: $INPUT_EXCLUDES"
find_cmd "$INPUT_SOURCES" "$INPUT_EXCLUDES" FIND_CMD
else
find_cmd "$INPUT_SOURCES" "" FIND_CMD
fi

for file in $(eval $FIND_CMD); do
log "Checking file: $file"
Expand All @@ -89,7 +93,7 @@ function main() {
if [ $i -ne 0 ]; then
echo -n " && "
fi
echo "clang-format -style=file -i "${PROBLEMETIC_FILES[$i]}" \\"
echo "clang-format $STYLE -i "${PROBLEMETIC_FILES[$i]}" \\"
done
exit 1
fi
Expand Down
6 changes: 6 additions & 0 deletions examples/file1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>

int main() {
printf("Hello, World from file1!\n");
return 0;
}
7 changes: 7 additions & 0 deletions examples/file2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <stdio.h>

int main()
{
printf("Hello, World from file2!\n");
return 0;
}

0 comments on commit 4a04d8e

Please sign in to comment.