Skip to content

Commit

Permalink
Refactor how we determine TEST_LIGHTSPEED_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Apr 18, 2024
1 parent d6b722f commit 28a54b5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
11 changes: 11 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ export HOSTNAME="${HOSTNAME:-${HOST:-$(hostname)}}"
# for build and testing purposes.
export VIRTUAL_ENV="${HOME}/.local/share/virtualenvs/vsa"

# determine which TEST_LIGHTSPEED_URL value to use, as on macos we need a
# different value than on linux due to how ipv4/ipv6 hostnames are resolved.

if [[ "$OSTYPE" == "darwin"* ]]; then
TEST_LIGHTSPEED_URL='http://127.0.0.1:3000'
else
TEST_LIGHTSPEED_URL='http://ip6-localhost:3000'
fi
export TEST_LIGHTSPEED_URL


# Activate virtualenv (creates it if needed)
layout python
source_up 2>/dev/null || true
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ jobs:
#
# 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' }}"
# TEST_LIGHTSPEED_URL: "${{ contains(matrix.name, 'macos') && 'http://127.0.0.1:3000' || 'http://ip6-localhost:3000' }}"

# Set environment variables using matrix properties.
SKIP_PODMAN: "${{ matrix.env.SKIP_PODMAN || '0' }}"
Expand Down
4 changes: 4 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ tasks:
- webpack.config.ts
- Taskfile.yml
- ./tools/package.sh
- src/**/*
- test/**/*
- package/*/src
- package/*/test
generates:
- "*.vsix"
cmds:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@
"_test-ui": "extest get-vscode -c ${CODE_VERSION} -s out/test-resources && extest get-chromedriver -c ${CODE_VERSION} -s out/test-resources && extest install-vsix -f ansible-*.vsix -e out/ext -s out/test-resources && extest install-from-marketplace redhat.vscode-yaml ms-python.python -e out/ext -s out/test-resources && extest run-tests -s out/test-resources -e out/ext --code_settings test/testFixtures/settings.json out/client/test/ui-test/allTestsSuite.js",
"test-ui-current": "CODE_VERSION='max' yarn _test-ui",
"test-ui-oldest": "CODE_VERSION='min' yarn _test-ui",
"test-ui-with-mock-lightspeed-server": "TEST_LIGHTSPEED_URL='http://127.0.0.1:3000' ./tools/run-ui-test-with-mock-lightspeed-server.sh",
"test-ui-with-mock-lightspeed-server": "./tools/run-ui-test-with-mock-lightspeed-server.sh",
"vscode-prepublish": "yarn run webpack",
"watch": "tsc -b -w",
"watch-server": "tsc -p ../ansible-language-server --outDir out/server -w",
Expand All @@ -856,7 +856,7 @@
"mock-lightspeed-server": "DEBUG='express:*' node ./out/client/test/mockLightspeedServer/server.js 2> out/log/express.log",
"kill-mock-lightspeed-server": "pkill -f mockLightspeedServer/server.js",
"_coverage-all": "./tools/coverage-all.sh",
"coverage-all": "TEST_LIGHTSPEED_URL='http://127.0.0.1:3000' yarn _coverage-all",
"coverage-all": "yarn _coverage-all",
"als-compile": "yarn workspace @ansible/ansible-language-server compile"
},
"version": "24.4.0",
Expand Down
10 changes: 2 additions & 8 deletions tools/coverage-all.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#!/bin/bash

# If TEST_LIGHTSPEED_URL is not defined, set a URL with the ipv6 callback hostname,
# which is available in the GitHub Actions Linux environment.
if [[ -z "${TEST_LIGHTSPEED_URL}" ]]; then
TEST_LIGHTSPEED_URL="http://ip6-localhost:3000"
fi

# Start the mock Lightspeed server and run e2e tests with code coverage enabled.
npx start-server-and-test \
"TEST_LIGHTSPEED_URL=${TEST_LIGHTSPEED_URL} yarn mock-lightspeed-server" \
"yarn mock-lightspeed-server" \
"${TEST_LIGHTSPEED_URL}" \
"TEST_LIGHTSPEED_ACCESS_TOKEN=dummy TEST_LIGHTSPEED_URL=${TEST_LIGHTSPEED_URL} yarn coverage-e2e"
"TEST_LIGHTSPEED_ACCESS_TOKEN=dummy yarn coverage-e2e"
10 changes: 2 additions & 8 deletions tools/run-ui-test-with-mock-lightspeed-server.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#!/bin/bash

# If TEST_LIGHTSPEED_URL is not defined, set a URL with the ipv6 callback hostname,
# which is available in the GitHub Actions Linux environment.
if [[ -z "${TEST_LIGHTSPEED_URL}" ]]; then
TEST_LIGHTSPEED_URL="http://ip6-localhost:3000"
fi

# Start the mock Lightspeed server and run UI tests with the new VS Code
npx start-server-and-test \
"TEST_LIGHTSPEED_URL=${TEST_LIGHTSPEED_URL} yarn mock-lightspeed-server" \
"yarn mock-lightspeed-server" \
"${TEST_LIGHTSPEED_URL}" \
"TEST_LIGHTSPEED_ACCESS_TOKEN=dummy TEST_LIGHTSPEED_URL=${TEST_LIGHTSPEED_URL} yarn test-ui-current"
"TEST_LIGHTSPEED_ACCESS_TOKEN=dummy yarn test-ui-current"

0 comments on commit 28a54b5

Please sign in to comment.