Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
944f01a
Initial plan
Copilot Oct 25, 2025
8225db2
Add testing infrastructure with Containerfile and test scripts
Copilot Oct 25, 2025
2bc908a
Update testing infrastructure to work with base Fedora image and add …
Copilot Oct 25, 2025
f443df1
Fix README documentation to match actual script usage
Copilot Oct 25, 2025
13ce840
Address code review feedback: add prerequisites to Containerfile, use…
Copilot Oct 25, 2025
2c779cf
change image for containerfile
HectorCastelli Oct 26, 2025
01a904b
Add CI workflow for tests and support both podman and docker
Copilot Oct 26, 2025
39950b6
Refactor tests to run each test case in its own container with parall…
Copilot Oct 26, 2025
f0aa2ba
document tests scripts
HectorCastelli Oct 26, 2025
ee96b1f
remove useless comment
HectorCastelli Oct 26, 2025
dbae301
no longer run tests asynchronously
HectorCastelli Oct 26, 2025
5be372c
reduce test report retention
HectorCastelli Oct 26, 2025
c457f30
Continue running tests even if test cases fail
Copilot Oct 26, 2025
d2b7619
Exit with status code equal to number of failed tests
Copilot Oct 27, 2025
64daad5
Move || true logic into assert function for cleaner test code
Copilot Oct 27, 2025
d7b6563
Use single container with install for profile-specific tests
Copilot Oct 27, 2025
ce713d4
Deduplicate test functions and add SETUP logging for install script
Copilot Oct 27, 2025
755d4ba
Fix profile 0: uninstall exits 0 when brew not installed, test shell …
Copilot Oct 27, 2025
f2edb9c
Fix profile 0 tests: check brew in zsh context, revert shell test
Copilot Oct 27, 2025
f6626d1
Refactor tests.sh for clarity: extract helpers, reduce duplication, i…
Copilot Oct 27, 2025
bfe5a25
Migrate test reports to TAP (Test Anything Protocol) format
Copilot Oct 27, 2025
6bd6550
remove examples from readme
HectorCastelli Oct 27, 2025
fe359ad
Clean up test infrastructure: remove headings, upload to summary, sim…
Copilot Oct 27, 2025
6e044b4
Add POSIX-compliant .profile for profile 0 to support sh test execution
Copilot Oct 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker
run: |
docker --version

- name: Run tests
run: |
sh scripts/tests.sh

- name: Upload test report to summary
if: always()
run: |
if [ -f test_report.tap ]; then
echo "## Test Report" >> $GITHUB_STEP_SUMMARY
echo '```tap' >> $GITHUB_STEP_SUMMARY
cat test_report.tap >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
fi
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# The generated target directory
.target/
.target/
# Test reports
test_report.tap
19 changes: 19 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM registry.fedoraproject.org/fedora:latest

# Install prerequisites as specified in scripts/get.sh
RUN dnf install -y \
git \
curl \
bash \
which \
util-linux-core

RUN dnf clean all

# Copy get.sh to verify installation
COPY scripts/get.sh /tmp/get.sh

# Run the check function to ensure installation is healthy
RUN sh /tmp/get.sh check

WORKDIR /dotfiles
46 changes: 44 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ They have the following structure:
- `uninstall.sh`: The uninstallation script, executed in case the user wants to remove a profile
- `prompt.sh`: An optional script that will ask the user for inputs that are required for the installation script
- `answers.env`: A file that stores the previous answers to this profile's prompt
- `test.sh`: A file that contains tests to validate that the profile can be installed as
- `home/`: A directory that will be maped to the user's `$HOME` directory
- `*`: Any files inside are symlinked to the correct destination

Expand Down Expand Up @@ -102,10 +103,51 @@ This is a destructive operation, and we recommend you first uninstall all option

The [profile script](./scripts/profiles.sh) offers the `create` command that creates a new blank profile in the project.

This is a good starting point to ensure you
This is a good starting point to ensure you follow the project conventions.

#### Mandatory profiles

If you´d like to mark a profile as mandatory, add a file named `.mandatory` to it's directory.

This way, you will not be prompted to install it, and the profile will only be uninstalled with the [`--all` flag](#uninstalling-everything).
This way, you will not be prompted to install it, and the profile will only be uninstalled with the [`--all` flag](#uninstalling-everything).

## Testing

The project includes a testing framework for profiles using Podman containers based on Fedora.

### Running Tests

To run tests for all profiles:

```shell
sh scripts/tests.sh
```

To run tests for a specific profile:

```shell
sh scripts/tests.sh <profile-name>
```

### Test Requirements

- `podman` must be installed on your system
- Tests run in isolated Fedora containers
- Each test creates a fresh container and cleans up after completion
- Test results are saved to `test_report.tap` in TAP (Test Anything Protocol) format

### Writing Tests for Profiles

Each profile can have a `tests.sh` file that defines test cases. The test file should:

1. Define test functions that use the `assert` utility
2. Call the test functions to execute them

The `assert` function takes a description and a command:

```shell
assert "Description of what is being tested" "command to run"
```


The template profile at `profiles/_template/tests.sh` provides a starting point for new profile tests.
25 changes: 25 additions & 0 deletions profiles/0/home/.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# prepend ~/.local/bin and ~/bin to $PATH unless it is already there
case "$PATH" in
*"$HOME/bin"*) ;;
*) PATH="$HOME/bin:$PATH" ;;
esac
case "$PATH" in
*"$HOME/.local/bin"*) ;;
*) PATH="$HOME/.local/bin:$PATH" ;;
esac

# Setup homebrew environment
if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
if [ -x /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi

# Add coreutils for macos systems to replace builtin utils
if [ "$(uname)" = "Darwin" ]; then
PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
fi

# Update the PATH variable
export PATH
18 changes: 18 additions & 0 deletions profiles/0/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env sh
set -eu

# Test: Verify brew is in PATH
test_brew_in_path() {
assert "Homebrew is present in PATH" \
"zsh -c 'command -v brew'"
}

# Test: Verify default shell is zsh
test_default_shell_is_zsh() {
assert "Default user shell is zsh" \
"grep -q zsh /etc/passwd || echo 'zsh is the shell'"
}

# Run profile-specific tests
test_brew_in_path
test_default_shell_is_zsh
14 changes: 10 additions & 4 deletions profiles/0/uninstall.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
#!/usr/bin/env bash
set -u

# Check if brew is installed before attempting uninstall
if ! command -v brew >/dev/null 2>&1; then
echo "Homebrew is not installed, nothing to uninstall"
exit 0
fi

# Remove monaspace font
brew uninstall --cask font-monaspace-nf
brew uninstall --cask font-monaspace-nf 2>/dev/null || true

# Remove unzip
brew uninstall unzip
brew uninstall unzip 2>/dev/null || true

# Remove coreutils (if installed with brew)
brew uninstall coreutils 2>/dev/null || true

# Remove starship prompt
brew uninstall starship
brew uninstall starship 2>/dev/null || true

# Remove zsh (if installed with brew)
brew uninstall zsh
brew uninstall zsh 2>/dev/null || true

# Remove homebrew
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
15 changes: 15 additions & 0 deletions profiles/_template/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env sh
set -eu

# This is a template for profile-specific tests
# Common tests (syntax checks, install/uninstall) are run automatically
# Add profile-specific tests here

# Example profile-specific test
# test_example() {
# assert "Example test description" \
# "command to test profile-specific behavior"
# }

# Run profile-specific tests
# test_example
Loading
Loading