diff --git a/.env b/.env new file mode 100644 index 000000000..767a1bb6b --- /dev/null +++ b/.env @@ -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" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 639095139..1f9ae3c90 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -146,9 +146,24 @@ 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') }} @@ -156,43 +171,29 @@ jobs: with: python-version: "3.12" - - name: Install asdf inside WSL - if: contains(matrix.shell, '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 - direnv --version + 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 + ~/.local/bin/mise --version + echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc + + - name: Validate mise availability + # if: contains(matrix.shell, 'wsl') + run: | + set -ex + 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 @@ -205,7 +206,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 diff --git a/.tool-versions b/.tool-versions index 1c3e8b76e..30cefe811 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,4 +1,3 @@ -direnv 2.34.0 nodejs 20.18.0 # asdf install task latest task 3.37.2 diff --git a/mise.toml b/mise.toml new file mode 100644 index 000000000..d3a86d3a1 --- /dev/null +++ b/mise.toml @@ -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' diff --git a/packages/ansible-language-server/Taskfile.yml b/packages/ansible-language-server/Taskfile.yml index 5fe90bea4..ac08ee798 100644 --- a/packages/ansible-language-server/Taskfile.yml +++ b/packages/ansible-language-server/Taskfile.yml @@ -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 diff --git a/tools/test-setup.sh b/tools/test-setup.sh index b662f3c91..e2b25438c 100755 --- a/tools/test-setup.sh +++ b/tools/test-setup.sh @@ -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 || { @@ -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) @@ -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)