Skip to content

Commit

Permalink
Feat/arm64 - integration test with test containers to test docker bui…
Browse files Browse the repository at this point in the history
…ld and run (#125)


* Test if docker builds and runs using test container and integration test

* Visualiser service scaled to 0 in compose file, Readme updated

* Updating version to 0.3.11

---------

Co-authored-by: dc-autobot[bot] <181364585+dc-autobot[bot]@users.noreply.github.com>
  • Loading branch information
syedhasandigi and dc-autobot[bot] authored Jan 22, 2025
1 parent ed8e497 commit a37cc99
Show file tree
Hide file tree
Showing 13 changed files with 1,080 additions and 54 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
}
EOF
sudo service apparmor reload # reload AppArmor profiles to include the new one
tests: '["test:unit"]'
env_vars: |
{
"TMPDIR": "${{ github.workspace }}"
Expand Down Expand Up @@ -68,8 +67,8 @@ jobs:
- static-checks-npm
uses: digicatapult/shared-workflows/.github/workflows/build-docker.yml@main
with:
push_dockerhub: false
push_ghcr: false
push_dockerhub: true
push_ghcr: true
permissions:
packages: write
contents: write
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ jobs:
include <tunables/global>
profile chrome $CHROME_PUPPETEER_PATH flags=(unconfined) {
userns,
# Site-specific additions and overrides. See local/README for details.
include if exists <local/chrome>
}
EOF
sudo service apparmor reload # reload AppArmor profiles to include the new one
tests: '["test:unit"]'
env_vars: |
{
"TMPDIR": "${{ github.workspace }}"
Expand Down Expand Up @@ -66,3 +66,4 @@ jobs:
permissions:
packages: write
contents: write

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ obj
.vscode/*
/test-results/
/playwright-report/
/playwright/.cache/
/playwright/.cache/
*.zip
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ ENV PPTRUSER_UID=10042
ENV NODE_OPTIONS="--no-warnings"
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
ENV CHROME_PUPPETEER_PATH=/usr/bin/chromium

COPY sample ./sample

RUN apt-get update && apt-get install -y --no-install-recommends chromium
RUN apt-get update && apt-get install -y chromium --no-install-recommends

RUN groupadd -r pptruser && useradd -u $PPTRUSER_UID -rm -g pptruser -G audio,video pptruser

Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,22 @@ By default, validation ignores `ResolutionException`s that occur when parsing a
dtdl-visualiser validate -p sample/energygrid -r
```

## Docker Compose

To bring up the `postgres` database service on port `5432`, run
```
docker compose up
```

To bring up both the `postgres` database and the `dtdl-visualiser` service in docker you may run
```
docker compose up --scale dtdl-visualiser=1
```
The service will be available on `http://localhost:3000`

## Docker

The application can be run in Docker. `sample/energygrid` is automatically parsed at start up. **The image runs as `amd64` - it is very slow when emulated by Rosetta**.
The application can be run in Docker. `sample/energygrid` is automatically parsed at start up.

`docker build -t dtdl-visualiser .` and run with `docker run -p 3000:3000 dtdl-visualiser`.

Expand All @@ -91,6 +104,15 @@ The application can be run in Docker. `sample/energygrid` is automatically parse
| DB_PASSWORD | n | `postgres` | The database password |
| DB_PORT | n | `5432` | The database port number |

## Database migrations

To migrate up the database started by `docker compose`, run locally
```
npm run db:migrate
```

If you have started both the database and the `dtdl-visualiser` service with `docker compose`, the database will will already be migrated

## Testing

This repository consists of two test types: [**e2e**, **unit**] and we are using a combination of `mocha`, `chai` and `sinon` frameworks.
Expand Down
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ services:
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
- POSTGRES_DB=dtdl-visualisation-tool
dtdl-visualiser:
container_name: dtdl-visualiser
depends_on:
- postgres-dtdl-visualisation-tool
ports:
- 3000:3000
build:
dockerfile: ./Dockerfile
scale: 0
environment:
- DB_HOST=postgres-dtdl-visualisation-tool
- DB_NAME=dtdl-visualisation-tool
- DB_USERNAME=postgres
- DB_PASSWORD=postgres
- DB_PORT=5432
command: >
sh -c "
npx knex migrate:latest --env production
dtdl-visualiser parse -p /sample/energygrid"
volumes:
postgres-dtdl-visualisation-tool:
Loading

0 comments on commit a37cc99

Please sign in to comment.