Skip to content

Commit d7094ac

Browse files
committed
github test: create test results in jest and upload them for dorny/test-reporter
1 parent 006eb47 commit d7094ac

File tree

8 files changed

+112
-22
lines changed

8 files changed

+112
-22
lines changed

.github/workflows/make-and-test.yml

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Check doc links
4444
run: cd src/scripts && python3 check_doc_urls.py || sleep 5 || python3 check_doc_urls.py
4545

46-
build:
46+
test:
4747
runs-on: ubuntu-latest
4848

4949
services:
@@ -94,7 +94,7 @@ jobs:
9494
- name: Download and install Valkey
9595
run: |
9696
VALKEY_VERSION=8.1.2
97-
curl -LO https://download.valkey.io/releases/valkey-${VALKEY_VERSION}-jammy-x86_64.tar.gz
97+
curl -LOq https://download.valkey.io/releases/valkey-${VALKEY_VERSION}-jammy-x86_64.tar.gz
9898
tar -xzf valkey-${VALKEY_VERSION}-jammy-x86_64.tar.gz
9999
sudo cp valkey-${VALKEY_VERSION}-jammy-x86_64/bin/valkey-server /usr/local/bin/
100100
@@ -106,7 +106,49 @@ jobs:
106106
pip install ipykernel
107107
python -m ipykernel install --prefix=./jupyter-local --name python3-local --display-name "Python 3 (Local)"
108108
109-
- run: cd src && npm install -g pnpm
110-
- run: cd src && pnpm run make
111-
- run: source venv/bin/activate && cd src && pnpm run test || pnpm run test || pnpm run test
112-
- run: cd src && pnpm run depcheck
109+
- name: install pnpm
110+
#run: cd src && npm install -g pnpm
111+
uses: pnpm/action-setup@v4
112+
with:
113+
version: 10
114+
run_install: false
115+
116+
- name: build
117+
run: cd src && pnpm run make
118+
119+
- name: test
120+
run: source venv/bin/activate && cd src && pnpm run test:report
121+
122+
- name: upload test results
123+
uses: actions/upload-artifact@v4 # upload test results
124+
if: ${{ !cancelled() }} # run this step even if previous step failed
125+
with:
126+
name: "test-results-node-${{ matrix.node-version }}-pg-${{ matrix.pg-version }}"
127+
path: 'src/packages/*/junit.xml'
128+
129+
- name: dependency check
130+
run: cd src && pnpm run depcheck
131+
132+
# Separater Job für Test-Reporting
133+
test-report:
134+
runs-on: ubuntu-latest
135+
needs: [test]
136+
if: ${{ !cancelled() }}
137+
steps:
138+
- name: Checkout code
139+
uses: actions/checkout@v4
140+
141+
- name: Download all test artifacts
142+
uses: actions/download-artifact@v4
143+
with:
144+
pattern: "test-results-*"
145+
merge-multiple: true
146+
path: test-results/
147+
148+
- name: Test Report
149+
uses: dorny/test-reporter@v2
150+
with:
151+
name: CoCalc Jest Tests
152+
path: 'test-results/**/junit.xml'
153+
reporter: jest-junit
154+
fail-on-error: false

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,6 @@ src/packages/frontend/i18n/trans/*.compiled.json
159159
**/*.db
160160
**/project-env.sh
161161
**/*.bash_history
162+
163+
# test reports by jest-junit
164+
junit.xml

src/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"version-check": "pip3 install --break-system-packages typing_extensions mypy || pip3 install --break-system-packages typing_extensions mypy && ./workspaces.py version-check && mypy scripts/check_npm_packages.py",
1919
"test-parallel": "unset DEBUG && pnpm run version-check && cd packages && pnpm run -r --parallel test",
2020
"test": "unset DEBUG && pnpm run version-check && cd packages && pnpm run -r test",
21+
"test:report": "unset DEBUG && pnpm run version-check && cd packages && pnpm run -r test:report",
2122
"depcheck": "cd packages && pnpm run -r --parallel depcheck",
2223
"prettier-all": "cd packages/",
2324
"local-ci": "./scripts/ci.sh",

src/packages/backend/package.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010
"./auth/*": "./dist/auth/*.js",
1111
"./auth/tokens/*": "./dist/auth/tokens/*.js"
1212
},
13-
"keywords": ["utilities", "cocalc"],
13+
"keywords": [
14+
"utilities",
15+
"cocalc"
16+
],
1417
"scripts": {
1518
"preinstall": "npx only-allow pnpm",
1619
"clean": "rm -rf dist node_modules",
1720
"build": "pnpm exec tsc --build",
1821
"tsc": "pnpm exec tsc --watch --pretty --preserveWatchOutput",
1922
"test": "pnpm exec jest --forceExit --maxWorkers=50%",
23+
"test:report": "pnpm exec jest --forceExit --maxWorkers=50% --reporters=default --reporters=jest-junit",
2024
"depcheck": "pnpx depcheck --ignores events",
2125
"prepublishOnly": "pnpm test",
2226
"conat-watch": "node ./bin/conat-watch.cjs",
@@ -25,7 +29,12 @@
2529
"conat-inventory": "node ./bin/conat-inventory.cjs",
2630
"conat-persist": "DEBUG=cocalc:* node ./bin/conat-persist.cjs"
2731
},
28-
"files": ["dist/**", "bin/**", "README.md", "package.json"],
32+
"files": [
33+
"dist/**",
34+
"bin/**",
35+
"README.md",
36+
"package.json"
37+
],
2938
"author": "SageMath, Inc.",
3039
"license": "SEE LICENSE.md",
3140
"dependencies": {
@@ -54,6 +63,7 @@
5463
},
5564
"homepage": "https://github.com/sagemathinc/cocalc/tree/master/src/packages/backend",
5665
"devDependencies": {
57-
"@types/node": "^18.16.14"
66+
"@types/node": "^18.16.14",
67+
"jest-junit": "^16.0.0"
5868
}
5969
}

src/packages/database/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@
3838
"@types/lodash": "^4.14.202",
3939
"@types/node": "^18.16.14",
4040
"@types/pg": "^8.6.1",
41-
"coffeescript": "^2.5.1"
41+
"coffeescript": "^2.5.1",
42+
"jest-junit": "^16.0.0"
4243
},
4344
"scripts": {
4445
"preinstall": "npx only-allow pnpm",
4546
"build": "../node_modules/.bin/tsc --build && coffee -c -o dist/ ./",
4647
"clean": "rm -rf dist",
4748
"tsc": "../node_modules/.bin/tsc --watch --pretty --preserveWatchOutput",
4849
"test": "pnpm exec jest --forceExit --runInBand",
50+
"test:report": "pnpm exec jest --forceExit --runInBand --reporters=default --reporters=jest-junit",
4951
"depcheck": "pnpx depcheck | grep -Ev '\\.coffee|coffee$'",
5052
"prepublishOnly": "pnpm test"
5153
},

src/packages/hub/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"devDependencies": {
5151
"@types/express": "^4.17.21",
5252
"@types/node": "^18.16.14",
53-
"coffeescript": "^2.5.1"
53+
"coffeescript": "^2.5.1",
54+
"jest-junit": "^16.0.0"
5455
},
5556
"scripts": {
5657
"preinstall": "npx only-allow pnpm",
@@ -66,6 +67,7 @@
6667
"hub-docker-prod-nossl": "export DEBUG=${DEBUG:='cocalc:*,-cocalc:silly:*'} && COCALC_DOCKER=true NODE_ENV=production PROJECTS=/projects/[project_id] PORT=80 NODE_OPTIONS='--max_old_space_size=8000 --enable-source-maps' cocalc-hub-server --mode=multi-user --all --hostname=0.0.0.0",
6768
"tsc": "tsc --watch --pretty --preserveWatchOutput",
6869
"test": "jest dist/",
70+
"test:report": "jest dist/ --reporters=default --reporters=jest-junit",
6971
"depcheck": "pnpx depcheck | grep -Ev '\\.coffee|coffee$'",
7072
"prepublishOnly": "test"
7173
},

src/packages/pnpm-lock.yaml

Lines changed: 39 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/packages/util/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"build": "pnpm exec tsc --build",
2121
"tsc": "pnpm exec tsc --watch --pretty --preserveWatchOutput",
2222
"test": "pnpm exec jest",
23+
"test:report": "pnpm exec jest --reporters=default --reporters=jest-junit",
2324
"depcheck": "pnpx depcheck --ignores events",
2425
"prepublishOnly": "pnpm test"
2526
},
@@ -76,6 +77,7 @@
7677
"@types/node": "^18.16.14",
7778
"@types/seedrandom": "^3.0.8",
7879
"@types/uuid": "^8.3.1",
80+
"jest-junit": "^16.0.0",
7981
"expect": "^26.6.2",
8082
"seedrandom": "^3.0.5",
8183
"tsd": "^0.22.0"

0 commit comments

Comments
 (0)