Skip to content

Commit

Permalink
feat: refactor, more tests and improve cli ui
Browse files Browse the repository at this point in the history
  • Loading branch information
easbarba committed Jul 28, 2024
1 parent f541954 commit 12e3b61
Show file tree
Hide file tree
Showing 37 changed files with 397 additions and 190 deletions.
Empty file added .clang-tidy
Empty file.
4 changes: 4 additions & 0 deletions .containerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ PROTOCOL.md
README.md
TODO.md
manifest.scm
/build
/subprojects/*
!/subprojects/*.wrap
/.cache
17 changes: 17 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: tests

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
build:
runs-on: ubuntu-latest
container:
image: registry.gitlab.com/easbarba/onur-cpp:0.2.0

steps:
- name: integration tests
run: meson test -C /home/easbarba/app/build
15 changes: 15 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
image: registry.gitlab.com/easbarba/onur-cpp:0.2.0

stages:
- test

workflow:
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == 'main'

Integration Tests:
stage: test
script:
- meson test -C /home/easbarba/app/build
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ along with Onur. If not, see <https://www.gnu.org/licenses/>.

## 0.2.0

- feat: refactor, more tests and improve cli ui
- feat: add pull and klone actions
- feat: parse and bundle configurations
- feat: get all config files names
Expand Down
11 changes: 5 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ Contributions are welcome via pull request.

Please make sure to successfully check-up the guidelines list before sending a PR:

- run `./prfix.bash`
- run tests
- check for updates
```sh
```

- run usual checkers with `./prfix.bash`:
- add due entries changes in `CHANGELOG.md`
- tag per [SemVer](http://semver.org/).

## dependencies

- DaveGamble/cJSON
34 changes: 31 additions & 3 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
FROM debian:unstable-slim
WORKDIR /app
FROM debian:unstable

MAINTAINER EAS Barbosa <[email protected]>
LABEL version=${ONUR_VERSION}
LABEL description="Easily manage multiple FLOSS repositories."

RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential git meson cmake ca-certificates && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV USER_NAME easbarba
ENV XDG_CONFIG_HOME /home/$USER_NAME/.config
ENV APP_HOME /home/$USER_NAME/app

RUN groupadd -r $USER_NAME &&\
useradd -r -g $USER_NAME -m -s /bin/bash $USER_NAME &&\
chown -R $USER_NAME /home/$USER_NAME &&\
usermod -aG sudo $USER_NAME

WORKDIR $APP_HOME
COPY examples/ $XDG_CONFIG_HOME/onur
COPY . .
RUN ./prepare.bash
CMD [ "test" ]

RUN chown -R $USER_NAME:$USER_NAME /home/$USER_NAME
USER $USER_NAME

RUN ls -la $APP_HOME
RUN CC=g++ meson setup $APP_HOME/build --wipe --backend ninja
RUN CC=g++ meson compile -C $APP_HOME/build

CMD [ "meson", "test", "-C", $APP_HOME/build ]
68 changes: 38 additions & 30 deletions Makefile → GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,40 @@

# DEPS: gcc meson ninja muon coreutils valgrind indent splint cunit

.DEFAULT_GOAL: test
PREFIX ?= ${HOME}/.local/bin
NAME = onur
NAME = onur-cpp
RM = rm -rf

BUILDDIR = ./build

RUNNER := podman
VERSION := $(shell awk -F "'" '/version:/ { print $$2; exit }' meson.build)
CONTAINER_IMAGE := registry.gitlab.com/${USER}/${NAME}:${VERSION}

# ------------------------------------ TASKS

.PHONY: all
all: deps
all:
CC=g++ meson setup $(BUILDDIR) --wipe
CC=g++ meson compile -C $(BUILDDIR)

.PHONY: deps
deps:
CC=g++ meson setup build --wipe

.PHONY: dev
dev:
CC=g++ meson setup $(BUILDDIR)
CC=g++ meson compile -C $(BUILDDIR)

.PHONY: cmake
all:
cmake:
cmake -B ${BUILDDIR} -S .
cmake --build ${BUILDDIR}

.PHONY: test
test:
@echo "testing"

.PHONY: clean
clean:
@$(RM) $(BUILDDIR)

.PHONY: install
install:
cp -v ${BUILDDIR}/${NAME} ${PREFIX}/${NAME}
cp -v ${BUILDDIR}/onur ${PREFIX}/${NAME}

.PHONY: uninstall
uninstall:
Expand All @@ -60,7 +58,7 @@ format:

.PHONY: lint
lint:
splint -preproc -unrecog -warnposix src/*.c
clang-check ./src/*.cpp

.PHONY: leaks
leaks:
Expand All @@ -71,23 +69,33 @@ leaks:
./build/onur grab
# --log-file=valgrind-output \
# ------------------------------------ ACTIONS

.PHONY: default
default:
$(BUILDDIR)/$(NAME)

.PHONY: usage
usage:
$(BUILDDIR)/$(NAME) --help
# ------------------------------- CONTAINER

.PHONY: grab
grab:
$(BUILDDIR)/$(NAME) grab
.PHONY: image.build
image.build:
${RUNNER} build --file ./Containerfile --tag ${CONTAINER_IMAGE} --env ONUR_VERSION=${VERSION}

.PHONY: backup
backup:
$(BUILDDIR)/$(NAME) backup meh,foo,bar
.PHONY: image.repl
image.repl:
${RUNNER} run --rm -it \
--volume ${PWD}:/app:Z \
--workdir /home/easbarba/app \
${CONTAINER_IMAGE} bash

.PHONY: image.publish
image.publish:
${RUNNER} push ${CONTAINER_IMAGE}

.DEFAULT_GOAL: test
.PHONY: test
test:
${RUNNER} run --rm -it \
--volume ${PWD}:/app:Z \
--workdir /home/easbarba/app \
${CONTAINER_IMAGE} bash -c "meson test -C build"

.PHONY: image.commands
image.commands:
${RUNNER} run --rm -it \
--volume ${PWD}:/app:Z \
--workdir /home/easbarba/app \
${CONTAINER_IMAGE} bash -c "$(shell cat ./container-commands | fzf)"
65 changes: 48 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,23 @@ along with Onur. If not, see <https://www.gnu.org/licenses/>.
# Onur

Easily manage multiple FLOSS repositories.
[c](https://gitlab.com/easbarba/onur-c) |
[go](https://gitlab.com/easbarba/onur-go) | [python](https://gitlab.com/easbarba/onur-python) | [rust](https://gitlab.com/easbarba/onur-rust) | [php](https://gitlab.com/easbarba/onur-php) | [java](https://gitlab.com/easbarba/onur-java)

## USAGE
[c](https://gitlab.com/easbarba/onur) | [dotnet](https://gitlab.com/easbarba/onur-dotnet) | [go](https://gitlab.com/easbarba/onur-go) | [python](https://gitlab.com/easbarba/onur-python) | [rust](https://gitlab.com/easbarba/onur-rust) | [php](https://gitlab.com/easbarba/onur-php) | [java](https://gitlab.com/easbarba/onur-java)

`Onur` consumes configuration in the following manners:

By default it looks for configuration files at `$XDG_CONFIG/onur` or in the directory set in the `$ONUR_CONFIG_HOME` environment variable.
## Usage

```shell
onur grab
onur archive nuxt,awesomewm,gitignore
onur help
onur backup nuxt awesomewm gitignore
onur --help
```

## INSTALLATION

`Onur` requires a [C++20](https://gcc.gnu.org/) compiler and [Meson](https://mesonbuild.com/), then just run `make clean all`, and executable file will be placed at `$PWD/.build/onur`.

Tip: A clean install without messing around your system is easily achievable with [GNU Guix](https://guix.gnu.org/manual/devel/en/html_node/Invoking-guix-shell.html): `guix shell --check`.
## Configuration file

## CONFIGURATION FILE
`onur` consumes configuration in the following manners:

A `onur` single configuration file:
By default it looks for configuration files at `$XDG_CONFIG/onur` or in the
directory set in the `$ONUR_CONFIG_HOME` environment variable.

```json
{
Expand All @@ -64,24 +57,62 @@ A `onur` single configuration file:
"branch": "main",
"url": "https://github.com/nuxt/framework"
}
],
"tools/gnu": [
{
"name": "inetutils",
"url": "https://git.savannah.gnu.org/git/inetutils.git"
},
{
"name": "gnu-wget",
"url": "https://git.savannah.gnu.org/git/wget.git"
}
]
}
```

More examples of configuration files are at `examples`.

## SETTINGS
## Settings

`settings.toml`

```toml
[git]
single-branch = true
quiet = true
depth = 1
```

## SCREENSHOT
## Installation

`onur` requires a c++ 20 compiler and `meson` to install, locally at `$HOME/.local/bin`, easily with : `make all install`.

## Development

In development it may suit you better running the tests in a isolated environment
with containers, that can be done so:

docker run --rm -it $(docker build -qf Containerfile.run)

or:

podman build https://gitlab.com/easbarba/onur/-/raw/main/Containerfile.dev --tag onur:latest
podman run --rm -it onur:latest


## GNU Guix

In a system with GNU Guix binary installed, its even easier to grab all
dependencies: `guix shell`.

![Onur CLI](onur.png)


## TODO

Check the `TODO.md` for more information.

## LICENSE

[GNU GENERAL PUBLIC LICENSE Version 3](https://www.gnu.org/licenses/gpl-3.0.en.html)
5 changes: 5 additions & 0 deletions container-commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
./build/onur grab
./build/onur backup awesomewm,git,apple-swift
./build/onur --help

meson test
3 changes: 3 additions & 0 deletions examples/incomplete.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"main": []
}
12 changes: 12 additions & 0 deletions examples/lua.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"lua": [
{
"name": "lua-repl",
"url": "https://github.com/hoelzro/lua-repl"
},
{
"name": "lua",
"url": "https://github.com/lua/lua"
}
]
}
1 change: 1 addition & 0 deletions examples/settings.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[git]
single-branch = true
quiet = false
depth = 3
Loading

0 comments on commit 12e3b61

Please sign in to comment.