Skip to content

Commit 9510a16

Browse files
committed
Update workflows, add README, and improve build and test setup
1 parent 7324b6a commit 9510a16

File tree

4 files changed

+160
-6
lines changed

4 files changed

+160
-6
lines changed

.github/workflows/complaince_check.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ jobs:
1818
sudo apt install -y gcc
1919
gcc --version
2020
- name: Compile
21-
run: gcc -std=c17 -o sumcli -Wall -Wextra main.c
21+
run: |
22+
gcc -std=c17 -o sumcli -Wall -Wextra main.c
23+
ll ./ | grep sumcli
24+
./sumcli
2225
2326
- name: Setup Node.js
2427
uses: actions/setup-node@v5
2528
with:
2629
node-version: 20
2730
- name: Test
28-
run: npx @microsoft/tui-test
31+
run: |
32+
npm install
33+
npm test
2934
- name: Print test snapshots
3035
run: cat test/__snapshots__/*.snap

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 4.0)
2-
project(poc_for_testing_cli_app C)
2+
project(sumcli C)
33

44
set(CMAKE_C_STANDARD 17)
55

6-
add_executable(poc_for_testing_cli_app main.c)
6+
add_executable(sumcli main.c)

README.md

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# SumCLI
2+
3+
A simple command-line calculator that adds two numbers together.
4+
5+
## Description
6+
7+
SumCLI is a lightweight C-based command-line tool that performs addition of two numbers. It accepts two numeric
8+
arguments and returns their sum with two decimal places precision.
9+
10+
## Features
11+
12+
- ✅ Add two numbers (integers or decimals)
13+
- ✅ Input validation and error handling
14+
- ✅ Help documentation
15+
- ✅ Automated testing with TUI Test framework
16+
- ✅ CI/CD pipeline with compliance checks
17+
18+
## Installation
19+
20+
### Prerequisites
21+
22+
- C compiler (GCC or Clang)
23+
- CMake (for building)
24+
- Node.js and npm (for running tests)
25+
26+
### Build from Source
27+
28+
1. Clone the repository:
29+
```bash
30+
git clone https://github.com/Interes-Group/cli_testing_poc
31+
cd cli_testing_poc
32+
```
33+
34+
2. Create build directory and compile:
35+
```bash
36+
mkdir build
37+
cd build
38+
cmake ..
39+
make
40+
```
41+
42+
It can be compiled with only gcc compiler
43+
```bash
44+
gcc -std=c17 -o sumcli -Wall -Wextra main.c
45+
```
46+
47+
3. The executable `sumcli` will be created in the build directory.
48+
49+
## Usage
50+
51+
```bash
52+
sumcli <first_number> <second_number>
53+
```
54+
55+
### Examples
56+
57+
```bash
58+
# Add two integers
59+
./sumcli 5 3
60+
# Output: The sum is 8.00
61+
62+
# Add decimal numbers
63+
./sumcli 2.5 1.7
64+
# Output: The sum is 4.20
65+
66+
# Add negative numbers
67+
./sumcli -10 15
68+
# Output: The sum is 5.00
69+
```
70+
71+
### Help
72+
73+
```bash
74+
./sumcli
75+
# Shows usage information and help text
76+
```
77+
78+
## Error Handling
79+
80+
The application provides clear error messages for common issues:
81+
82+
- **Too few arguments**: Displays error message and help when less than 2 numbers are provided
83+
- **Too many arguments**: Displays error message and help when more than 2 numbers are provided
84+
- **Invalid input**: Uses `atof()` which handles invalid numeric input gracefully
85+
86+
## Testing
87+
88+
This project uses the Microsoft TUI Test framework for automated testing.
89+
90+
### Run Tests
91+
92+
```bash
93+
cd test
94+
npm install
95+
npm test
96+
```
97+
98+
The test suite includes:
99+
100+
- Snapshot testing for output verification
101+
- Various input scenarios validation
102+
- Error condition testing
103+
104+
### Test Configuration
105+
106+
Tests are configured in `test/tui-test.config.js` and test cases are defined in `test/sumcli.test.js`.
107+
108+
## Development
109+
110+
### Project Structure
111+
112+
```
113+
poc_for_testing_cli_app/
114+
├── main.c # Main source code
115+
├── CMakeLists.txt # Build configuration
116+
├── test/ # Test directory
117+
│ ├── sumcli.test.js # Test cases
118+
│ ├── tui-test.config.js # Test configuration
119+
├── .github/workflows/ # CI/CD configuration
120+
└── README.md # This file
121+
```
122+
123+
### Contributing
124+
125+
1. Fork the repository
126+
2. Create a feature branch
127+
3. Make your changes
128+
4. Run tests to ensure they pass
129+
5. Submit a pull request
130+
131+
## CI/CD
132+
133+
The project includes GitHub Actions workflow for:
134+
135+
- Automated compliance checks
136+
- Build verification
137+
- Test execution
138+
139+
## License
140+
141+
See `LICENSE.txt` for license information.
142+
143+
## Requirements
144+
145+
- C99 compatible compiler
146+
- Standard C library
147+
- CMake 3.0 or higher (for building)
148+
- Node.js 16+ (for testing)

test/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
"name": "sumcli-test",
33
"version": "1.0.0",
44
"description": "",
5+
"private": true,
56
"main": "index.js",
67
"type": "module",
78
"scripts": {
8-
"test": "echo \"Error: no test specified\" && exit 1"
9+
"test": "npx @microsoft/tui-test"
910
},
1011
"keywords": [],
1112
"author": "",
12-
"license": "ISC",
13+
"license": "WTFPL",
1314
"packageManager": "pnpm@10.15.0",
1415
"devDependencies": {
1516
"@microsoft/tui-test": "0.0.1-rc.5"

0 commit comments

Comments
 (0)