Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Integration Test dotfile

on:
push:
branches: '**/**'

jobs:
test:
runs-on: ubuntu-latest

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

- name: Cache Docker image layers
uses: actions/cache@v2
with:
path: /var/lib/docker
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }}

- name: Build Docker and Execute Tests
run: docker compose up --exit-code-from os-deps-test --build
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ARG base_image

FROM ${base_image} as base
RUN \
apt-get update && \
apt-get -y install sudo && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

COPY . .

FROM base
RUN bash deps/install || true # Ignore if it fails.
39 changes: 39 additions & 0 deletions deps/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

function update {
[ -x "$(command -v apt)" ] && sudo apt update
[ -x "$(command -v yum)" ] && sudo yum update
[ -x "$(command -v brew)" ] && brew update
}

function install {
success=()
errors=()
for program in "$@"; do
if ! [ -x "$(command -v $program)" ]; then
[ -x "$(command -v pacman)" ] && sudo pacman --noconfirm -S $program
[ -x "$(command -v apt)" ] && sudo apt install -y $program
[ -x "$(command -v yum)" ] && sudo yum install -y $program
[ -x "$(command -v brew)" ] && brew install $program
errors+=($program)
else
success+=($program)
fi
done

for program in ${success[@]}; do
echo -e "The $program is installed."
done

for program in ${errors[@]}; do
echo -e "\033[31mError: $program is not installed. \033[0m"
done

if [ ${#errors[@]} -gt 0 ]; then
exit 1
fi
}

update

install $(cat deps/list)
13 changes: 13 additions & 0 deletions deps/list
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
autojump
curl
fzf
gawk
git
jq
npm
ripgrep
taskwarrior
tmux
vim
zsh
stow
9 changes: 9 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3.6'

services:
os-deps-test:
build:
context: .
args:
base_image: ubuntu:latest
entrypoint: bash ./tests/os-dependencies.bash
30 changes: 3 additions & 27 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
#!/bin/bash
cd $HOME

function install {
for program in "$@"
do
if ! [ -x "$(command -v $program)" ]; then
echo "Error: $program is not installed."
[ -x "$(command -v pacman)" ] && sudo pacman --noconfirm -S $program
[ -x "$(command -v apt)" ] && sudo apt install -y $program
[ -x "$(command -v yum)" ] && sudo yum install -y $program
[ -x "$(command -v brew)" ] && brew install $program
fi
done
}
bash deps/install

cd $HOME

function createLink {
rm -rf $2
Expand All @@ -27,20 +17,6 @@ function createLink {
esac
}

install \
autojump \
curl \
fzf \
gawk \
git \
jq \
npm \
ripgrep \
taskwarrior \
tmux \
vim \
zsh

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Expand Down
8 changes: 8 additions & 0 deletions tests/os-dependencies.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
while read package; do
if ! dpkg -s "$package" >/dev/null 2>&1; then
result=1
echo "'$package' package not found"
fi
done <./deps/list
exit $result