Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support MacOS for golang and rust #123

Merged
merged 4 commits into from
Sep 25, 2024
Merged
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
15 changes: 0 additions & 15 deletions roles/golang/tasks/configure_Ubuntu.yml

This file was deleted.

5 changes: 5 additions & 0 deletions roles/golang/tasks/install_MacOS.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

- name: Install go with brew
homebrew:
name: go
15 changes: 13 additions & 2 deletions roles/golang/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,19 @@
install_golang_version.stdout | regex_replace('go version go(.*) .*', '\\1')
is version(GOLANG_VERSION, '<')

- name: Setup golang depends on distribution
ansible.builtin.include_tasks: configure_{{ ansible_distribution }}.yml
- name: Setup environment variable 'GOPATH'
ansible.builtin.lineinfile:
dest: "{{ ansible_user_dir }}/{{ GOLANG_SHELL_INIT_FILE }}"
regexp: "{{ item.regexp }}"
insertafter: "{{ item.insertafter }}"
line: "{{ item.line }}"
create: yes
mode: "0644"
with_items:
# yamllint disable rule:commas
- { regexp: '^export PATH="\$PATH:/usr/local/go/bin"', line: 'export PATH="$PATH:/usr/local/go/bin"', insertafter: EOF }
- { regexp: '^export GOPATH=', line: 'export GOPATH="{{ GOLANG_GOPATH }}"', insertafter: EOF }
- { regexp: '^export PATH="\$PATH:\$GOPATH/bin"', line: 'export PATH="$PATH:$GOPATH/bin"', insertafter: EOF }

- name: Install developing tools for golang
ansible.builtin.include_tasks: install_devtools.yml
Expand Down
34 changes: 16 additions & 18 deletions roles/rust/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,25 @@
ansible.builtin.command: sh /tmp/rustup.sh -y
when: cargo.rc != 0

- name: Set shell info
ansible.builtin.set_fact:
shell_info: "{{ ansible_user_shell | shell_config }}"

- name: Setup rustup path
ansible.builtin.lineinfile:
path: "{{ ansible_user_dir }}/{{ shell_info.rc_file }}"
regexp: ". \"$HOME/.cargo/env\""
line: ". \"$HOME/.cargo/env\""

# LSP for rust
- name: Check rust-analyzer already installed
ansible.builtin.command: bash -lc "which rust-analyzer"
ansible.builtin.command: bash -lc "rustup component list --installed"
changed_when: false
failed_when: false
register: rust_analyzer

- name: Download rust-analyzer
ansible.builtin.get_url:
url: https://github.com/rust-lang/rust-analyzer/releases/latest/download/rust-analyzer-x86_64-unknown-linux-gnu.gz
dest: /tmp/rust-analyzer.gz
mode: '0644'
when: rust_analyzer.rc != 0

- name: Unarchive rust-analyzer
ansible.builtin.shell: gzip -d /tmp/rust-analyzer.gz -c > ~/.local/bin/rust-analyzer
when: rust_analyzer.rc != 0
register: rustup_component

- name: Change rust-analyzer as executable
ansible.builtin.file:
path: ~/.local/bin/rust-analyzer
mode: '0775'
when: rust_analyzer.rc != 0
- name: Install rust-analyzer
ansible.builtin.command: sh -lc "rustup component add rust-analyzer"
when: rustup_component.stdout is not search('rust-analyzer')
register: result
changed_when: result.stdout is search('installing')
Loading