Files
tasknote/tools/tools.md
T
CopilotGitHubcopilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>RMCamposrmcampos
1aa8ded9b3 feat: Integrate Cypress for E2E authentication testing (#39)
* Initial plan

* feat: add Cypress E2E testing for auth flows

Agent-Logs-Url: https://github.com/RMCampos/tasknote/sessions/f3b4e747-3e09-4b6c-8b4c-336cf45b59c4

Co-authored-by: RMCampos <2219519+RMCampos@users.noreply.github.com>

* fix: use regex intercepts and unique emails in Cypress auth tests

Agent-Logs-Url: https://github.com/RMCampos/tasknote/sessions/2a1225d9-9412-459e-bc97-93303454a461

Co-authored-by: RMCampos <2219519+RMCampos@users.noreply.github.com>

* fix: use PUT method for sign-up intercepts in Cypress auth tests

Agent-Logs-Url: https://github.com/RMCampos/tasknote/sessions/bda14dfc-a30d-4c01-aa74-e8c2690072e3

Co-authored-by: RMCampos <2219519+RMCampos@users.noreply.github.com>

* chore: update tools.md file to include sql command

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: RMCampos <2219519+RMCampos@users.noreply.github.com>
Co-authored-by: Ricardo Campos <ricardompcampos@gmail.com>
2026-05-06 17:21:17 -03:00

4.4 KiB

Tools

All kind of tools and useful links and commands can be found here!

Building locally

Tasknote-web - Frontend Web App:

Before building, you need define some env vars:

export VITE_BUILD=<branch-name-and-PR-number>

Then you can call the install and build scripts (from the client folder):

npm ci --ignore-scripts --no-update-notifier --omit=dev \
 && npm run build \
 && rm -rf node_modules

If you want to build with Docker:

docker build --no-cache \
 --build-arg VITE_BUILD="v999-$(date '+%Y-%m-%d-%H%M%S')" \
 --build-arg SOURCE_PR="v999-123456789-$(date '+%Y-%m-%d-%H%M%S')" \
 -t tasknote-web:candidate \
 ./client

That's it!

Tasknote-api - Backend REST API:

For the backend there's a Dockerfile ready, just run (from the project root):

docker build --no-cache \
 --build-arg BUILD="v999-$(date '+%Y-%m-%d-%H%M%S')" \
 --build-arg SOURCE_PR="v999-123456789-$(date '+%Y-%m-%d-%H%M%S')" \
 -t tasknote-api:candidate \
 ./server

That's it!

Running with Docker

DB:

docker run -d -p 5432:5432 --rm \
  --name db \
  -e POSTGRES_DB=$POSTGRES_DB \
  -e POSTGRES_USER=$POSTGRES_USER \
  -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD \
  postgres:15.8-bookworm

Tasknote-api:

docker run -d -p 8585:8585 --rm \
  --name tasknote-api \
  -e POSTGRES_DB=$POSTGRES_DB \
  -e POSTGRES_USER=$POSTGRES_USER \
  -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD \
  -e POSTGRES_PORT=$POSTGRES_PORT \
  -e POSTGRES_HOST=$POSTGRES_HOST \
  -e CORS_ALLOWED_ORIGINS=$CORS_ALLOWED_ORIGINS \
  ghcr.io/ricardo-campos-org/react-typescript-todolist/tasknote-api:<PR-Number>

Build Cloud Native: ./mvnw -B package -Pnative -DskipTests

Tasknote-web:

The frontend app will run on Nginx.

Interacting with GitHub Package and Container Registry

Login in:

export CR_PAT=YOUR_TOKEN
echo $CR_PAT | docker login ghcr.io -u RMCampos --password-stdin

Pulling images:

docker pull ghcr.io/ricardo-campos-org/react-typescript-todolist/tasknote-web:50
docker pull ghcr.io/ricardo-campos-org/react-typescript-todolist/tasknote-api:50

Pushing images:

docker push ghcr.io/ricardo-campos-org/react-typescript-todolist/tasknote-api:316
  • Get container IP
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db
  • Get reason of health check failing on a container
docker inspect --format "{{json .State.Health}}" container_name_or_id | jq

# Or to see it live
while true; do clear; docker inspect --format "{{json .State.Health}}" tasknote-api | jq; sleep 1; done
  • Extract Env value from docker image (without running)
docker inspect tasknote-web:candidate | jq -r '.[0].Config.Env[] | select(startswith("SOURCE_PR="))' | sed -n 's/SOURCE_PR=\(v[0-9]*\).*/\1/p'

Restoring DB for testing

docker run \
 --name my-postgres-db \
 -e POSTGRES_USER="<user>" \
 -e POSTGRES_PASSWORD='<password>' \
 -e POSTGRES_DB="<db-name>" \
 -p 5432:5432 \
 -d postgres
docker exec -i my-postgres-db pg_restore -U <user> -d <db-name> < 2025-04-26T20_00_00.114Z.sql

Updating packages

Node packages:

  • npm install -g npm-check-updates
  • Then run ncu and ncu -u

Angular dependencies:

  • First run: npx @angular/cli update @angular/cli @angular/core
  • Then run npx npm-check-updates -u

Build with: mvn -Pnative -DskipTests spring-boot:build-image
-Dspring-boot.build-image.imageName=rmcampos/tasknote:api-latest

Run with: docker run --rm -p 8080:8080
-e SPRING_PROFILES_ACTIVE=native
-e POSTGRES_HOST=localhost
-e POSTGRES_PORT=5432
-e POSTGRES_DB=tasknote
-e POSTGRES_USER=tasknoteuser
-e POSTGRES_PASSWORD=default
-e SECURITY_KEY=9052e499446dac5fa2d69dd07f1f6381a360c646c63d555244c3a2911494f63a
-e CORS_ALLOWED_ORIGINS=http://localhost:5000
-e SERVER_SERVLET_CONTEXT_PATH=/
--network host
docker.io/rmcampos/tasknote:api-latest

Running a single class test file

# For a single class
mvn test -P test -Dtest=YourTestClassName

# For a single class method
mvn test -P test -Dtest=YourTestClassName#method

Running SQL query from the CLI using docker

docker exec -it tasknote-db psql -U tasknoteuser -d tasknote -c "SET search_path TO tasknote; SELECT * FROM users;