diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5b806f1..7db0e74 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,15 +1,39 @@ --- -name: Code quality +name: CI on: push: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + jobs: - lint-ansible: - name: Ansible Lint - runs-on: ubuntu-latest + integration: + name: Integration + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - macos-12 + steps: - uses: actions/checkout@v3 - - name: Set up Ansible - uses: ansible-community/ansible-lint-action@main + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + cache: 'pip' + - run: pip install -r requirements.txt + + - name: Set up the test environment. + run: | + cp tests/ansible.cfg ./ansible.cfg + ansible-galaxy install -r requirements.yaml + + - name: Test the playbook's syntax. + run: ansible-playbook macOS.yaml --syntax-check + + - name: Test the playbook. + run: ansible-playbook macOS.yaml + env: + ANSIBLE_FORCE_COLOR: '1' diff --git a/ansible.cfg b/ansible.cfg index 201d698..1c990b6 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,5 +1,9 @@ [defaults] +nocows = True +roles_path = ./roles:/etc/ansible/roles inventory = inventory.ini +stdout_callback = yaml +bin_ansible_callbacks = True [diff] always = true diff --git a/dotfiles/roles/asdf/tasks/main.yaml b/dotfiles/roles/asdf/tasks/main.yaml index 6078e85..7acb775 100644 --- a/dotfiles/roles/asdf/tasks/main.yaml +++ b/dotfiles/roles/asdf/tasks/main.yaml @@ -5,7 +5,7 @@ failed_when: - asdf_add_golang.rc != 0 - '"already added" not in asdf_add_golang.stderr' - ansible.builtin.command: 'asdf plugin add golang' + ansible.builtin.command: 'asdf plugin add golang https://github.com/kennyp/asdf-golang.git' - name: asdf - Install latest Go version register: asdf_golang_installed diff --git a/dotfiles/roles/git/files/.gitconfig b/dotfiles/roles/git/files/.gitconfig index 177b868..6bae20e 100644 --- a/dotfiles/roles/git/files/.gitconfig +++ b/dotfiles/roles/git/files/.gitconfig @@ -1,3 +1,5 @@ +[color] + ui = auto [user] name = James Brookes email = jpebrookes@gmail.com diff --git a/dotfiles/roles/git/tasks/main.yaml b/dotfiles/roles/git/tasks/main.yaml index 4a84ff1..60290bf 100644 --- a/dotfiles/roles/git/tasks/main.yaml +++ b/dotfiles/roles/git/tasks/main.yaml @@ -1,6 +1,7 @@ --- - name: Git - Ensure Git is installed become: true + when: ansible_os_family == 'Debian' ansible.builtin.package: name: git state: present @@ -9,5 +10,5 @@ ansible.builtin.copy: src: .gitconfig dest: "{{ ansible_user_dir }}/.gitconfig" - mode: '0644' + mode: "0644" force: false diff --git a/dotfiles/roles/zsh/files/.zshrc b/dotfiles/roles/zsh/files/.zshrc index 16e004b..42de3cd 100644 --- a/dotfiles/roles/zsh/files/.zshrc +++ b/dotfiles/roles/zsh/files/.zshrc @@ -1,14 +1,8 @@ -# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. -# Initialization code that may require console input (password prompts, [y/n] -# confirmations, etc.) must go above this block; everything else may go below. -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" -fi - zstyle :omz:plugins:ssh-agent identities id_ed25519 export GOPATH=$HOME/go -export PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/go/bin:$GOPATH/bin:/opt/homebrew/bin +export PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/go/bin:$GOPATH/bin +export EDITOR="nano" # Path to your oh-my-zsh installation. export ZSH="$HOME/.oh-my-zsh" @@ -17,7 +11,7 @@ export ZSH="$HOME/.oh-my-zsh" # load a random theme each time oh-my-zsh is loaded, in which case, # to know which specific one was loaded, run: echo $RANDOM_THEME # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes -ZSH_THEME="powerlevel10k/powerlevel10k" +# ZSH_THEME="powerlevel10k/powerlevel10k" # Set list of themes to pick from when loading at random # Setting this variable when ZSH_THEME=random will cause zsh to load @@ -79,7 +73,7 @@ ENABLE_CORRECTION="true" # Custom plugins may be added to $ZSH_CUSTOM/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) # Add wisely, as too many plugins slow down shell startup. -plugins=(git zsh-autosuggestions dirhistory sudo ssh-agent direnv asdf copyfile golang colored-man-pages) +plugins=(asdf colored-man-pages command-not-found copyfile direnv dirhistory docker git golang ssh-agent sudo zsh-autosuggestions) source $ZSH/oh-my-zsh.sh @@ -114,5 +108,4 @@ alias la="exa -la --icons" alias lsa="exa -la --icons" alias lsd='exa -aD' -# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. -[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh +eval $(starship init zsh) diff --git a/dotfiles/roles/zsh/tasks/main.yaml b/dotfiles/roles/zsh/tasks/main.yaml index 7fe9d1e..a03dd3a 100644 --- a/dotfiles/roles/zsh/tasks/main.yaml +++ b/dotfiles/roles/zsh/tasks/main.yaml @@ -14,5 +14,8 @@ name: "{{ ansible_user_id }}" shell: /bin/zsh -- import_tasks: tasks/oh-my-zsh.yaml -- import_tasks: tasks/powerlevel10k.yaml +- ansible.builtin.import_tasks: tasks/oh-my-zsh.yaml + +- name: Setup powerlevel10k on Ubuntu + ansible.builtin.import_tasks: tasks/powerlevel10k.yaml + when: ansible_os_family == 'Debian' diff --git a/macOS.yaml b/macOS.yaml index c0c472f..55178cf 100644 --- a/macOS.yaml +++ b/macOS.yaml @@ -6,6 +6,7 @@ homebrew_installed_packages: - coreutils - zsh + - starship - ssh-copy-id - git - pv @@ -14,8 +15,13 @@ - tmux - watch - cowsay + - tldr + - direnv + - exa + - bat + - fzf + - nano - asdf - - openjdk - kubectl - helm @@ -36,6 +42,7 @@ - keepingyouawake - visual-studio-code - docker + - font-fira-code-nerd-font - font-anonymice-nerd-font - insomnia - bitwarden @@ -52,3 +59,4 @@ - role: geerlingguy.mac.homebrew - role: jamesbrookes.dotfiles.zsh - role: jamesbrookes.dotfiles.asdf + - role: jamesbrookes.dotfiles.git diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..90d4055 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +ansible diff --git a/tests/ansible.cfg b/tests/ansible.cfg new file mode 100644 index 0000000..1da4684 --- /dev/null +++ b/tests/ansible.cfg @@ -0,0 +1,2 @@ +[defaults] +inventory = inventory.ini