-
Notifications
You must be signed in to change notification settings - Fork 434
174 lines (155 loc) · 6.15 KB
/
scripts-javascript.yml
File metadata and controls
174 lines (155 loc) · 6.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Test JavaScript screenshot scripts
on:
pull_request:
paths:
- '.github/workflows/scripts-javascript.yml'
- 'scripts/run-javascript-browser-tests.sh'
- 'scripts/run-javascript-screenshot-tests.sh'
- 'scripts/run-javascript-headless-browser.mjs'
- 'scripts/build-javascript-port-hellocodenameone.sh'
- 'scripts/javascript_browser_harness.py'
- 'scripts/javascript/screenshots/**'
- 'scripts/lib/cn1ss.sh'
- 'scripts/common/java/**'
- 'scripts/hellocodenameone/**'
- 'Ports/JavaScriptPort/**'
- 'vm/**'
- 'maven/**'
- '!maven/core-unittests/**'
- '!docs/**'
push:
branches: [ master ]
paths:
- '.github/workflows/scripts-javascript.yml'
- 'scripts/run-javascript-browser-tests.sh'
- 'scripts/run-javascript-screenshot-tests.sh'
- 'scripts/run-javascript-headless-browser.mjs'
- 'scripts/build-javascript-port-hellocodenameone.sh'
- 'scripts/javascript_browser_harness.py'
- 'scripts/javascript/screenshots/**'
- 'scripts/lib/cn1ss.sh'
- 'scripts/common/java/**'
- 'scripts/hellocodenameone/**'
- 'Ports/JavaScriptPort/**'
- 'vm/**'
- 'maven/**'
- '!maven/core-unittests/**'
- '!docs/**'
jobs:
javascript-screenshots:
permissions:
contents: read
pull-requests: write
issues: write
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.CN1SS_GH_TOKEN }}
GH_TOKEN: ${{ secrets.CN1SS_GH_TOKEN }}
ARTIFACTS_DIR: ${{ github.workspace }}/artifacts/javascript-ui-tests
CN1_JS_TIMEOUT_SECONDS: "180"
CN1_JS_BROWSER_LIFETIME_SECONDS: "150"
CN1SS_SKIP_COVERAGE: "1"
CN1SS_FAIL_ON_MISMATCH: "1"
BROWSER_CMD: "node \"$GITHUB_WORKSPACE/scripts/run-javascript-headless-browser.mjs\""
steps:
- uses: actions/checkout@v4
- name: Set TMPDIR
run: echo "TMPDIR=${{ runner.temp }}" >> $GITHUB_ENV
- name: Cache codenameone-tools
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/codenameone-tools
key: ${{ runner.os }}-cn1-tools-${{ hashFiles('scripts/setup-workspace.sh') }}
restore-keys: |
${{ runner.os }}-cn1-tools-
- name: Set up Java 8 for ParparVM
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '8'
cache: 'maven'
- name: Prepare Codename One binaries for Maven plugin
run: |
mkdir -p ~/.codenameone
cp maven/UpdateCodenameOne.jar ~/.codenameone/
- name: Build ParparVM compiler bundle
run: mvn -B -f maven/pom.xml -pl parparvm -am -DskipTests -Dmaven.javadoc.skip=true package
- name: Set up Java 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
cache: 'maven'
- name: Set up Node 20
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Cache npm modules for scripts/
uses: actions/cache@v4
with:
path: scripts/node_modules
key: ${{ runner.os }}-scripts-npm-playwright-v1
restore-keys: |
${{ runner.os }}-scripts-npm-
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-chromium-v2
restore-keys: |
${{ runner.os }}-playwright-
- name: Install Playwright Chromium
run: |
cd scripts
npm init -y 2>/dev/null || true
npm install playwright
# OS-level deps (apt packages) aren't cached so always install them.
npx playwright install-deps chromium
# `npm install playwright` resolves the floating version, so the
# cached browser binary can drift away from what the freshly
# installed Playwright expects (the cache only stores the binary).
# `install chromium` is a no-op when the versions match and
# re-downloads the right build when they don't, so it makes the
# job resilient to Playwright revving its bundled chromium build
# in between cache writes.
npx playwright install chromium
- name: Install Xvfb for headless Java AWT
run: sudo apt-get update && sudo apt-get install -y xvfb
- name: Setup workspace
run: xvfb-run ./scripts/setup-workspace.sh -q -DskipTests
- name: Build HelloCodenameOne JavaScript port bundle
run: |
# Use JAVA_HOME set by actions/setup-java for Java 17
# (JAVA_HOME_17_X64 is always available after setup-java@v4)
export JAVA_HOME="${JAVA_HOME_17_X64}"
export PATH="$JAVA_HOME/bin:$PATH"
echo "Using JAVA_HOME=$JAVA_HOME"
java -version
# xvfb-run is required for CSS compilation which uses java.awt
SKIP_PARPARVM_BUILD=1 xvfb-run ./scripts/build-javascript-port-hellocodenameone.sh "${GITHUB_WORKSPACE}/artifacts/javascript-ui-tests/hellocodenameone-javascript-port.zip"
- name: Locate JavaScript bundle
id: locate_bundle
run: |
set -euo pipefail
bundle="$(ls -1 \
artifacts/javascript-ui-tests/hellocodenameone-javascript-port.zip \
scripts/hellocodenameone/parparvm/target/hellocodenameone-javascript-port.zip \
2>/dev/null | head -n1 || true)"
if [ -z "$bundle" ]; then
echo "Unable to locate HelloCodenameOne JavaScript-port bundle" >&2
exit 1
fi
echo "bundle=$bundle" >> "$GITHUB_OUTPUT"
- name: Run JavaScript screenshot browser tests
run: |
mkdir -p "${ARTIFACTS_DIR}"
./scripts/run-javascript-browser-tests.sh "${{ steps.locate_bundle.outputs.bundle }}" "${GITHUB_WORKSPACE}/scripts/javascript/screenshots"
- name: Upload JavaScript screenshot artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: javascript-ui-tests
path: artifacts/javascript-ui-tests
if-no-files-found: warn
retention-days: 14