Skip to content

Commit 2fe6d18

Browse files
authored
Merge pull request #8406 from sagemathinc/github-tests-report-status
github test dorny/test-reporter
2 parents ba3a96b + a399033 commit 2fe6d18

File tree

9 files changed

+148
-36
lines changed

9 files changed

+148
-36
lines changed

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

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Make all packages and run their tests
1+
name: Test
22

33
# newer commits in the same PR abort running ones for the same workflow
44
concurrency:
@@ -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,6 +106,52 @@ 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-github-ci
109+
110+
- name: install 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+
# This runs all the tests with text output and jest-junit reporters to generate junit.xml reports
120+
# That test-github-ci target runs workspaces.py for testing, which in turn runs the depchecks
121+
- name: test
122+
run: source venv/bin/activate && cd src && pnpm run test-github-ci --report
123+
124+
- name: upload test results
125+
uses: actions/upload-artifact@v4 # upload test results
126+
if: ${{ !cancelled() }} # run this step even if previous step failed
127+
with:
128+
name: "test-results-node-${{ matrix.node-version }}-pg-${{ matrix.pg-version }}"
129+
path: 'src/packages/*/junit.xml'
130+
131+
report:
132+
runs-on: ubuntu-latest
133+
134+
needs: [test]
135+
136+
if: ${{ !cancelled() }}
137+
138+
steps:
139+
- name: Checkout code
140+
uses: actions/checkout@v4
141+
142+
- name: Download all test artifacts
143+
uses: actions/download-artifact@v4
144+
with:
145+
pattern: "test-results-*"
146+
merge-multiple: true
147+
path: test-results/
148+
149+
- name: Test Report
150+
uses: dorny/test-reporter@v2
151+
with:
152+
name: CoCalc Jest Tests
153+
path: 'test-results/**/junit.xml'
154+
reporter: jest-junit
155+
use-actions-summary: 'true'
156+
fail-on-error: false
157+

.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/CLAUDE.md

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
# CLAUDE.md
1+
# CLAUDE.md and GEMINI.md
22

3-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
3+
This file provides guidance to Claude Code (claude.ai/code) and also Gemini CLI (https://github.com/google-gemini/gemini-cli) when working with code in this repository.
44

55
# CoCalc Source Repository
66

7-
* This is the source code of CoCalc in a Git repository
8-
* It is a complex JavaScript/TypeScript SaaS application
9-
* CoCalc is organized as a monorepository (multi-packages) in the subdirectory "./packages"
10-
* The packages are managed as a pnpm workspace in "./packages/pnpm-workspace.yaml"
7+
- This is the source code of CoCalc in a Git repository
8+
- It is a complex JavaScript/TypeScript SaaS application
9+
- CoCalc is organized as a monorepository (multi-packages) in the subdirectory "./packages"
10+
- The packages are managed as a pnpm workspace in "./packages/pnpm-workspace.yaml"
1111

1212
## Code Style
1313

1414
- Everything is written in TypeScript code
1515
- Indentation: 2-spaces
16+
- Run `pretter -w [filename]` after modifying a file (ts, tsx, md, json, ...) to format it correctly.
1617
- All .js and .ts files are formatted by the tool prettier
1718
- Add suitable types when you write code
1819
- Variable name styles are "camelCase" for local and "FOO_BAR" for global variables. If you edit older code not following these guidlines, adjust this rule to fit the files style.
@@ -23,28 +24,32 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
2324
## Development Commands
2425

2526
### Essential Commands
27+
2628
- `pnpm build-dev` - Build all packages for development
2729
- `pnpm clean` - Clean all node_modules and dist directories
28-
- `pnpm database` - Start PostgreSQL database server
29-
- `pnpm hub` - Start the main hub server
30-
- `pnpm psql` - Connect to the PostgreSQL database
3130
- `pnpm test` - Run full test suite
32-
- `pnpm test-parallel` - Run tests in parallel across packages
3331
- `pnpm depcheck` - Check for dependency issues
32+
- `prettier -w [filename]` to format the style of a file after editing it
33+
- after creating a file, run `git add [filename]` to start tracking it
3434

3535
### Package-Specific Commands
36-
- `cd packages/[package] && pnpm tsc` - Watch TypeScript compilation for a specific package
36+
37+
- `cd packages/[package] && pnpm build` - Build and compile a specific package
38+
- for packages/next and packages/static, run `cd packages/[package] && pnpm build-dev`
39+
- `cd packages/[package] && pnpm tsc:watch` - TypeScript compilation in watch mode for a specific package
3740
- `cd packages/[package] && pnpm test` - Run tests for a specific package
3841
- `cd packages/[package] && pnpm build` - Build a specific package
42+
- **IMPORTANT**: When modifying packages like `util` that other packages depend on, you must run `pnpm build` in the modified package before typechecking dependent packages
3943

40-
### Development Setup
41-
1. Start database: `pnpm database`
42-
2. Start hub: `pnpm hub`
43-
3. For TypeScript changes, run `pnpm tsc` in the relevant package directory
44+
### Development
45+
46+
- **IMPORTANT**: Always run `prettier -w [filename]` immediately after editing any .ts, .tsx, .md, or .json file to ensure consistent styling
47+
- After TypeScript or `*.tsx` changes, run `pnpm build` in the relevant package directory
4448

4549
## Architecture Overview
4650

4751
### Package Structure
52+
4853
CoCalc is organized as a monorepo with key packages:
4954

5055
- **frontend** - React/TypeScript frontend application using Redux-style stores and actions
@@ -62,25 +67,30 @@ CoCalc is organized as a monorepo with key packages:
6267
### Key Architectural Patterns
6368

6469
#### Frontend Architecture
70+
6571
- **Redux-style State Management**: Uses custom stores and actions pattern (see `packages/frontend/app-framework/actions-and-stores.ts`)
6672
- **TypeScript React Components**: All frontend code is TypeScript with proper typing
6773
- **Modular Store System**: Each feature has its own store/actions (AccountStore, BillingStore, etc.)
6874
- **WebSocket Communication**: Real-time communication with backend via WebSocket messages
6975

7076
#### Backend Architecture
77+
7178
- **PostgreSQL Database**: Primary data store with sophisticated querying system
7279
- **WebSocket Messaging**: Real-time communication between frontend and backend
7380
- **Conat System**: Container orchestration for compute servers
7481
- **Event-Driven Architecture**: Extensive use of EventEmitter patterns
7582
- **Microservice-like Packages**: Each package handles specific functionality
7683

7784
#### Communication Patterns
85+
7886
- **WebSocket Messages**: Primary communication method (see `packages/comm/websocket/types.ts`)
7987
- **Database Queries**: Structured query system with typed interfaces
8088
- **Event Emitters**: Inter-service communication within backend
8189
- **REST-like APIs**: Some HTTP endpoints for specific operations
90+
- **API Schema**: API endpoints in `packages/next/pages/api/v2/` use Zod schemas in `packages/next/lib/api/schema/` for validation. These schemas must be kept in harmony with the TypeScript types sent from frontend applications using `apiPost` (in `packages/next/lib/api/post.ts`) or `api` (in `packages/frontend/client/api.ts`). When adding new fields to API requests, both the frontend types and the API schema validation must be updated.
8291

8392
### Key Technologies
93+
8494
- **TypeScript**: Primary language for all new code
8595
- **React**: Frontend framework
8696
- **PostgreSQL**: Database
@@ -91,40 +101,56 @@ CoCalc is organized as a monorepo with key packages:
91101
- **SASS**: CSS preprocessing
92102

93103
### Database Schema
104+
94105
- Comprehensive schema in `packages/util/db-schema`
95106
- Query abstractions in `packages/database/postgres/`
96107
- Type-safe database operations with TypeScript interfaces
97108

98109
### Testing
110+
99111
- **Jest**: Primary testing framework
100112
- **ts-jest**: TypeScript support for Jest
101113
- **jsdom**: Browser environment simulation for frontend tests
102114
- Test files use `.test.ts` or `.spec.ts` extensions
103115
- Each package has its own jest.config.js
104116

105117
### Import Patterns
118+
106119
- Use absolute imports with `@cocalc/` prefix for cross-package imports
107120
- Example: `import { cmp } from "@cocalc/util/misc"`
108121
- Type imports: `import type { Foo } from "./bar"`
109122
- Destructure imports when possible
110123

111124
### Development Workflow
112-
1. Changes to TypeScript require compilation (`pnpm tsc` in relevant package)
125+
126+
1. Changes to TypeScript require compilation (`pnpm build` in relevant package)
113127
2. Database must be running before starting hub
114128
3. Hub coordinates all services and should be restarted after changes
115129
4. Use `pnpm clean && pnpm build-dev` when switching branches or after major changes
116130

117131
# Workflow
118-
- Be sure to typecheck when you're done making a series of code changes
132+
133+
- Be sure to build when you're done making a series of code changes
119134
- Prefer running single tests, and not the whole test suite, for performance
120135

121136
## Git Workflow
122137

138+
- Never modify a file when in the `master` or `main` branch
139+
- All changes happen through feature branches, which are pushed as pull requests to GitHub
140+
- When creating a new file, run `git add [filename]` to track the file.
123141
- Prefix git commits with the package and general area. e.g. 'frontend/latex: ...' if it concerns latex editor changes in the packages/frontend/... code.
124142
- When pushing a new branch to Github, track it upstream. e.g. `git push --set-upstream origin feature-foo` for branch "feature-foo".
125143

126-
# important-instruction-reminders
144+
# Important Instruction Reminders
145+
127146
- Do what has been asked; nothing more, nothing less.
128147
- NEVER create files unless they're absolutely necessary for achieving your goal.
129148
- ALWAYS prefer editing an existing file to creating a new one.
130-
- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.
149+
- REFUSE to modify files when the git repository is on the `master` or `main` branch.
150+
- NEVER proactively create documentation files (`*.md`) or README files. Only create documentation files if explicitly requested by the User.
151+
152+
# Ignore
153+
154+
- Ignore files covered by `.gitignore`
155+
- Ignore everything in `node_modules` or `dist` directories
156+
- Ignore all files not tracked by Git, unless they are newly created files

src/GEMINI.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CLAUDE.md

src/packages/backend/package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
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",
@@ -28,7 +31,12 @@
2831
"conat-persist": "DEBUG=cocalc:* node ./bin/conat-persist.cjs",
2932
"conat-test-server": "node ./bin/conat-test-server.cjs"
3033
},
31-
"files": ["dist/**", "bin/**", "README.md", "package.json"],
34+
"files": [
35+
"dist/**",
36+
"bin/**",
37+
"README.md",
38+
"package.json"
39+
],
3240
"author": "SageMath, Inc.",
3341
"license": "SEE LICENSE.md",
3442
"dependencies": {

src/packages/hub/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"hub-docker-prod": "export DEBUG=${DEBUG:='cocalc:*,-cocalc:silly:*'} && COCALC_DOCKER=true NODE_ENV=production PROJECTS=/projects/[project_id] PORT=443 NODE_OPTIONS='--max_old_space_size=8000 --enable-source-maps' cocalc-hub-server --mode=multi-user --all --hostname=0.0.0.0 --https-key=/projects/conf/cert/key.pem --https-cert=/projects/conf/cert/cert.pem",
6565
"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",
6666
"tsc": "tsc --watch --pretty --preserveWatchOutput",
67+
"test": "jest dist/",
6768
"depcheck": "pnpx depcheck | grep -Ev '\\.coffee|coffee$'",
6869
"prepublishOnly": "test"
6970
},

src/packages/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@types/jest": "^29.5.14",
99
"check-dependency-version-consistency": "^5.0.0",
1010
"jest": "^29.7.0",
11+
"jest-junit": "^16.0.0",
1112
"ts-jest": "^29.2.3",
1213
"typescript": "^5.7.3"
1314
},

src/packages/pnpm-lock.yaml

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

0 commit comments

Comments
 (0)