Skip to content

Commit 05d0ca9

Browse files
hakalbMathias Lundin
authored andcommitted
fix(nx-payload): run e2e for a specific package manager and fix docker tests
Fixes COD-99, COD-117, COD-122
1 parent 6972760 commit 05d0ca9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1281
-711
lines changed

.env.local

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ NX_SKIP_NX_CACHE=false
2323
# If set to `true`, will print debug information useful for troubleshooting.
2424
NX_VERBOSE_LOGGING=false
2525

26-
### `nx-plugins` variables ###
26+
### Plugins variables ###
2727

28-
# E2E package manager; `bun`, `npm`, `pnpm`, `yarn`, `infer`
29-
E2E_PACKAGE_MANAGER=
28+
# If set to `true`, will print E2E debug information useful for troubleshooting.
29+
CDWR_DEBUG_LOGGING=true
30+
31+
# Package manager to use in E2E tests; `npm`, `pnpm`, `yarn` (todo: `bun`)
32+
CDWR_E2E_PACKAGE_MANAGER=
33+
34+
# Verdaccio host; 'localhost' is default Linux and 'host.docker.internal' is for macOS and Windows
35+
CDWR_E2E_VERDACCIO_HOST='host.docker.internal'

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
- uses: ./.github/actions/test
2323
with:
2424
codecov-token: ${{ secrets.CODECOV_TOKEN }}
25-
nx-cloud: ${{ contains(github.head_ref || github.ref_name, 'renovate') == false }}
25+
nx-cloud: ${{ contains(github.head_ref || github.ref_name, 'renovate') == false && vars.NX_NO_CLOUD != 'true' }}

.github/workflows/e2e-matrix.yml

Lines changed: 107 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ on:
1111
branches:
1212
- master
1313
workflow_dispatch:
14-
inputs:
15-
debug-enabled:
16-
type: boolean
17-
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
18-
required: false
19-
default: false
2014

2115
concurrency:
2216
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
@@ -27,25 +21,18 @@ jobs:
2721
runs-on: ${{ matrix.os }}
2822
strategy:
2923
matrix:
30-
os:
31-
- ubuntu-latest
32-
- windows-latest
33-
node_version:
34-
- 20
35-
- 18
36-
exclude:
37-
- os: windows-latest
38-
node_version: 18
24+
os: [ubuntu-latest, macos-latest, windows-latest]
25+
node: [20]
3926

40-
name: Cache install (${{ matrix.os }}, node v${{ matrix.node_version }})
27+
name: Cache install (${{ matrix.os }}, node v${{ matrix.node }})
4128
steps:
4229
- name: Checkout
4330
uses: actions/checkout@v4
4431

4532
- name: Set node
4633
uses: actions/setup-node@v4
4734
with:
48-
node-version: ${{ matrix.node_version }}
35+
node-version: ${{ matrix.node }}
4936
cache: 'yarn'
5037

5138
- name: Cache node_modules
@@ -54,7 +41,7 @@ jobs:
5441
with:
5542
lookup-only: true
5643
path: '**/node_modules'
57-
key: ${{ runner.os }}-modules-${{ matrix.node_version }}-${{ github.run_id }}
44+
key: ${{ matrix.os }}-modules-${{ matrix.node }}-${{ github.run_id }}
5845

5946
- name: Install packages
6047
if: steps.cache-modules.outputs.cache-hit != 'true'
@@ -68,91 +55,141 @@ jobs:
6855
timeout-minutes: 90
6956
strategy:
7057
matrix:
71-
os:
72-
- ubuntu-latest
73-
- windows-latest
74-
node_version:
75-
- 20
76-
- 18
77-
package_manager:
78-
- npm
79-
# - yarn
80-
# - pnpm
81-
project:
82-
- nx-payload-e2e
58+
os: [ubuntu-latest, macos-latest, windows-latest]
59+
node: [20]
60+
pm: [npm, pnpm, yarn]
61+
project: [nx-payload-e2e]
8362
include:
84-
# os short names
85-
- os: ubuntu-latest
86-
os_name: 'Linux'
87-
- os: windows-latest
88-
os_name: 'Windows'
89-
# test timeouts
90-
- os: ubuntu-latest
91-
os_timeout: 60
92-
- os: windows-latest
93-
os_timeout: 60
94-
# configurations
9563
- os: ubuntu-latest
96-
configuration: ''
64+
name: Linux
65+
timeout: 30
66+
configuration: 'skip-docker'
67+
verdaccio: localhost
68+
- os: macos-latest
69+
name: macOS
70+
timeout: 30
71+
configuration: skip-docker
9772
- os: windows-latest
98-
# will skip docker build test since node image doesn't exist running inside a windows container
99-
configuration: 'windows'
73+
name: Windows
74+
timeout: 60
75+
configuration: skip-docker
10076
exclude:
101-
# windows: only npm 20
102-
- os: windows-latest
103-
package_manager: yarn
77+
- os: macos-latest
78+
pm: pnpm
79+
- os: macos-latest
80+
pm: yarn
10481
- os: windows-latest
105-
package_manager: pnpm
82+
pm: pnpm
10683
- os: windows-latest
107-
node_version: 18
84+
pm: yarn
10885
fail-fast: false
10986

110-
name: E2E ${{ matrix.os_name }}/${{ matrix.package_manager }}/${{ matrix.node_version }} ${{ join(matrix.project) }}
87+
name: E2E ${{ matrix.os }}/${{ matrix.pm }}/${{ matrix.node }} ${{ join(matrix.project) }}
11188
steps:
11289
- name: Checkout
11390
uses: actions/checkout@v4
11491

115-
- name: Use Node.js ${{ matrix.node_version }}
92+
- name: Install PNPM
93+
run: npm install -g @pnpm/exe@8
94+
95+
- name: Use Node.js ${{ matrix.node }}
11696
uses: actions/setup-node@v4
11797
with:
118-
node-version: ${{ matrix.node_version }}
98+
node-version: ${{ matrix.node }}
11999
cache: 'yarn'
120100

121101
- name: Cache node_modules
122102
id: cache-modules
123103
uses: actions/cache@v4
124104
with:
125105
path: '**/node_modules'
126-
key: ${{ runner.os }}-modules-${{ matrix.node_version }}-${{ github.run_id }}
106+
key: ${{ runner.os }}-modules-${{ matrix.node }}-${{ github.run_id }}
127107

128108
- name: Install packages
129109
run: yarn install --immutable
130110

131-
- name: Set starting timestamp
132-
id: before-e2e
133-
run: |
134-
echo "timestamp=$(date +%s)" >> $GITHUB_OUTPUT
135-
136111
- name: Run e2e tests
137112
id: e2e-run
138113
run: yarn nx e2e ${{ matrix.project }} -c ${{ matrix.configuration }}
139-
timeout-minutes: ${{ matrix.os_timeout }}
114+
timeout-minutes: ${{ matrix.timeout }}
140115
env:
116+
CDWR_E2E_PACKAGE_MANAGER: ${{ matrix.pm }}
117+
CDWR_E2E_VERDACCIO_HOST: ${{ matrix.verdaccio }}
118+
CDWR_DEBUG_LOGGING: 'true'
141119
NX_CACHE_DIRECTORY: 'tmp'
142120
NX_PERF_LOGGING: 'false'
143-
NX_NO_CLOUD: ${{ contains(github.head_ref || github.ref_name, 'renovate') }}
121+
NX_NO_CLOUD: ${{ contains(github.head_ref || github.ref_name, 'renovate') || vars.NX_NO_CLOUD == 'true' }}
144122
# NX_DAEMON defaults to 'true' unless explicitly set to 'false'
145123
NX_DAEMON: ${{ env.NX_DAEMON == 'false' && 'false' || 'true' }}
146124
# NX_VERBOSE_LOGGING defaults to 'false' unless explicitly set to 'true'
147-
NX_VERBOSE_LOGGING: ${{ env.NX_VERBOSE_LOGGING == 'true' && 'true' || 'false' }}
148-
E2E_PACKAGE_MANAGER: ${{ env.E2E_PACKAGE_MANAGER }}
125+
NX_VERBOSE_LOGGING: ${{ vars.NX_VERBOSE_LOGGING == 'true' && 'true' || 'false' }}
126+
# Yarn workarounds
127+
YARN_ENABLE_HARDENED_MODE: ${{ vars.YARN_ENABLE_HARDENED_MODE == 'true' && 1 || 0 }}
128+
# TODO: fix flaky yarn lock issues when running `create-nx-workspace`
129+
YARN_ENABLE_IMMUTABLE_INSTALLS: ${{ vars.YARN_ENABLE_IMMUTABLE_INSTALLS }}
130+
- name: Save test result
131+
if: always()
132+
run: |
133+
echo '{"os": "${{ matrix.os }}", "pm": "${{ matrix.pm }}", "node": "${{ matrix.node }}", "configuration": "${{ matrix.configuration }}", "status": "${{ job.status }}"}' > results-${{ matrix.os }}-${{ matrix.pm }}-${{ matrix.node }}.json
134+
shell: bash
149135

150-
- name: Setup tmate session
151-
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug-enabled && failure() }}
152-
uses: mxschmitt/action-tmate@v3.18
153-
timeout-minutes: 15
154-
env:
155-
# disable sudo for windows debugging
156-
sudo: ${{ matrix.os != 'windows-latest' }}
136+
- name: Upload test results
137+
if: always()
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: results-${{ matrix.os }}-${{ matrix.pm }}-${{ matrix.node }}
141+
path: results-${{ matrix.os }}-${{ matrix.pm }}-${{ matrix.node }}.json
142+
143+
summary:
144+
name: E2E Test Summary
145+
needs: e2e
146+
runs-on: ubuntu-latest
147+
if: always()
148+
steps:
149+
- name: Download all workflow run artifacts
150+
uses: actions/download-artifact@v4
157151
with:
158-
sudo: ${{ env.sudo }}
152+
path: artifacts
153+
pattern: results-*
154+
merge-multiple: true
155+
- name: Create summary
156+
run: |
157+
echo "# E2E Test Results Summary" > summary.md
158+
echo "" >> summary.md
159+
echo "| OS | Package Manager | Node Version | Configuration | Status |" >> summary.md
160+
echo "|----|-----------------|--------------| ------------ | ------ |" >> summary.md
161+
for artifact in artifacts/*.json; do
162+
if [ -f "$artifact" ]; then
163+
os=$(jq -r '.os' "$artifact")
164+
pm=$(jq -r '.pm' "$artifact")
165+
configuration=$(jq -r '.configuration' "$artifact")
166+
node=$(jq -r '.node' "$artifact")
167+
status=$(jq -r '.status' "$artifact")
168+
echo "| $os | $pm | $node | $configuration | $status |" >> summary.md
169+
fi
170+
done
171+
172+
echo "" >> summary.md
173+
echo "## Detailed Results" >> summary.md
174+
echo "" >> summary.md
175+
echo "<details><summary>Click to expand</summary>" >> summary.md
176+
for artifact in artifacts/*.json; do
177+
echo "$(basename $artifact)" >> summary.md
178+
echo "" >> summary.md
179+
echo '```json' >> summary.md
180+
echo "" >> summary.md
181+
jq -s '.' $artifact >> summary.md
182+
echo "" >> summary.md
183+
echo '```' >> summary.md
184+
echo "" >> summary.md
185+
done
186+
echo "</details>" >> summary.md
187+
188+
- name: Upload summary artifact
189+
uses: actions/upload-artifact@v4
190+
with:
191+
name: e2e-test-summary
192+
path: summary.md
193+
194+
- name: Output summary
195+
run: cat summary.md >> $GITHUB_STEP_SUMMARY

.verdaccio/config.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@ uplinks:
77
url: https://registry.npmjs.org/
88
maxage: 60m
99

10-
# TODO: Codeware plugins needs to be stored in local registry during e2e tests, but all other packages can be proxied to npmjs.
11-
# There's a problem during e2e where public packages have localhost in lock file and install within Docker container are refused to connect.
12-
# Is it because e2e runs inside Docker containers and Verdaccio is running on host machine?
13-
# Is the problem inside Verdaccio configuration or Docker compose configuration?
10+
# give all users (including non-authenticated users) full access because it is a local registry
1411
packages:
1512
'@cdwr/*':
16-
# give all users (including non-authenticated users) full access
17-
# because it is a local registry
1813
access: $all
1914
publish: $all
2015
unpublish: $all
@@ -30,7 +25,7 @@ packages:
3025
proxy: npmjs
3126

3227
# log settings
33-
logs:
28+
log:
3429
type: stdout
3530
format: pretty
3631
level: warn

e2e/nx-payload-e2e/project.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"$schema": "../../node_modules/nx/schemas/project-schema.json",
44
"projectType": "application",
55
"sourceRoot": "e2e/nx-payload-e2e/src",
6+
"tags": ["scope:e2e"],
7+
"implicitDependencies": ["create-nx-payload", "nx-payload"],
68
"targets": {
79
"e2e": {
810
"executor": "@nx/jest:jest",
@@ -11,11 +13,11 @@
1113
"runInBand": true
1214
},
1315
"configurations": {
14-
"windows": { "testPathIgnorePatterns": ["docker"] }
15-
},
16-
"dependsOn": ["create-nx-payload:build", "nx-payload:build"]
16+
"docker": { "testPathPattern": ["docker"] },
17+
"skip-docker": {
18+
"testPathIgnorePatterns": ["docker"]
19+
}
20+
}
1721
}
18-
},
19-
"tags": ["scope:e2e"],
20-
"implicitDependencies": ["create-nx-payload", "nx-payload"]
22+
}
2123
}

0 commit comments

Comments
 (0)