Skip to content

Commit 84960a1

Browse files
Update c-cpp.yml
1 parent 3d945d5 commit 84960a1

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

.github/workflows/c-cpp.yml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,32 @@ on:
77
branches: [ "main" ]
88

99
jobs:
10-
build:
11-
10+
build-and-run:
1211
runs-on: ubuntu-latest
1312

1413
steps:
15-
- uses: actions/checkout@v4
16-
- name: configure
17-
run: ./configure
18-
- name: make
19-
run: make
20-
- name: make check
21-
run: make check
22-
- name: make distcheck
23-
run: make distcheck
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Compile and Run all C programs in the 'program' folder
18+
run: |
19+
# Check if any .c files exist to avoid errors
20+
if ! ls program/*.c 1> /dev/null 2>&1; then
21+
echo "No .c files found in 'program' directory. Skipping."
22+
exit 0
23+
fi
24+
25+
# Loop through each .c file in the 'program' directory
26+
for c_file in program/*.c; do
27+
# Create a unique name for the executable from the C file name
28+
# For example, "program/app.c" becomes "app_executable"
29+
executable_name=$(basename "$c_file" .c)_executable
30+
31+
echo "---"
32+
echo "Compiling: $c_file"
33+
gcc "$c_file" -o "$executable_name"
34+
35+
echo "Running: ./${executable_name}"
36+
./"$executable_name"
37+
echo "---"
38+
done

0 commit comments

Comments
 (0)