Skip to content

Commit ec9b4fc

Browse files
paulopattoPaulo 'Patto' Santos
andauthored
breaking change(core): refactor installation scripts to use Makefile 🔧 (#66)
This pull request refactors the project's installation and setup process by replacing the legacy bootstrap and install scripts with a more structured and powerful Makefile. This change simplifies the setup process, improves maintainability, and adds support for different operating systems. - close #51 ### Main Changes: - Replaced `bootstrap` and `install` scripts: All installation and setup logic is now centralized in the Makefile. - Added `.editorconfig`: An .editorconfig file has been added to ensure consistent coding styles across different editors and IDEs. - Modular `Makefile`: The Makefile is organized into modular targets, allowing for the installation and configuration of specific components like base_packages, git_config, zsh_config, asdf_config, tmux_config, and nvim. - Improved OS Detection: The Makefile now automatically detects the operating system (macOS, Fedora, or Debian/Ubuntu) and uses the appropriate package manager (brew, dnf, or apt) to install the necessary dependencies. - Idempotent Targets: The Makefile targets are designed to be idempotent, meaning they can be run multiple times without causing issues. This is achieved by using marker files to track whether a target has already been executed. ### How to Use: To set up the development environment, simply run the following command: ```bash make bootstrap ``` This will install all the necessary packages and configure the dotfiles. To see all available commands, run make help. This refactoring makes the dotfiles project more robust, easier to manage, and more user-friendly for new contributors. --------- Co-authored-by: Paulo 'Patto' Santos <paulopatto@MacBookPro.bbrouter>
1 parent 1563930 commit ec9b4fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+666
-534
lines changed

.editorconfig

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,17 @@ charset = utf-8
1111
end_of_line = lf
1212
indent_style = space
1313
indent_size = 2
14-
insert_final_newline = true
1514
trim_trailing_whitespace = true
15+
insert_final_newline = true
16+
17+
[*.sh]
18+
indent_style = space
19+
indent_size = 2
20+
21+
[Makefile]
22+
indent_style = tab
1623

1724
# Markdown files
1825
[*.md]
1926
trim_trailing_whitespace = false
2027

21-

.github/workflows/CI.yaml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- '**.bash'
9+
- '**.sh'
10+
- '**.zsh'
11+
- 'tests/**'
12+
- '.github/workflows/bats.yml'
13+
- 'package.json'
14+
15+
jobs:
16+
test:
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
matrix:
20+
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
21+
os: [ubuntu-latest, macos-latest] #, windows-latest]
22+
node-version: [20]
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: ${{ matrix['node-version'] }}
32+
33+
34+
# - name: Setup Bats and bats libs
35+
# id: setup-bats
36+
# uses: bats-core/bats-action@3.0.1
37+
38+
- name: Install bats and helpers
39+
run: npm ci
40+
41+
- name: Run install script (bootstrap)
42+
run: make bootstrap
43+
44+
- name: Add bats to PATH
45+
run: echo "$(npm bin)" >> $GITHUB_PATH
46+
47+
- name: Run bats tests
48+
shell: bash
49+
env:
50+
TERM: xterm # Set TERM to a value that supports colors
51+
run: npm test
52+
53+
test-on-fedora-via-docker:
54+
runs-on: ubuntu-latest
55+
container:
56+
image: fedora:latest
57+
steps:
58+
- name: Checkout repository
59+
uses: actions/checkout@v4
60+
61+
- name: Setup Docker Buildx
62+
uses: docker/setup-buildx-action@v2
63+
64+
- name: Setup build essentials on fedora container
65+
run: |
66+
dnf install -y nodejs @c-development @development-tools
67+
68+
- name: Install bats and helpers
69+
run: npm ci
70+
71+
- name: Run install script (bootstrap)
72+
run: make bootstrap
73+
74+
- name: Add bats to PATH
75+
run: echo "$(npm bin)" >> $GITHUB_PATH
76+
77+
- name: Run bats tests
78+
shell: bash
79+
env:
80+
TERM: xterm # Set TERM to a value that supports colors
81+
run: npm test
82+
83+
# - name: Run tests in Fedora container
84+
# run: |
85+
# docker run --rm -v $PWD:/workspace -w /workspace fedora:latest bash -c "
86+
# dnf install -y nodejs &&
87+
# npm ci &&
88+
# echo "$(npm bin)" >> $GITHUB_PATH &&
89+
# make bootstrap &&
90+
# TERM=xterm npm test
91+
# "

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
tmux/plugins/
33
zsh/plugins/
44
nvim/lazy-lock.json
5+
tmux/.config/tmux/plugins/tpm/
6+
.bootstrap
7+
node_modules/

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.stowrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--target=~/
2+
--dotfiles
3+
--restow
4+
--verbose

Makefile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# List of packages to manage with GNU Stow
2+
STOW_PACKAGES := asdf git mcphub nvim tmux vscode zsh
3+
4+
# The stow command defaults to the parent of the current directory,
5+
# but we explicitly set it to HOME for clarity.
6+
STOW_TARGET := $(HOME)
7+
8+
# Variaveis
9+
SHELL := /bin/bash
10+
XDG_CONFIG_HOME := $(shell echo ~)/.config
11+
DOTFILES_HOME := $(shell pwd)
12+
13+
.PHONY: all base_packages git_config zsh_config asdf_config tmux_config nvim
14+
15+
.PHONY: all link unlink test
16+
17+
all: bootstrap link
18+
19+
link:
20+
@echo "Linking dotfiles to $(STOW_TARGET)..."
21+
@stow --restow $(STOW_PACKAGES)
22+
23+
unlink:
24+
@echo "Unlinking dotfiles from $(STOW_TARGET)..."
25+
@stow --delete $(STOW_PACKAGES)
26+
27+
28+
bootstrap:
29+
@echo "Verificando a necessidade de bootstrap..."
30+
@if [ ! -f .bootstrap ]; then \
31+
echo "Executando bootstrap de dependências do sistema..."; \
32+
./scripts/bootstrap.sh; \
33+
echo "Bootstrap concluído."; \
34+
touch .bootstrap; \
35+
else \
36+
echo "Bootstrap já realizado, arquivo .bootstrap encontrado."; \
37+
fi
38+
# nvim:
39+
# @echo "--> Configuring neovim"
40+
# @if [ ! -L "$(XDG_CONFIG_HOME)/nvim" ]; then \
41+
# echo "Creating symlink for neovim config"; \
42+
# ln -s "$(DOTFILES_DIR)/nvim" "$(XDG_CONFIG_DIR)/nvim"; \
43+
# else \
44+
# echo "neovim config symlink already exists"; \
45+
# fi
46+
# @echo "Installing/updating neovim plugins..."
47+
# # @nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
48+
# @nvim --headless "+Lazy! sync" +qa
49+
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ ruby 3.4.5
22
lua 5.4.7
33
python 3.13.2
44
nodejs 23.7.0
5+
java temurin-21.0.6+7.0.LTS

0 commit comments

Comments
 (0)