Skip to content

Commit

Permalink
Try Github actions for bootstrap test
Browse files Browse the repository at this point in the history
  • Loading branch information
primeapple committed Nov 26, 2023
1 parent 60053ec commit 3f41e0c
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .config/yadm/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ echo "Init all submodules"
cd "$HOME"
yadm submodule update --recursive --init --rebase

### hide README and LICENSE ###
### hide README and LICENSE and workflow files ###
yadm gitconfig core.sparseCheckout true
yadm sparse-checkout set '/*' '!README.md' '!LICENSE'
yadm sparse-checkout set '/*' '!README.md' '!LICENSE' '.github'

### change https to git repo url ###
echo "Updating the yadm repo origin URL"
Expand Down
2 changes: 1 addition & 1 deletion .config/yadm/bootstrap.d/fish
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end

# adding nice fish greeting
fish -c "set -U fish_greeting 'Welcome to fish 🐟'"
fish -C "set -U fish_features qmark-noglob"
fish -c "set -U fish_features qmark-noglob"
fish -c "fish_config theme save kanagawa"

# TODO: this does not work yet, it sometimes adds weird filenames to the fish_plugins file
Expand Down
13 changes: 13 additions & 0 deletions .github/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM archlinux:base

RUN pacman -Syu --noconfirm \
&& pacman -S --noconfirm fish yadm

RUN useradd --create-home --shell /bin/bash primeapple

WORKDIR /home/primeapple
COPY yadm-test.sh yadm-test.sh
RUN chmod +x yadm-test.sh && chown primeapple:primeapple yadm-test.sh

USER primeapple
CMD ./yadm-test.sh
18 changes: 18 additions & 0 deletions .github/workflows/yadm-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Yadm Test

on:
push:

jobs:
yadm-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Build Docker image
run: docker build -f .github/Dockerfile -t arch-yadm .github/

- name: Run yadm-test script
run: docker run --rm arch-yadm
66 changes: 66 additions & 0 deletions .github/yadm-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
echo "## TEST: Cloning the dotfiles via YADM ##"
yadm clone --no-bootstrap https://github.com/primeapple/dotfiles
echo '## DONE'

###############################################################################

echo "## TEST: Checking if required directories and files exist"
directories=(".config/nvim" ".config/fish")
files=(".profile" ".vimrc")

for dir in "${directories[@]}"; do
if [ ! -d "$dir" ]; then
echo "Error: Directory $dir does not exist."
exit 1
fi
done

for file in "${files[@]}"; do
if [ ! -f "$file" ]; then
echo "Error: File $file does not exist."
exit 1
fi
done
echo '## DONE'

###############################################################################

echo "##TEST: Executing bootstrap"
yadm bootstrap
echo '## DONE'

###############################################################################

echo "##TEST: README.md and LICENSE and .github/ should not be checked out"
if [ -f "README.md" ]; then
echo "Error: README.md should not be checked out."
exit 1
fi

if [ -f "LICENSE" ]; then
echo "Error: LICENSE should not be checked out."
exit 1
fi

if [ -d ".github" ]; then
echo "Error: .github/ should not be checked out."
exit 1
fi
echo '## DONE'

###############################################################################

echo "##TEST: fish is the default shell"
if [ "$(basename "$SHELL")" != "fish" ]; then
echo "Error: fish is not the default shell."
exit 1
fi
echo '## DONE'

###############################################################################

echo "##TEST: fisher is installed"
if ! fish -c "fisher --version" >/dev/null 2>&1; then
echo "Error: fisher is not installed."
exit 1
fi

0 comments on commit 3f41e0c

Please sign in to comment.