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 c7cdf9d
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 53 deletions.
5 changes: 5 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Command such `yarn webpack-dev` might fail with
# Reached heap limit Allocation failed - JavaScript heap out of memory
# https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes
# default 16 MiB for 64-bit systems and 8 MiB for 32-bit systems
export NODE_OPTIONS="--max-old-space-size=8192"
49 changes: 15 additions & 34 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,53 +146,34 @@ 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

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

- name: Install asdf inside WSL
if: contains(matrix.shell, 'wsl')
- name: Activate mise
run: |
set -ex
# echo "$HOME/.local/bin" >> $GITHUB_PATH
# echo "$HOME/.local/share/mise/bin" >> $GITHUB_PATH
# # echo "$HOME/.local/share/mise/shims" >> $GITHUB_PATH
eval "$(mise activate bash)" >> ~/.bashrc
- name: Validate mise availability
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
direnv --version
mise --version
task --version
yarn --version
node --version
python3 --version
mise doctor
- 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)
- name: Ensure .env file was loaded (mise)
if: ${{ !contains(matrix.shell, 'wsl') }}
run: |
set -ex
Expand All @@ -205,7 +186,7 @@ jobs:
exit 98
}
# Ensure NODE_OPTIONS config on CI is identical with the one in .envrc
[[ "${NODE_OPTIONS:-}" == "$(asdf exec direnv exec . printenv NODE_OPTIONS)" ]] || { echo "NODE_OPTIONS mismatch between .envrc and ci.yaml"; exit 97; }
[[ "${NODE_OPTIONS:-}" == "$(source .env; printenv NODE_OPTIONS)" ]] || { echo "NODE_OPTIONS mismatch between .envrc and ci.yaml"; exit 97; }
- name: Enable caching
uses: actions/cache@v4
Expand Down
1 change: 0 additions & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
direnv 2.34.0
nodejs 20.18.0
# asdf install task latest
task 3.37.2
Expand Down
15 changes: 15 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[env]
# https://mise.jdx.dev/mise-cookbook/nodejs.html#add-node-modules-binaries-to-the-path
_.path = ['./node_modules/.bin']

# 'vsa' is acronym for 'visual studio ansible'
# we use HOME location below to avoid polluting the project directory with,
# temporary data and to allow us to mount the codebase on multiple machines
# for build and testing purposes.
# export VIRTUAL_ENV="${HOME}/.local/share/virtualenvs/vsa"

# https://mise.jdx.dev/mise-cookbook/python.html
_.python.venv = { path = "~/.local/share/virtualenvs/vsa", create = true }

[settings]
env_file = '.env'
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
29 changes: 14 additions & 15 deletions tools/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,20 @@ 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)..."

VERSION_MANAGER=mise
if type mise >/dev/null; then
VERSION_MANAGER=mise
else
curl https://mise.run | sh
fi
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 +337,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 +478,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 c7cdf9d

Please sign in to comment.