Skip to content

Commit

Permalink
add ansible scaffolding and automation script;
Browse files Browse the repository at this point in the history
change relative path to shell variable expansion
feat: add Dockerfile basic structure
feat: add compose.yml basic structure
feat: add actions workflow for nvim CI
  • Loading branch information
deomorxsy committed May 22, 2024
1 parent e112e1d commit dd016d9
Show file tree
Hide file tree
Showing 20 changed files with 830 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .config/audio/ncmpcpp/config
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ statusbar_time_color = cyan:b
# Port and dir configuration
mpd_host = localhost
mpd_port = 6601
mpd_music_dir = "/home/asari/Musicas"
mpd_music_dir = "$HOME/Musicas"


# Visualizer config
Expand Down
Empty file added .config/nvim/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions .config/nvim/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM alpine:3.19

RUN apk add --no-cache neovim


USER 1000
WORKDIR /$USER/rice/

COPY . .

RUN ./deorice/

ENTRYPOINT [ "nvim", "--headless", "-c" , "'so'", "-c", "'PackerSync'", " "${HOME}/.config/nvim/lua/user/packer.lua" " ]
3 changes: 1 addition & 2 deletions .config/nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ vim.o.packpath = vim.o.runtimepath
-- check ./lua/user/packer.lua for installed plugins

-- python interpreter path from virtualenv
vim.g.python3_host_prog = "/home/asari/.config/nvim/venv_nvim/neovim3/bin/python"

vim.g.python3_host_prog = "$HOME/.config/nvim/venv_nvim/neovim3/bin/python"

-- lsp
-- Mason Setup
Expand Down
2 changes: 1 addition & 1 deletion .config/nvim/lua/user/set.lua
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ local writer = vim.api.nvim_exec([[
]], true)

-- ncm2 completion requirements
vim.g.python3_host_prog="/usr/bin/python3"
vim.g.python3_host_prog = "$HOME/.config/nvim/venv_nvim/neovim3/bin/python"

-- Statusline
-- refer to user/newstatus.lua
Expand Down
Empty file added .github/.gitkeep
Empty file.
46 changes: 46 additions & 0 deletions .github/workflows/nvim-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# setup nvim
name: nvim

# This rule triggers when the workflow will run
on:
# run the workflow manually from Actions tab
workflow_dispatch:

# jobs can run in sequence or parallel in a workflow
jobs:
# This single job is called "build"
build:
# Specify the operating system for the runner job
runs-on: ubuntu-latest
env:
git_hash: $(git rev-parse --short "$GITHUB_SHA")

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# the job gets runned into $GITHUB_WORKSPACE, that is the environment variable for the repo
- name: Access current repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Build docker image
run: |
docker run -d -p 5000:5000 --name registry registry:2.7
# env git_hash env goes into the compose.yml
docker compose -f ./compose.yml --progress=plain build nvim
docker push localhost:5000/deonvim:latest
#podman build -t deonvim:latest -f ./utils/busybox/Dockerfile
- name: Retrieve artifact from docker image
run: |
docker run -it --name nvim -d localhost:5000/deonvim:latest
docker cp nvim:./asciinema_nvim ${{ github.workspace }}/artifacts/
- name: Archive the build artifact
uses: actions/upload-artifact@v3
with:
name: nvim
path: ${{ github.workspace }}/artifacts/asciinema_nvim


Empty file added .github/workflows/wm-ci.yml
Empty file.
18 changes: 18 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3.8"
services:
nvim:
environment:
- git_hash
build:
context: "."
dockerfile: "./.config/nvim/Dockerfile"
tags:
- "localhost:5000/deonvim:latest"
stop_signal: SIGINT
dwm:
build:
context: "./wms/dwm/"
tags:
- "localhost:5000/deodwm:latest"
stop_signal: SIGINT

60 changes: 60 additions & 0 deletions scripts/ansible-scaffolding.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/sh
#
# basic ansible project
# directory structure scaffolding
#
# PS: run from the project root dir
#
# sh and dash only supports = for equality comparison,
# so use that instead of the == in C-like languages..
#
# [ .. ] can't match globs. Case statements: [[ .. ]] or grep.
# In POSIX sh, [[ .. ]] is undefined. POSIX sh uses [ ] and test instead.

check_path=$(pwd | grep deorice | awk -F/ '{print $NF}')

if [ "$check_path" = 'deorice' ]; then
cd ./scripts/playbooks/ || return


mkdir -p inventories/production \
inventories/staging \
group_vars \
host_vars \
library \
module_utils \
filter_plugins \
roles


#declare -a dirs
#
# find every directory and print it jumping lines
dirs_string="$(find . -type d -printf '%p\n')"


# counter and iterator for first line number
# this avoids creating a .gitkeep directly
# into the playbook directory.
counter=0
target_iter=1

# where index is each directory
printf '%s' "$dirs_string" |
while read -r index; do
# increment counter
counter=$((counter+1))

# if the iteration is not in the first line,
# create the gitkeep dotfile.
if [ ! "$counter" -eq "$target_iter" ]; then
#echo "$index"/.gitkeep
touch "$index"/.gitkeep
fi
done

#for x in "${!find_dirs[@]}"; do ls "$x"; done
#touch "{$(find scripts/playbooks/ -type d -printf '%p,')}/.gitkeep"

cd - || return
fi
Empty file added scripts/playbooks/.gitkeep
Empty file.
Loading

0 comments on commit dd016d9

Please sign in to comment.