Skip to content

Commit

Permalink
Used exec to run tests in existing container
Browse files Browse the repository at this point in the history
The idea here is to simplify and streamline the dev stack. So rather than a
separate docker-compose file for testing, and spinning up new containers we can
run the tests in the existing activitypub container we use, which also has the
local src files mounted.

`yarn dev` will start the stack as usual, but now it does it as a daemon, which
means it runs in the background. We also pass the --no-recreate flag which
ensures that running it multiple times doesn't destroy the container and is
essentially idempotent.

`yarn stop` will bring the stack down

`yarn logs` will tail the activitypub logs for the container

`yarn test` uses the `exec` docker compose command to run the tests, and also
calls `yarn dev` first - which makes sure the stack is running if it wasn't
already.

`yarn fix` will remove local containers for activitypub and nginx and then rebuild them
  • Loading branch information
allouis authored Jul 30, 2024
1 parent 1e30707 commit 593a935
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ jobs:
image: $IMAGE_NAME:$DOCKER_METADATA_OUTPUT_VERSION" > docker-compose.ci.yml
- name: "Run tests"
run: |
docker compose -f docker-compose.testing.yml -f docker-compose.ci.yml up --abort-on-container-exit --exit-code-from activitypub
run: yarn test

- name: Login to GAR
uses: docker/login-action@v3
Expand Down
31 changes: 0 additions & 31 deletions docker-compose.testing.yml

This file was deleted.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
"main": "src/app.ts",
"type": "module",
"scripts": {
"dev": "docker compose up",
"dev": "docker compose up -d --no-recreate",
"stop": "docker compose down",
"fix": "docker compose rm activitypub nginx -sf && docker compose build activitypub nginx",
"logs": "docker compose logs activitypub -f",
"test": "yarn dev && docker compose exec activitypub yarn test:all",
"test:types": "tsc --noEmit",
"test:unit": "c8 --src src --all --reporter text --reporter cobertura mocha -r tsx './src/**/*.unit.test.ts'",
"test:integration": "c8 --src src --all --reporter text --reporter cobertura mocha -r tsx './src/**/*.integration.test.ts'",
"test:code": "c8 --src src --all --reporter text --reporter cobertura mocha -r tsx './src/**/*.test.ts'",
"test:all": "yarn test:types && yarn test:code",
"test": "docker compose -f docker-compose.testing.yml up --abort-on-container-exit --exit-code-from activitypub",
"lint:code": "eslint *.js lib/ --ext .js --cache",
"lint": "yarn lint:code"
},
Expand Down

0 comments on commit 593a935

Please sign in to comment.