Skip to content

[DRAFT] Switch windows runner #4937

[DRAFT] Switch windows runner

[DRAFT] Switch windows runner #4937

Workflow file for this run

# This is a basic workflow
name: ci
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
push:
branches: ["main", "devel/*"]
tags:
- "v*.*"
pull_request:
branches: ["main", "devel/*"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.ref }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
env:
FORCE_COLOR: "1" # make mocha output colorful
PRETTIER_LEGACY_CLI: "1" # https://github.com/prettier/prettier/issues/15832
# https://docs.github.com/en/actions/learn-github-actions/environment-variables
# https://devblogs.microsoft.com/commandline/share-environment-vars-between-wsl-and-windows/
WSLENV: HOSTNAME:CI:FORCE_COLOR:GITHUB_ACTION:GITHUB_ACTION_PATH/p:GITHUB_ACTION_REPOSITORY:GITHUB_WORKFLOW:GITHUB_WORKSPACE/p:GITHUB_PATH/p:GITHUB_ENV/p:VIRTUAL_ENV/p:SKIP_PODMAN:SKIP_DOCKER
# We define a hostname because otherwise the variable might not always be accessible on runners.
HOSTNAME: gha
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
name: ${{ matrix.name }}
environment: ci
env:
SKIP_DOCKER: ${{ matrix.env.SKIP_DOCKER || 0 }}
SKIP_PODMAN: ${{ matrix.env.SKIP_PODMAN || 0 }}
TASKFILE_ARGS: --output=group --output-group-begin='::group::{{.TASK}}' --output-group-end='::endgroup::'
# For using the mock Lightspeed server.
TEST_LIGHTSPEED_ACCESS_TOKEN: "dummy"
# The mock server runs on localhost. However, just using "localhost" as the hostname causes a few issues in
# GitHub Actions environment:
#
# On Linux: When "localhost" is used as the hostname, the mock server uses the ipv6 loopback address [::1] . However,
# the axios library, which is used in the extension tries to access to the ipv4 loopback 127.0.0.1 when "localhost"
# is specified and the axios library does not support URLs that contains ipv6 addresses, e.g. http://[::1]:3000.
# Also, If 127.0.0.1 is specified for the mock server, the server fails to start. Those issues are resolved by
# using the special ipv6-only hostname "ip6-localhost", which is available in GitHub Actions Linux environment.
#
# On MacOS: The hostname "ip6-localhost" is not available. However, 127.0.0.1 can be used for starting the mock
# server on MacOS and the axios library can connect to that address. So we can use 127.0.0.1 for MacOS.
#
# Once the axios library starts supporting URLs that contain ipv6 addresses, we will be able to use
# http://[::1]:3000 both on Linux and MacOS to get rid of the following conditional statement.
TEST_LIGHTSPEED_URL: "${{ contains(matrix.name, 'macos') && 'http://127.0.0.1:3000' || 'http://ip6-localhost:3000' }}"
# Set environment variables using matrix properties.
# For using an actual Lightspeed server instance, uncomment following two lines.
# TEST_LIGHTSPEED_ACCESS_TOKEN: ${{ secrets.TEST_LIGHTSPEED_ACCESS_TOKEN }}
# TEST_LIGHTSPEED_URL: ${{ secrets.TEST_LIGHTSPEED_URL }}
defaults:
run:
shell: ${{ matrix.shell || 'bash'}}
# The type of runner that the job will run on
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
# see https://github.com/containers/podman/issues/13609
continue-on-error: ${{ contains(matrix.name, 'macos') && true || false }}
outputs:
can_release_to_npm: ${{ steps.package.outputs.can_release_to_npm }}
strategy:
fail-fast: false
matrix:
# Avoid letting github do the matrix multiplication and use manual
# includes for each job, this gives us fine control over job name.
# Order is important, keep it alphabetical: docs, lint, test*
continue-on-error:
- false
os:
- ubuntu-22.04
task-name:
- docs
name:
- docs
include:
- name: lint
task-name: lint
os: ubuntu-22.04
env:
SKIP_PODMAN: 1
SKIP_DOCKER: 1
# - name: test (linux)
# task-name: test
# - name: test (macos)
# task-name: test
# os: macos-13-large
# env:
# SKIP_PODMAN: 1
# SKIP_DOCKER: 1
# # only until we fix some broken tests, as we need it to pass
# # in order to enable the caching
# continue-on-error: true
- name: test (wsl)
# runner does not support running containers
task-name: als:test-without-ee
log-name: als-test-without-ee
# https://github.com/actions/virtual-environments/issues/5151
os: devtools-vscode-win11-x64
shell: bash
# /bin/cp /etc/skel/.bashrc ~/
# echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
# echo 'export ASDF_DIR="$HOME/.asdf"' >> ~/.bashrc
steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0 # we need tags for dynamic versioning
# show-progress: false
# # https://github.com/marketplace/actions/setup-wsl
# - name: Activate WSL
# uses: Ubuntu/WSL/.github/actions/wsl-install@main
# with:
# distro: Ubuntu-22.04
# echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
- name: Checkout in WSL
uses: alisonlhart/WSL/.github/actions/wsl-checkout@main
with:
distro: Ubuntu-22.04
working-dir: /tmp/github/
- name: Install dependencies
uses: Ubuntu/WSL/.github/actions/wsl-bash@main
with:
distro: Ubuntu-22.04
working-dir: /tmp/github/
exec: |
apt install -y curl dbus dirmngr docker gawk git gpg gpg-agent jq make podman python3-dev python3-full python3-venv qemu-user-static tar unzip xvfb apt-transport-https ca-certificates software-properties-common
apt install -y libnss3-dev libasound2 libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
. "$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 -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt install -y docker-ce docker-ce-cli containerd.io
direnv --version
task --version
yarn --version
node --version
python3 --version
podman --version
docker --version
- name: task setup - wsl
uses: Ubuntu/WSL/.github/actions/wsl-bash@main
with:
distro: Ubuntu-22.04
working-dir: /tmp/github/
exec: |
. "$HOME/.asdf/asdf.sh"
export NODE_OPTIONS=--max_old_space_size=8192
task setup
- name: task package - wsl
uses: Ubuntu/WSL/.github/actions/wsl-bash@main
with:
distro: Ubuntu-22.04
working-dir: /tmp/github/
exec: |
. "$HOME/.asdf/asdf.sh"
export NODE_OPTIONS=--max_old_space_size=8192
task package ${{ matrix.env.TASKFILE_ARGS }}
- name: task unit
uses: Ubuntu/WSL/.github/actions/wsl-bash@main
with:
distro: Ubuntu-22.04
working-dir: /tmp/github/
exec: |
. "$HOME/.asdf/asdf.sh"
export NODE_OPTIONS=--max_old_space_size=8192
task unit ${{ matrix.env.TASKFILE_ARGS }}
# - name: task ui - wsl
# uses: Ubuntu/WSL/.github/actions/wsl-bash@main
# with:
# distro: Ubuntu-22.04
# working-dir: /tmp/github/vscode-ansible
# exec: |
# . "$HOME/.asdf/asdf.sh"
# export NODE_OPTIONS=--max_old_space_size=8192
# task ui ${{ matrix.env.TASKFILE_ARGS }}
- name: task e2e - wsl
uses: Ubuntu/WSL/.github/actions/wsl-bash@main
with:
distro: Ubuntu-22.04
working-dir: /tmp/github/
exec: |
. "$HOME/.asdf/asdf.sh"
export NODE_OPTIONS=--max_old_space_size=8192
task e2e ${{ matrix.env.TASKFILE_ARGS }}
- name: task als - wsl
uses: Ubuntu/WSL/.github/actions/wsl-bash@main
with:
distro: Ubuntu-22.04
working-dir: /tmp/github/
exec: |
. "$HOME/.asdf/asdf.sh"
export NODE_OPTIONS=--max_old_space_size=8192
task als ${{ matrix.env.TASKFILE_ARGS }}
# - name: task package
# id: package
# run: task package ${{ matrix.env.TASKFILE_ARGS }}
# - name: task ${{ matrix.task-name }}
# if: "${{ !contains(matrix.name, 'test') }}"
# run: task ${{ matrix.task-name }} ${{ matrix.env.TASKFILE_ARGS }}
# - name: task unit
# if: contains(matrix.name, 'test')
# run: task unit ${{ matrix.env.TASKFILE_ARGS }}
# - name: task ui
# # https://github.com/ansible/vscode-ansible/issues/1451
# if: "${{ contains(matrix.name, 'test') && !contains(matrix.name, 'wsl') }}"
# run: task ui ${{ matrix.env.TASKFILE_ARGS }}
# - name: task e2e
# # https://github.com/ansible/vscode-ansible/issues/1451
# if: "${{ contains(matrix.name, 'test') && !contains(matrix.name, 'wsl') }}"
# run: task e2e ${{ matrix.env.TASKFILE_ARGS }}
# - name: task als
# # https://github.com/ansible/vscode-ansible/issues/1451
# if: contains(matrix.name, 'test')
# run: task als ${{ matrix.env.TASKFILE_ARGS }}
# - name: task unit - wsl
# uses: Ubuntu/WSL/.github/actions/wsl-bash@main
# with:
# distro: Ubuntu-22.04
# working-dir: /tmp/github/
# exec: |
# task unit ${{ matrix.env.TASKFILE_ARGS }}
# wsl-conf: |
# [automount]
# enabled = true
# root = /
# options = "metadata,umask=077"
# [boot]
# command=/etc/init.d/dbus start
# [interop]
# enabled = false
# appendWindowsPath = false
# [network]
# hostname = wsl
- name: Setup asdf
if: ${{ !contains(matrix.name, 'wsl') }}
uses: asdf-vm/actions/install@v3
- name: Setup python
if: ${{ !contains(matrix.name, 'wsl') }}
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Activate direnv
if: ${{ !contains(matrix.name, 'wsl') }}
run: |
set -x
asdf direnv setup --shell bash --version latest
asdf current
asdf exec direnv allow
asdf exec direnv reload
asdf exec direnv exec . bash -c 'echo "VIRTUAL_ENV=${VIRTUAL_ENV}"' >> "$GITHUB_ENV"
asdf exec direnv exec . bash -c 'echo "${VIRTUAL_ENV}/bin"' >> "$GITHUB_PATH"
- name: Ensure virtualenv is active (direnv)
if: ${{ !contains(matrix.name, 'wsl') }}
run: |
set -x
test "${VIRTUAL_ENV:-}" = "${HOME}/.local/share/virtualenvs/vsa"
test "$(which python3)" = "${HOME}/.local/share/virtualenvs/vsa/bin/python3"
- name: Enable caching
uses: actions/cache@v4
with:
path: |
.vscode-test
.yarn/cache
out/ext
out/test-resources
out/test-resources-oldest
~/.cache/pip
~/.cache/yarn
~/.cache/pre-commit/
key: ${{ runner.os }}-${{ matrix.task-name }}-${{ hashFiles('package.json', 'yarn.lock', '.config/requirements.txt', 'tools/*.*') }}
# - name: Enable caching for podman-machine
# if: "contains(matrix.os, 'macos')"
# uses: actions/cache@v4
# with:
# path: |
# ~/.local/share/containers
# ~/.config/containers
# key: ${{ runner.os }}-${{ matrix.task-name }}-${{ hashFiles('package.json', 'yarn.lock', '.config/requirements.txt', '**/Taskfile.yml', 'tools/*.*') }}
# - name: task setup
# # starting podman machine can randomly get stuck on macos
# timeout-minutes: 25
# run: task setup
# ## uncomment to debug on GHA runner
# # - name: Setup tmate session
# # uses: mxschmitt/action-tmate@v3
# - name: task package
# id: package
# run: task package ${{ matrix.env.TASKFILE_ARGS }}
# - name: task ${{ matrix.task-name }}
# if: "${{ !contains(matrix.name, 'test') }}"
# run: task ${{ matrix.task-name }} ${{ matrix.env.TASKFILE_ARGS }}
# - name: task unit
# if: contains(matrix.name, 'test')
# run: task unit ${{ matrix.env.TASKFILE_ARGS }}
# - name: task ui
# # https://github.com/ansible/vscode-ansible/issues/1451
# if: "${{ contains(matrix.name, 'test') && !contains(matrix.name, 'wsl') }}"
# run: task ui ${{ matrix.env.TASKFILE_ARGS }}
# - name: task e2e
# # https://github.com/ansible/vscode-ansible/issues/1451
# if: "${{ contains(matrix.name, 'test') && !contains(matrix.name, 'wsl') }}"
# run: task e2e ${{ matrix.env.TASKFILE_ARGS }}
# - name: task als
# # https://github.com/ansible/vscode-ansible/issues/1451
# if: contains(matrix.name, 'test')
# run: task als ${{ matrix.env.TASKFILE_ARGS }}
- name: Upload vsix artifact
if: ${{ matrix.name == 'test (linux)' }}
uses: actions/upload-artifact@v4
with:
name: ansible-extension-build-${{ github.event.number || github.ref_name }}.zip
path: ansible-*.vsix
if-no-files-found: error
retention-days: 90
- name: Upload ansible-language-server npm package
if: ${{ matrix.name == 'test (linux)' }}
uses: actions/upload-artifact@v4
with:
name: "@ansible-ansible-language-server-build-${{ github.event.number || github.ref_name }}.tgz"
path: packages/ansible-language-server/*.tgz
if-no-files-found: error
retention-days: 90
- name: Upload test logs and reports
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: logs-${{ matrix.os }}-${{ matrix.log-name || matrix.task-name }}.zip
path: |
out/coverage
out/e2eTestReport
out/log
out/test-resources/settings/logs
out/userdata/logs
if-no-files-found: ignore
retention-days: 90
# - name: Stop services
# if: "contains(matrix.os, 'macos')"
# # Stopping podman machine is needed or caching it will fail
# run: |
# command -v podman && {
# podman machine stop
# while [[ "$(podman machine ls --format '{{.Running}}' \
# --noheading || true)" != "false" ]]; do
# sleep 1
# echo -n .
# done
# echo .
# }
# continue-on-error: true
## commented out for future use to debug on the GHA node if required
# - name: Setup tmate session
# if: ${{ always() }}
# uses: mxschmitt/action-tmate@v3
ack:
if: github.event_name == 'pull_request'
uses: ansible/team-devtools/.github/workflows/ack.yml@main
secrets: inherit
check: # This job does nothing and is only used for the branch protection
if: always()
needs:
- build
permissions: # codecov
id-token: write
checks: read
runs-on: ubuntu-22.04
steps:
- name: Merge logs into a single archive
uses: actions/upload-artifact/merge@v4
with:
name: logs.zip
pattern: logs*.zip
separate-directories: true
delete-merged: true
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: logs.zip
path: .
- name: Upload als test coverage data [1/4]
uses: codecov/codecov-action@v4
with:
name: als
files: ./*/coverage/als/lcov.info
flags: als
disable_search: true
fail_ci_if_error: true
use_oidc: true # cspell:ignore oidc
- name: Upload unit test coverage data [2/4]
uses: codecov/codecov-action@v4
with:
name: unit
files: ./*/coverage/unit/lcov.info
flags: unit
disable_search: true
fail_ci_if_error: true
use_oidc: true # cspell:ignore oidc
- name: Upload ui test coverage data [3/4]
uses: codecov/codecov-action@v4
with:
name: unit
files: ./*/coverage/ui/lcov.info
flags: ui
disable_search: true
fail_ci_if_error: true
use_oidc: true # cspell:ignore oidc
- name: Upload e2e test coverage data [4/4]
uses: codecov/codecov-action@v4
with:
name: e2e
files: ./*/coverage/e2e/lcov.info
flags: e2e
disable_search: true
fail_ci_if_error: true
use_oidc: true # cspell:ignore oidc
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
publish:
if: github.ref_type == 'tag' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: release # manual approval
needs:
- check
steps:
- name: Checkout Source
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: corepack enable
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 18
- name: Download the artifact
uses: actions/download-artifact@v4
with:
name: ansible-extension-build-${{ github.event.number || github.ref_name }}.zip
- run: |
yarn install --immutable
ls -la *.vsix
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Publish extension to marketplaces
run: |
./tools/helper --publish
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
OVSX_PAT: ${{ secrets.OVSX_PAT }}
publish-npm:
environment: release
if: needs.build.outputs.can_release_to_npm == 'true' && (github.ref_type == 'tag' || github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
needs:
- build
- check
steps:
- name: Download the artifact
uses: actions/download-artifact@v4
with:
name: "@ansible-ansible-language-server-build-${{ github.event.number || github.ref_name }}.tgz"
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
- run: npm publish --access public @ansible-ansible-language-server-*.tgz
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}