Compare commits

...

2 Commits

Author SHA1 Message Date
Andrei Jiroh Halili 860b98aab2
Overhaul bootstrap script to add support for GitHub Codespaces
We might also add support for Gitpod very soon, but for now, there's
an envvar override for dotfiles home which is currently not yet implemented
on shell rc files yet. Also in this commit, we're in the progress of deprecating
dotfiles-secrets in favor of PasswordStore secret storage backed by GPG.

Signed-off-by: Andrei Jiroh Eugenio Halili <ajhalili2006@gmail.com>
2022-06-11 19:50:21 +08:00
Andrei Jiroh Halili ddbae29707
Add tests to the bootstrap script for Ubuntu in GHA first
Also some chores on my custom Ubuntu container image for the tests.

Signed-off-by: Andrei Jiroh Eugenio Halili <ajhalili2006@gmail.com>
2022-06-11 19:30:33 +08:00
3 changed files with 61 additions and 5 deletions

View File

@ -0,0 +1,27 @@
name: Bootstrap Script CI
on:
push:
workflow_dispatch:
jobs:
ubuntu-gha:
name: Ubuntu 22.04 - GitHub Actions VM
runs-on: ubuntu-22.04
steps:
- run: curl -fsSL https://github.com/ajhalili2006/dotfiles/raw/main/bootstrap | bash -
env:
STORJ_ACCESS_GRANT: ${{secrets.STORJ_ACCESS_GRANT}}
ubuntu-docker:
name: Ubuntu 22.04 - Docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: DOCKER_BUILDKIT=1 docker build -f tests/ubuntu/Dockerfile -t ajhalili2006/dotfiles-testing-rig tests
- run: docker run --rm --volume $PWD/exec-log.txt:/var/tests/exec-log.txt -u 1000 -e STORJ_ACCESS_GRANT ajhalili2006/dotfiles-testing-rig "curl -fsSL https://github.com/ajhalili2006/dotfiles/raw/main/bootstrap | bash -"
env:
STORJ_ACCESS_GRANT: ${{secrets.STORJ_ACCESS_GRANT}}
USE_PYENV: "1"
USE_NVM: "1"
#FF_LEGACY_DOTFILES_SECRETS_REPO: "1"
#FF_SETUP_HOMEBREW: "1"

View File

@ -8,7 +8,9 @@
# if undefined, use $HOME/.local
if [[ $PREFIX == "" ]]; then
export PREFIX="$HOME/.local"
[[ ! -d "$PREFIX/bin" ]] && mkdir "$PREFIX/bin" -p
if [[ ! -d "$PREFIX/bin" ]]; then
mkdir "$PREFIX/bin" -p
fi
fi
# Check if we're on Gitpod OR GitHub Codespaces before running the main script
@ -95,8 +97,12 @@ setupSysPkgs() {
setupGLabCli
elif [[ $DOTFILES_OS_NAME == "debian" ]] && [[ $SKIP_DEPENDENCY_INSTALL == "" ]]; then
sudo apt install gnupg git nano pass openssh-client -y
setupGhCli
setupGLabCli
elif [[ $DOTFILES_OS_NAME == "ubuntu" ]] && [[ $SKIP_DEPENDENCY_INSTALL == "" ]]; then
sudo apt install gnupg nano pass openssh-client -y
setupGhCli
setupGLabCli
else
warn "Dependency installs are being skipped"
fi
@ -206,8 +212,16 @@ cloneSecretsRepo() {
sleep 5
}
# TODO: Check whenever Linuxbrew is installed and use local Homebrew install instead when detected.
# TODO: If installed using this script via FF_SETUP_HOMEBREW environment variable, defaults to
# TODO: /home/linuxbrew/.nrew as per my bashrc and zshrc files.
# Install GitHub CLI if we're gonna use that GitHub mirror
setupGhCli() {
if command -v gh >>/dev/null; then
info "GitHub CLI installed for this environment, skipping system package manager setup"
return
fi
if [[ $DOTFILES_OS_NAME == "android-termux" ]]; then
pkg install gh # TODO: check Linux install docs in cli/cli
elif [[ $DOTFILES_OS_NAME == "debian" || $DOTFILES_OS_NAME == "ubuntu" ]] && ! command -v gh >> /dev/null; then
@ -216,6 +230,21 @@ setupGhCli() {
sudo apt update && sudo apt install gh
fi
}
# Also setup GLab CLI too
setupGLabCli() {
if command -v glab >>/dev/null; then
info "GLab CLI installed for this environment, skipping running scripts from Git repo rawfile/Termux pkgrepo"
return
fi
if [[ "$DOTFILES_OS_NAME" == "android-termux" ]]; then
warn "GLab CLI is currently unavailable on Termux package repos yet."
return
#pkg install glab
else
curl -fsSL https://raw.githubusercontent.com/profclems/glab/trunk/scripts/install.sh | sh - "$PREFIX"
fi
}
cleanup() {
echoStageName "Bootstrapper successfully ran, cleaning up to ensure no secrets are leaked on env vars..."
@ -251,7 +280,7 @@ setupSshConfig() {
copyBashrc() {
if [[ $DOTFILES_OS_NAME == "android-termux" ]]; then
ln -s $HOME/.dotfiles/termux.bashrc ~/.bashrc
elif [[ $DOTFILES_OS_NAME == "debian-ubuntu" ]]; then
elif [[ $DOTFILES_OS_NAME == "debian" ]] || [[ $DOTFILES_OS_NAME == "ubuntu" ]]; then
if [[ $SKIP_CONFIG_LINKING == "" ]] && [ ! -f "$HOME/.bashrc" ]; then
ln -s "$HOME/.dotfiles/ubuntu.bashrc" ~/.bashrc
elif [[ $GOOGLE_CLOUD_SHELL == "true" ]] && [[ $SKIP_CONFIG_LINKING == "" ]] && [ -f "$HOME/.bashrc" ]; then
@ -276,7 +305,7 @@ copyGitConfig() {
# TODO: Write checks if it's Ubuntu or Debian
# See https://superuser.com/a/741610/1124908 for details
# By default, we'll use the one-size-fits-all Linux config for Git
elif [[ $DOTFILES_OS_NAME == "debian-ubuntu" ]] && [[ $SKIP_CONFIG_LINKING == "" ]]; then
elif echo $OSTYPE | grep -qE '^linux-gnu.*' && [[ $SKIP_CONFIG_LINKING == "" ]]; then
[ ! -L "$HOME/.gitconfig" ] && ln -s "$HOME/.dotfiles/gitconfig/linux" "$HOME/.gitconfig" || warn "Git configuration on userspace found, either symlink is broken or customizations had been made. Please fix any conflicts or soft link them manually!"
fi
}

View File

@ -10,8 +10,8 @@ USER root
ARG DOCKER_UID=1000
# Copy our scripts to their destinations
COPY ../common/bin/logger.sh /usr/bin/entrypoint.sh
COPY ./bin/install-packages /usr/bin/install-packages
COPY common/bin/logger.sh /usr/bin/entrypoint.sh
COPY ubuntu/bin/install-packages /usr/bin/install-packages
# Install deps in noninteractive mode.
ARG DEBIAN_FRONTEND=noninteractive