Skip to content

Commit

Permalink
Use mise instead of asdf if present
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Dec 24, 2024
1 parent 5ca4a7c commit 1473b0e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 46 deletions.
72 changes: 44 additions & 28 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,50 +146,66 @@ jobs:
xvfb
# asdf nodejs plugin requires: dirmngr gpg curl gawk

- name: Setup asdf
if: ${{ !contains(matrix.shell, 'wsl') }}
uses: asdf-vm/actions/install@v3
- name: Install mise
uses: jdx/mise-action@v2
# with:
# version: 2024.12.14 # [default: latest] mise version to install
# install: true # [default: true] run `mise install`
# cache: true # [default: true] cache mise using GitHub's cache
# experimental: true # [default: false] enable experimental features
# # automatically write this mise.toml file
# mise_toml: |
# [tools]
# shellcheck = "0.9.0"
# # or, if you prefer .tool-versions:
# tool_versions: |
# shellcheck 0.9.0

# - name: Setup asdf
# if: ${{ !contains(matrix.shell, 'wsl') }}
# uses: asdf-vm/actions/install@v3

- name: Setup python
if: ${{ !contains(matrix.shell, 'wsl') }}
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install asdf inside WSL
- name: Install mise inside WSL
if: contains(matrix.shell, 'wsl')
run: |
set -ex
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
export ASDF_DIR="$HOME/.asdf"
. "$HOME/.asdf/asdf.sh"
asdf plugin add direnv
asdf plugin add nodejs
asdf plugin add python
asdf plugin add task
asdf plugin add yarn
asdf install
curl https://mise.run | sh
echo "$HOME/.local/bin" >> $GITHUB_PATH
echo "$HOME/.local/share/mise/bin" >> $GITHUB_PATH
echo "$HOME/.local/share/mise/shims" >> $GITHUB_PATH
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc
- name: Validate mise availability
# if: contains(matrix.shell, 'wsl')
run: |
set -ex
mise --version
direnv --version
task --version
yarn --version
node --version
python3 --version
- name: Activate direnv
if: ${{ !contains(matrix.shell, 'wsl') }}
run: |
set -x
asdf direnv setup --shell bash --version latest
asdf current
asdf exec direnv allow
asdf exec direnv reload
# https://github.com/direnv/direnv/wiki/GitHubActions
# Github prevents export of NODE_OPTIONS to GITHUB_ENV due to security reasons:
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable
asdf exec direnv export gha >> "$GITHUB_ENV"
asdf exec direnv exec . bash -c 'echo "${VIRTUAL_ENV}/bin"' >> "$GITHUB_PATH"
# - name: Activate direnv
# if: ${{ !contains(matrix.shell, 'wsl') }}
# run: |
# set -x
# asdf direnv setup --shell bash --version latest
# asdf current
# asdf exec direnv allow
# asdf exec direnv reload

# # https://github.com/direnv/direnv/wiki/GitHubActions
# # Github prevents export of NODE_OPTIONS to GITHUB_ENV due to security reasons:
# # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable
# asdf exec direnv export gha >> "$GITHUB_ENV"
# asdf exec direnv exec . bash -c 'echo "${VIRTUAL_ENV}/bin"' >> "$GITHUB_PATH"


- name: Ensure .envrc file is automatically loaded (direnv)
Expand Down
4 changes: 1 addition & 3 deletions packages/ansible-language-server/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ tasks:
dir: "{{ .TASKFILE_DIR }}"
desc: Update dependencies
cmds:
- npm install -g npm@latest
# - installs tools from .tool-versions
- asdf install
- task: shared:setup
- "{{.VIRTUAL_ENV}}/bin/python3 -m pre_commit autoupdate"
- npm outdated
# bumps some developments dependencies
Expand Down
43 changes: 28 additions & 15 deletions tools/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,34 @@ if [[ -z "${HOSTNAME:-}" ]]; then
exit 2
fi

log notice "Install required build tools"
for PLUGIN in yarn nodejs task python direnv; do
if ! asdf plugin-list | grep -q $PLUGIN; then
asdf plugin add $PLUGIN
fi
done
asdf install
log notice "Install required build tools (mise/asdf)..."

if type mise >/dev/null; then
VERSION_MANAGER=mise
mise install
else
curl https://mise.run | sh
mise install
# VERSION_MANAGER=asdf
# log warning "mise not found, trying to use asdf instead. "

# for PLUGIN in yarn nodejs task python direnv; do
# if ! asdf plugin-list | grep -q $PLUGIN; then
# asdf plugin add $PLUGIN
# fi
# done
# asdf install

# log notice "Report current build tool versions..."
asdf current
fi
VERSION_MANAGER=mise
mise install

log notice "Report current build tool versions..."
asdf current
command -v npm >/dev/null 2>&1 || {
log error "Failed to find npm."
exit 56
}

if [[ "${OSTYPE:-}" != darwin* ]]; then
pgrep "dbus-(daemon|broker)" >/dev/null || {
Expand Down Expand Up @@ -333,11 +351,6 @@ for CMD in ansible ansible-lint; do
done
unset CMD

command -v npm >/dev/null 2>&1 || {
log notice "Installing nodejs stable."
asdf install
}

if [[ -f yarn.lock ]]; then
command -v yarn >/dev/null 2>&1 || {
# Check if npm has permissions to install packages (system installed does not)
Expand Down Expand Up @@ -479,7 +492,7 @@ env:
tools:
ansible-lint: $(get_version ansible-lint)
ansible: $(get_version ansible)
asdf: $(get_version asdf)
$VERSION_MANAGER: $(get_version $VERSION_MANAGER)
bash: $(get_version bash)
gh: $(get_version gh || echo null)
git: $(get_version git)
Expand Down

0 comments on commit 1473b0e

Please sign in to comment.