Skip to content

Commit 6a3beee

Browse files
authored
Refactor GHA build steps (#1446)
- simplify taskfile test commands - sort GHA runner jobs for easier reading - reduce complexity of GHA steps - keep test steps separated on GHA to ease debugging failures - have a single codecov action upload per job - improve console logging during als testing
1 parent e2f9a3d commit 6a3beee

File tree

10 files changed

+150
-113
lines changed

10 files changed

+150
-113
lines changed

.c8rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"reporter": ["text", "html", "lcov"],
3-
"report-dir": "./out/coverage/ui-test",
3+
"report-dir": "./out/coverage/ui",
44
"exclude": [
55
"coverage/**",
66
"packages/*/test{,s}/**",

.config/Containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/ansible/creator-ee:v0.22.0 as DEFAULT_EE
1+
FROM ghcr.io/ansible/creator-ee:v24.2.0 as DEFAULT_EE
22
# This file is updated by dependabot and used to determine not only which
33
# version of creator-ee we are supposed to use for testing execution
44
# environments but also to dynamically retrieve the same set of constraints

.config/dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ neovim
158158
netcommon
159159
nocolor
160160
noheading
161+
norecursedirs
161162
notest
162163
notfound
163164
npmjs

.github/workflows/ci.yaml

Lines changed: 110 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,45 @@ env:
2121
PRETTIER_LEGACY_CLI: "1" # https://github.com/prettier/prettier/issues/15832
2222
# https://docs.github.com/en/actions/learn-github-actions/environment-variables
2323
# https://devblogs.microsoft.com/commandline/share-environment-vars-between-wsl-and-windows/
24-
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
24+
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
2525
# We define a hostname because otherwise the variable might not always be accessible on runners.
2626
HOSTNAME: gha
2727

2828
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2929
jobs:
3030
build:
3131
name: ${{ matrix.name }}
32-
environment: ci # codecov needed
32+
environment: ci
3333
env:
34-
SKIP_PODMAN: ${{ matrix.env.SKIP_PODMAN || 0 }}
3534
SKIP_DOCKER: ${{ matrix.env.SKIP_DOCKER || 0 }}
35+
SKIP_PODMAN: ${{ matrix.env.SKIP_PODMAN || 0 }}
36+
TASKFILE_ARGS: --output=group --output-group-begin='::group::{{.TASK}}' --output-group-end='::endgroup::'
37+
# For using the mock Lightspeed server.
38+
TEST_LIGHTSPEED_ACCESS_TOKEN: "dummy"
39+
# The mock server runs on localhost. However, just using "localhost" as the hostname causes a few issues in
40+
# GitHub Actions environment:
41+
#
42+
# On Linux: When "localhost" is used as the hostname, the mock server uses the ipv6 loopback address [::1] . However,
43+
# the axios library, which is used in the extension tries to access to the ipv4 loopback 127.0.0.1 when "localhost"
44+
# is specified and the axios library does not support URLs that contains ipv6 addresses, e.g. http://[::1]:3000.
45+
# Also, If 127.0.0.1 is specified for the mock server, the server fails to start. Those issues are resolved by
46+
# using the special ipv6-only hostname "ip6-localhost", which is available in GitHub Actions Linux environment.
47+
#
48+
# On MacOS: The hostname "ip6-localhost" is not available. However, 127.0.0.1 can be used for starting the mock
49+
# server on MacOS and the axios library can connect to that address. So we can use 127.0.0.1 for MacOS.
50+
#
51+
# Once the axios library starts supporting URLs that contain ipv6 addresses, we will be able to use
52+
# http://[::1]:3000 both on Linux and MacOS to get rid of the following conditional statement.
53+
TEST_LIGHTSPEED_URL: "${{ contains(matrix.name, 'macos') && 'http://127.0.0.1:3000' || 'http://ip6-localhost:3000' }}"
54+
55+
# Set environment variables using matrix properties.
56+
# For using an actual Lightspeed server instance, uncomment following two lines.
57+
# TEST_LIGHTSPEED_ACCESS_TOKEN: ${{ secrets.TEST_LIGHTSPEED_ACCESS_TOKEN }}
58+
# TEST_LIGHTSPEED_URL: ${{ secrets.TEST_LIGHTSPEED_URL }}
59+
3660
defaults:
3761
run:
3862
shell: ${{ matrix.shell || 'bash'}}
39-
permissions:
40-
id-token: write
41-
checks: read
4263
# The type of runner that the job will run on
4364
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
4465
# see https://github.com/containers/podman/issues/13609
@@ -50,32 +71,30 @@ jobs:
5071
matrix:
5172
# Avoid letting github do the matrix multiplication and use manual
5273
# includes for each job, this gives us fine control over job name.
74+
# Order is important, keep it alphabetical: docs, lint, test*
5375
continue-on-error:
5476
- false
5577
os:
5678
- ubuntu-22.04
5779
task-name:
58-
- test
80+
- docs
5981
name:
60-
- test
82+
- docs
6183
include:
62-
# - name: test-node-lts
63-
# task-name: test
64-
# task-name-als: als:test-node-lts
65-
- name: docs
66-
task-name: docs
67-
task-name-als: ""
6884
- name: lint
6985
task-name: lint
70-
task-name-als: ""
7186
os: ubuntu-22.04
7287
env:
7388
SKIP_PODMAN: 1
7489
SKIP_DOCKER: 1
7590

91+
- name: test (linux)
92+
task-name: test
93+
# https://github.com/ansible/vscode-ansible/issues/1473
94+
ignore-als-test-failure: true
95+
7696
- name: test (macos)
7797
task-name: test
78-
task-name-als: als:test-without-ee
7998
os: macos-13-large
8099
env:
81100
SKIP_PODMAN: 1
@@ -84,12 +103,12 @@ jobs:
84103
# in order to enable the caching
85104
continue-on-error: true
86105

87-
- name: als:test-without-ee (wsl)
88-
# runner does not support running container
106+
- name: test (wsl)
107+
# runner does not support running containers
89108
task-name: als:test-without-ee
90109
log-name: als-test-without-ee
91110
# https://github.com/actions/virtual-environments/issues/5151
92-
os: windows-2022
111+
os: devtools-win-x64
93112
shell: "wsl-bash {0}"
94113
env:
95114
SKIP_PODMAN: 1
@@ -223,87 +242,31 @@ jobs:
223242
# uses: mxschmitt/action-tmate@v3
224243
- name: task package
225244
id: package
226-
run: task package --output=group --output-group-begin='::group::{{.TASK}}' --output-group-end='::endgroup::'
245+
run: task package ${{ matrix.env.TASKFILE_ARGS }}
227246

228247
- name: task ${{ matrix.task-name }}
229-
env:
230-
# For using the mock Lightspeed server.
231-
TEST_LIGHTSPEED_ACCESS_TOKEN: "dummy"
232-
# The mock server runs on localhost. However, just using "localhost" as the hostname causes a few issues in
233-
# GitHub Actions environment:
234-
#
235-
# On Linux: When "localhost" is used as the hostname, the mock server uses the ipv6 loopback address [::1] . However,
236-
# the axios library, which is used in the extension tries to access to the ipv4 loopback 127.0.0.1 when "localhost"
237-
# is specified and the axios library does not support URLs that contains ipv6 addresses, e.g. http://[::1]:3000.
238-
# Also, If 127.0.0.1 is specified for the mock server, the server fails to start. Those issues are resolved by
239-
# using the special ipv6-only hostname "ip6-localhost", which is available in GitHub Actions Linux environment.
240-
#
241-
# On MacOS: The hostname "ip6-localhost" is not available. However, 127.0.0.1 can be used for starting the mock
242-
# server on MacOS and the axios library can connect to that address. So we can use 127.0.0.1 for MacOS.
243-
#
244-
# Once the axios library starts supporting URLs that contain ipv6 addresses, we will be able to use
245-
# http://[::1]:3000 both on Linux and MacOS to get rid of the following conditional statement.
246-
TEST_LIGHTSPEED_URL: "${{ contains(matrix.name, 'macos') && 'http://127.0.0.1:3000' || 'http://ip6-localhost:3000' }}"
247-
248-
# Set environment variables using matrix properties.
249-
SKIP_PODMAN: "${{ matrix.env.SKIP_PODMAN || '0' }}"
250-
SKIP_DOCKER: "${{ matrix.env.SKIP_DOCKER || '0' }}"
251-
252-
# For using an actual Lightspeed server instance, uncomment following two lines.
253-
# TEST_LIGHTSPEED_ACCESS_TOKEN: ${{ secrets.TEST_LIGHTSPEED_ACCESS_TOKEN }}
254-
# TEST_LIGHTSPEED_URL: ${{ secrets.TEST_LIGHTSPEED_URL }}
255-
run: task ${{ matrix.task-name }} --output=group --output-group-begin='::group::{{.TASK}}' --output-group-end='::endgroup::'
256-
257-
- name: task ${{ matrix.task-name-als }}
258-
if: ${{ (matrix.task-name-als || '') != '' }}
259-
env:
260-
SKIP_PODMAN: "${{ matrix.env.SKIP_PODMAN || '0' }}"
261-
SKIP_DOCKER: "${{ matrix.env.SKIP_DOCKER || '0' }}"
262-
run: task ${{ matrix.task-name-als }} --output=group --output-group-begin='::group::{{.TASK}}' --output-group-end='::endgroup::'
248+
if: "${{ !contains(matrix.name, 'test') }}"
249+
run: task ${{ matrix.task-name }} ${{ matrix.env.TASKFILE_ARGS }}
263250

264-
- name: Upload coverage data (unit test)
265-
if: ${{ startsWith(matrix.name, 'test') }}
266-
uses: codecov/codecov-action@v4
267-
with:
268-
name: ${{ matrix.name }}
269-
files: out/coverage/unit/lcov.info
270-
disable_search: true
271-
flags: unit
272-
fail_ci_if_error: true
273-
use_oidc: true # cspell:ignore oidc
251+
- name: task unit
252+
if: contains(matrix.name, 'test')
253+
run: task unit ${{ matrix.env.TASKFILE_ARGS }}
274254

275-
- name: Upload coverage data (ui test)
276-
if: ${{ startsWith(matrix.name, 'test') }}
277-
uses: codecov/codecov-action@v4
278-
with:
279-
name: ${{ matrix.name }}
280-
files: out/coverage/ui-test/lcov.info
281-
disable_search: true
282-
flags: ui
283-
fail_ci_if_error: true
284-
use_oidc: true # cspell:ignore oidc
255+
- name: task ui
256+
# https://github.com/ansible/vscode-ansible/issues/1451
257+
if: "${{ contains(matrix.name, 'test') && !contains(matrix.name, 'wsl') }}"
258+
run: task ui ${{ matrix.env.TASKFILE_ARGS }}
285259

286-
- name: Upload coverage data (e2e test)
287-
if: ${{ startsWith(matrix.name, 'test') }}
288-
uses: codecov/codecov-action@v4
289-
with:
290-
name: ${{ matrix.name }}
291-
files: out/coverage/e2e/lcov.info
292-
disable_search: true
293-
flags: e2e
294-
fail_ci_if_error: true
295-
use_oidc: true # cspell:ignore oidc
260+
- name: task e2e
261+
# https://github.com/ansible/vscode-ansible/issues/1451
262+
if: "${{ contains(matrix.name, 'test') && !contains(matrix.name, 'wsl') }}"
263+
run: task e2e ${{ matrix.env.TASKFILE_ARGS }}
296264

297-
- name: Upload coverage data (als)
298-
if: contains(matrix.task-name-als, 'test') || contains(matrix.task-name, 'als:test')
299-
uses: codecov/codecov-action@v4
300-
with:
301-
name: ${{ matrix.name }}
302-
files: out/coverage/als/lcov.info
303-
disable_search: true
304-
flags: als
305-
fail_ci_if_error: true
306-
use_oidc: true # cspell:ignore oidc
265+
- name: task als
266+
# https://github.com/ansible/vscode-ansible/issues/1451
267+
if: contains(matrix.name, 'test')
268+
continue-on-error: ${{ matrix.ignore-als-test-failure || false }}
269+
run: task als ${{ matrix.env.TASKFILE_ARGS }}
307270

308271
- name: Upload vsix artifact
309272
if: ${{ matrix.name == 'test' }}
@@ -323,12 +286,13 @@ jobs:
323286
if-no-files-found: error
324287
retention-days: 90
325288

326-
- name: Upload test logs
289+
- name: Upload test logs and reports
327290
if: ${{ always() }}
328291
uses: actions/upload-artifact@v4
329292
with:
330293
name: logs-${{ matrix.os }}-${{ matrix.log-name || matrix.task-name }}.zip
331294
path: |
295+
out/coverage
332296
out/e2eTestReport
333297
out/log
334298
out/test-resources/settings/logs
@@ -367,6 +331,10 @@ jobs:
367331
needs:
368332
- build
369333

334+
permissions: # codecov
335+
id-token: write
336+
checks: read
337+
370338
runs-on: ubuntu-22.04
371339

372340
steps:
@@ -375,8 +343,55 @@ jobs:
375343
with:
376344
name: logs.zip
377345
pattern: logs*.zip
346+
separate-directories: true
378347
delete-merged: true
379348

349+
- name: Download artifacts
350+
uses: actions/download-artifact@v4
351+
with:
352+
name: logs.zip
353+
path: .
354+
355+
- name: Upload als test coverage data [1/4]
356+
uses: codecov/codecov-action@v4
357+
with:
358+
name: als
359+
files: ./*/coverage/als/lcov.info
360+
flags: als
361+
disable_search: true
362+
fail_ci_if_error: true
363+
use_oidc: true # cspell:ignore oidc
364+
365+
- name: Upload unit test coverage data [2/4]
366+
uses: codecov/codecov-action@v4
367+
with:
368+
name: unit
369+
files: ./*/coverage/unit/lcov.info
370+
flags: unit
371+
disable_search: true
372+
fail_ci_if_error: true
373+
use_oidc: true # cspell:ignore oidc
374+
375+
- name: Upload ui test coverage data [3/4]
376+
uses: codecov/codecov-action@v4
377+
with:
378+
name: unit
379+
files: ./*/coverage/ui/lcov.info
380+
flags: ui
381+
disable_search: true
382+
fail_ci_if_error: true
383+
use_oidc: true # cspell:ignore oidc
384+
385+
- name: Upload e2e test coverage data [4/4]
386+
uses: codecov/codecov-action@v4
387+
with:
388+
name: e2e
389+
files: ./*/coverage/e2e/lcov.info
390+
flags: e2e
391+
disable_search: true
392+
fail_ci_if_error: true
393+
use_oidc: true # cspell:ignore oidc
394+
380395
- name: Decide whether the needed jobs succeeded or failed
381396
uses: re-actors/alls-green@release/v1
382397
with:

Taskfile.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,41 +131,38 @@ tasks:
131131
- test
132132
- tools
133133
test:
134-
desc: Run all tests
134+
# cspell: disable-next-line
135+
desc: "Run all tests: \e[22;32munit, ui, e2e, als\e[0m"
135136
cmds:
136137
- task: setup
137138
- task: unit
138-
- task: test-ui
139-
#- task: test-ui-old
140-
- task: test-e2e
139+
- task: ui
140+
- task: e2e
141+
- task: als:test
141142
# .vsix file is no longer needed for executing tests.
142143
# This is just for making sure that the package step works w/o issues.
143144
- task: package
144145
- tools/dirty.sh
145146
interactive: true
146147
test-e2e:
147148
desc: Run e2e tests {{.XVFB}}
149+
aliases: [e2e]
148150
cmds:
149151
- task: package
150152
- $VIRTUAL_ENV/bin/python3 --version
151153
- '{{.XVFB}} bash -c ''source "${VIRTUAL_ENV}/bin/activate" && yarn run _coverage-all'''
152154
interactive: true
153155
test-ui:
154156
desc: Run UI tests {{.XVFB}}
157+
aliases: [ui]
155158
cmds:
156159
- yarn webpack-dev
157160
- $VIRTUAL_ENV/bin/python3 --version
158161
- ' {{.XVFB}} bash -c ''source "${VIRTUAL_ENV}/bin/activate" && yarn _coverage-ui-with-mock-lightspeed-server'''
159162
interactive: true
160-
# test-ui-old:
161-
# desc: Run UI tests (oldest vscode)
162-
# cmds:
163-
# - task: package
164-
# - $VIRTUAL_ENV/bin/python3 --version
165-
# - bash -c 'source "${VIRTUAL_ENV}/bin/activate" && yarn run test-ui-oldest'
166-
# interactive: true
167-
unit:
163+
test-unit:
168164
desc: Run unit tests with coverage report
165+
aliases: [unit]
169166
cmds:
170167
- npm run unit-tests
171168
interactive: true

codecov.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
codecov:
22
require_ci_to_pass: true
3+
notify:
4+
after_n_builds: 3 # effectively number of uploads: linux, macos, wsl
5+
wait_for_ci: true
36
comment: false
47
coverage:
58
status:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@
990990
"package": "./tools/helper --package",
991991
"preinstall": "",
992992
"pretest": "yarn run compile",
993-
"unit-tests": "nyc mocha --recursive test/units/lightspeed",
993+
"unit-tests": "sh -c \"nyc mocha --recursive test/units/lightspeed ${MOCHA_OPTS:-}\"",
994994
"test-ui": "yarn run test-ui-current && yarn run test-ui-oldest",
995995
"_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",
996996
"test-ui-current": "CODE_VERSION='max' yarn _test-ui",

0 commit comments

Comments
 (0)