Skip to content

Commit

Permalink
test: init test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
albanm committed Sep 19, 2022
1 parent 87bdcfa commit 1ad1c5c
Show file tree
Hide file tree
Showing 16 changed files with 1,221 additions and 118 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ jobs:
- name: Checkout git repository
uses: actions/checkout@v2

# no need to work on a cache here, it is not faster than pulling
# instead work on moving to some images hosted on ghcr.io, it is the fastest
- name: Run test dependencies
run: |
NO_UI=true docker-compose --profile test up -d
docker ps
- name: Prepare docker image tags
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
Expand All @@ -29,6 +36,8 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host

- name: Login to Github container registry
uses: docker/login-action@v1
Expand All @@ -50,9 +59,14 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
allow: network.host
network: host
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Stop test dependencies
run: docker-compose stop

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

Expand All @@ -62,3 +76,4 @@ jobs:
- name: Send Keel notification to koumoul.com
run: |
curl -s --fail --show-error -X POST https://keel.admin.koumoul.com/v1/webhooks/native -u ${{ secrets.KEEL_PROD_USER }}:${{ secrets.KEEL_PROD_PASSWORD }} -d '{"name": "ghcr.io/${{ github.repository }}", "tag": "${{ steps.docker_meta.outputs.version }}"}'
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RUN npm run build && \
# Check quality
ADD .gitignore .gitignore
RUN npm run lint
RUN npm run test

# Cleanup /webapp/node_modules so it can be copied by next stage
RUN npm prune --production
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Portals manager for data-fair.
Install dependencies and launch service dependencies with docker-compose:

npm install
docker-compose up -d
npm run dev-deps

Run the 2 development servers with these commands in separate shells:

Expand Down
1 change: 1 addition & 0 deletions config/default.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
publicUrl: 'http://localhost:6200',
port: 6200,
dataDir: './data',
directoryUrl: 'http://localhost:6200/simple-directory',
dataFairUrl: 'http://localhost:6200/data-fair',
openapiViewerUrl: 'http://localhost:6200/openapi-viewer',
Expand Down
7 changes: 7 additions & 0 deletions config/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
dataDir: './data/test',
directoryUrl: 'http://localhost:8080',
notifyUrl: 'http://localhost:6200/notify',
privateNotifyUrl: 'http://localhost:8088',
notifyWSUrl: 'ws://localhost:8088'
}
50 changes: 33 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
version: '3'
services:
sd:
profiles:
- dev
- test
image: ghcr.io/data-fair/simple-directory:master
ports:
- 6201:8080
- 1080:1080
- 1025:1025
network_mode: host
environment:
- ADMINS=["[email protected]"]
- PUBLIC_URL=http://localhost:6200/simple-directory
- MAILDEV_ACTIVE=true
- STORAGE_TYPE=file
- NUXT_BUILD_BLOCKING=false
- NO_UI=${NO_UI}
- ROLES_DEFAULTS=["admin", "contrib", "user"]
- PROMETHEUS_ACTIVE=false
- NUXT_BUILD_BLOCKING=false
- NO_UI=${NO_UI}
- AUTHRATELIMIT_ATTEMPTS=200
volumes:
- ./test/resources/users.json:/webapp/data/users.json
- ./test/resources/organizations.json:/webapp/data/organizations.json

notify:
profiles:
- dev
- test
image: ghcr.io/data-fair/notify:master
network_mode: host
environment:
- PORT=8088
- PUBLIC_URL=http://localhost:6200/notify
- DIRECTORY_URL=http://localhost:6200/simple-directory
- SECRET_NOTIFICATIONS=secret-notifications
- SECRET_SENDMAILS=secret-sendmails
- PROMETHEUS_ACTIVE=false

data-fair:
profiles:
- dev
image: ghcr.io/data-fair/data-fair:master
restart: on-failure:10
network_mode: host
environment:
- PORT=6201
- DEBUG=files
- MONGO_URL=mongodb://localhost:27017/data-fair
- OPENAPI_VIEWER_URL=http://localhost:6200/openapi-viewer/
Expand All @@ -37,35 +55,33 @@ services:
# - EXTRA_NAV_ITEMS='[{"id": "processings","can":"contrib", "iframe": "https://staging-koumoul.com/s/data-fair-processings/embed/processings", "icon": "mdi-cog-transfer-outline", "title": "Traitements périodiques"},{"id": "portal","href": "https://data.staging-koumoul.com", "icon": "mdi-presentation", "title": "Portail de données"}]'
- PROMETHEUS_ACTIVE=false

notify:
image: ghcr.io/data-fair/notify:master
network_mode: host
environment:
- PORT=8088
- PUBLIC_URL=http://localhost:6200/notify
- DIRECTORY_URL=http://localhost:6200/simple-directory
- SECRET_NOTIFICATIONS=secret-notifications
- SECRET_SENDMAILS=secret-sendmails
- PROMETHEUS_ACTIVE=false

elasticsearch:
profiles:
- dev
image: ghcr.io/data-fair/elasticsearch:7.17.1
ports:
- 9200:9200
environment:
- discovery.type=single-node

mongo:
profiles:
- dev
- test
image: mongo:4.2
ports:
- 27017:27017

openapi-viewer:
profiles:
- dev
image: koumoul/openapi-viewer:1
ports:
- 6202:8080

capture:
profiles:
- dev
image: ghcr.io/data-fair/capture:master
network_mode: host
shm_size: '1gb'
Expand Down
Loading

0 comments on commit 1ad1c5c

Please sign in to comment.