Skip to content

Commit

Permalink
feat: unit-testing and general improvements.
Browse files Browse the repository at this point in the history
Added tons of features, examples like better builtin support, semi-normal shell functionality, unit-testing support, proper execution through execve.
  • Loading branch information
h4rldev authored Sep 8, 2024
2 parents 6502c8d + 93187cd commit 089c546
Show file tree
Hide file tree
Showing 47 changed files with 4,277 additions and 2,854 deletions.
2 changes: 2 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CompileFlags:
Add: [-Wall, -Wextra, -I./include/]
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: C Test CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
strategy:
matrix:
os: [ubuntu-24.04, windows-latest]
include:
- {sys: clang64, env: clang-x86_64}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Install mold on ubuntu systems
if: matrix.os == 'ubuntu-24.04'
uses: rui314/setup-mold@2e332a0b602c2fc65d2d3995941b1b29a5f554a0 # v1
- name: Install msys-clang on windows systems.
if: matrix.os == 'windows-latest'
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.sys }}
install: |
libbsd
git
mingw-w64-${{matrix.env}}-just
mingw-w64-${{matrix.env}}-clang
- name: Install just on ubuntu
if: matrix.os == 'ubuntu-24.04'
uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2
- name: Test build on windows
if: matrix.os == 'windows-latest'
shell: msys2 {0}
run: just build
- name: Test build on ubuntu
if: matrix.os == 'ubuntu-24.04'
shell: bash
run: just build
- name: Run unit-tests on windows
if: matrix.os == 'windows-latest'
shell: msys2 {0}
run: just test
- name: Run unit-tests on ubuntu
if: matrix.os == 'ubuntu-24.04'
shell: bash
run: just test
9 changes: 5 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
motd.ubuntu.com:443
objects.githubusercontent.com:443
packages.microsoft.com:443
uploads.github.com:443
uploads.github.com:443
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
# Initializes the CodeQL tools for scanning.
Expand All @@ -90,6 +90,8 @@ jobs:
echo "export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
- name: Enable Mold.
uses: rui314/setup-mold@0bf4f07ef9048ec62a45f9dbf2f098afa49695f0 # v1
- name: Install just on ubuntu
uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2
- name: Install dependencies.
shell: bash
run: |
Expand All @@ -99,9 +101,8 @@ jobs:
if: matrix.build-mode == 'manual'
shell: bash
run: |
./scripts/build.sh -c hshell
./scripts/build.sh -l hshell
mv ./bin/hshell .
just build
mv ./build/bin/hsh .
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6
with:
Expand Down
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
/bin/
/out/
/build/bin/
/build/out/
/build/tests/
/hsh
/hshell
/hamon
/tests/unity
/vgcore
/.cache
/compile_commands.json
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ repos:
hooks:
- id: clang-format
- id: clang-tidy
- id: oclint
- id: uncrustify
- id: cppcheck
- id: cpplint
- id: include-what-you-use
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.5)
project(hamon)

include_directories(include)

add_executable(main src/main.c)
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ or **H**amon **SH**ell aka hsh.
A homemade shell in C.

Compiled with
[clang](https://github.com/llvm/llvm-project/tree/main/clang) or
[clang](https://github.com/llvm/llvm-project/tree/main/clang) or
[gcc](https://gcc.gnu.org) & linked with [mold](https://github.com/rui314/mold).

![[LICENSE](https://github.com/h4rldev/hshell/blob/main/LICENSE)](https://img.shields.io/github/license/h4rldev/hshell?style=flat-square)
![[OpenSSF Scorecard](https://securityscorecards.dev/viewer/?uri=github.com/h4rldev/hshell)](https://api.securityscorecards.dev/projects/github.com/h4rldev/hshell/badge?style=flat-square)

<a href="https://github.com/tatsoku/hamon/blob/main/LICENSE">
<img src="https://img.shields.io/github/license/tatsoku/hamon?style=flat-square"
alt="License: BSD 3-Clause" />
</a>
<a href="https://securityscorecards.dev/viewer/?uri=github.com/tatsoku/hamon">
<img src="https://api.securityscorecards.dev/projects/github.com/tatsoku/hamon/badge?style=flat-square"
alt="OpenSSF Scorecard" />
</a>

> \[!NOTE\]
> This project is in no way functional yet!
Expand Down Expand Up @@ -53,11 +60,11 @@ chmod +x ./scripts/build.sh
./scripts/build.sh -l hsh
```

_et voilà!_ Now it should be located in ./bin/ aswell.
_et voilà!_ Now it should be located in ./bin/ aswell.

## Contributing

Contribution is simple, make sure you're running an editor that works with C.
Contribution is simple, make sure you're running an editor that works with C and is using clang for compilation.

Such as:

Expand All @@ -70,13 +77,20 @@ Such as:
Just don't clutter the repo with config files for your editor.

You will also need to either have a shell that supports bash scripts,
unless you want to port
[build.sh](https://github.com/tatsoku/hamon/blob/main/scripts/build.sh)
for Powershell or Batch,
unless you want to port
[build.sh](https://github.com/tatsoku/hamon/blob/main/scripts/build.sh)
for Powershell or Batch,
which is ick, but I'll gladly accept a pr for it.

Also, one final thing, make sure you have pre-commit hooks.

> \[!NOTE\]
> Windows people!
Just copy and paste the win_compile_commands.json in build and change it so it fits your path.

Don't forget to rename it to compile_commands.json!

_direnv users who don't use nix, i'm sorry :(_

Made with :heart: by tatsoku-org!
Loading

0 comments on commit 089c546

Please sign in to comment.