Skip to content

Commit

Permalink
feat(zsh): Resolve issues with ZSH + runner
Browse files Browse the repository at this point in the history
  • Loading branch information
sylus committed Feb 24, 2024
1 parent 8d85afa commit 60ea4fc
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 21 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ jobs:
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new

- name: Run Tests amd64
run: docker run --rm --platform amd64 localhost:5000/${{ matrix.os }}:latest /home/devcontainer/.local/bin/check-dotfiles

- name: Run Tests arm64
run: docker run --rm --platform arm64 localhost:5000/${{ matrix.os }}:latest /home/devcontainer/.local/bin/check-dotfiles
run: docker run --rm --platform amd64 localhost:5000/${{ matrix.os }}:latest /bin/zsh -c 'source /home/devcontainer/.zshenv && /home/devcontainer/.local/bin/check-dotfiles'

- name: Generate Image Metadata
id: metadata
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/github.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,16 @@ jobs:
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: ./install.sh

- name: Run tests
run: ~/.local/bin/check-dotfiles
- name: Switch to ZSH
if: runner.os == 'Linux'
shell: /home/linuxbrew/.linuxbrew/bin/zsh {0}
run: |
source ~/.zshenv
~/.local/bin/check-dotfiles
- name: Switch to ZSH
if: runner.os == 'macOS'
shell: /usr/local/bin/zsh {0}
run: |
source ~/.zshenv
~/.local/bin/check-dotfiles
1 change: 1 addition & 0 deletions containers/debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN set -eux \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
apt-transport-https \
bash \
build-essential \
ca-certificates \
curl \
dialog \
Expand Down
1 change: 1 addition & 0 deletions containers/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN set -eux \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
apt-transport-https \
bash \
build-essential \
ca-certificates \
curl \
dialog \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
#!/usr/bin/env bash

# Install XCode
xcode-select -p >/dev/null 2>&1 || xcode-select --install

{{- if .host.headless }}
# Install Visual Studio Code
curl -fsSL -o vscode.zip https://code.visualstudio.com/sha/download?build=stable\&os=darwin-universal
unzip -q vscode.zip
rm vscode.zip
mv "Visual Studio Code.app" /Applications/
ln -s "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code
{{- end }}

if ! command -v brew >/dev/null 2>&1; then
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi

{{ if eq .host.arch "arm64" -}}
{{- if eq .host.arch "arm64" }}
eval $(/opt/homebrew/bin/brew shellenv)
{{- else }}
eval $(/usr/local/bin/brew shellenv)
Expand All @@ -17,6 +27,7 @@ brew update

# Temporary Overrides
brew install --overwrite [email protected]
brew install --overwrite [email protected]
brew install --overwrite go

brew bundle --verbose --no-lock --file=/dev/stdin <<EOF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if ! command -v brew >/dev/null 2>&1; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi

{{ if eq .host.arch "arm64" -}}
{{- if eq .host.arch "arm64" }}
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
{{- else }}
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if ! command -v brew >/dev/null 2>&1; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi

{{ if eq .host.arch "arm64" -}}
{{- if eq .host.arch "arm64" }}
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
{{- else }}
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
Expand Down
2 changes: 2 additions & 0 deletions home/.chezmoitemplates/universal/packages
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{- $packages := list
"ack"
"age"
"awk"
"bash"
"bat"
"cmake"
Expand Down Expand Up @@ -30,6 +31,7 @@
"watch"
"wget"
"zplug"
"zsh"
"zsh-autosuggestions"
"zsh-syntax-highlighting"
-}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,6 @@ setup() {
assert_success
}

{{ if eq .host.distro.family "darwin" }}
@test "mas" {
run mas
assert_success
}
{{ end }}

{{ if .toolchains.docker }}
@test "docker" {
run docker --help
Expand Down
3 changes: 2 additions & 1 deletion home/dot_zshenv
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export ZDOTDIR=$HOME/.config/zsh/
ZDOTDIR=$HOME/.config/zsh/
source -- "$ZDOTDIR"/.zshrc
4 changes: 4 additions & 0 deletions home/private_dot_config/shell/dot_bash_exports.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,19 @@ export ZSH_EVALCACHE_DIR="$XDG_CACHE_HOME/zsh-evalcache"

# GPG
# https://stackoverflow.com/a/42265848/96656
{{- if not .host.headless }}
export GPG_TTY=$(tty);
{{- end }}

# Hyper
{{- if eq .host.distro.family "darwin" }}
{{- if not .host.headless }}
launchctl setenv XDG_CONFIG_HOME "$XDG_CONFIG_HOME"
launchctl setenv XDG_DATA_HOME "$XDG_DATA_HOME"
launchctl setenv XDG_CACHE_HOME "$XDG_CACHE_HOME"
launchctl setenv PATH "$PATH"
{{- end }}
{{- end }}

# NodeJS
export NODE_REPL_HISTORY_SIZE='32768';
Expand Down
13 changes: 9 additions & 4 deletions home/private_dot_config/zsh/dot_zshrc.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@

export HOMEBREW_NO_AUTO_UPDATE=1

{{ if eq .chezmoi.os "linux" -}}
{{- if eq .chezmoi.os "linux" }}
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
{{- end }}

{{ if eq .chezmoi.os "darwin" -}}
{{- if eq .chezmoi.os "darwin" }}
{{- if eq .host.arch "arm64" }}
eval "$(/opt/homebrew/bin/brew shellenv)"
{{- else }}
eval "$(/usr/local/bin/brew shellenv)"
{{- end }}
{{- end }}

# Powerlevel10k Configuration
Expand Down Expand Up @@ -131,14 +135,13 @@ setopt rm_star_silent
# -----------------------------------------------------------------------------

export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"

# Python Configuration
# -----------------------------------------------------------------------------

ln -sf "$(brew --prefix)/bin/python"{3,}


# Includes
# -----------------------------------------------------------------------------

Expand All @@ -157,6 +160,7 @@ if [ -f "$HOME"/.config/shell/.bash_functions ]; then
\. "$HOME"/.config/shell/.bash_functions
fi

{{- if eq .chezmoi.os "linux" }}
{{- if .toolchains.kubernetes }}
# Load cross-compatible Kubernetes alias definitions from separate file.
if [ -f "$HOME"/.config/kubernetes/.kube_aliases ]; then
Expand All @@ -168,3 +172,4 @@ if [ -f "$HOME"/.config/kubernetes/.kube_functions ]; then
\. "$HOME"/.config/kubernetes/.kube_functions
fi
{{- end }}
{{- end }}

0 comments on commit 60ea4fc

Please sign in to comment.