Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

92 - Execute e2e tests in GitHub action #131

Merged
merged 19 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 52 additions & 36 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,57 @@ name: test

on: push

env:
E2E_DATAVERSE_IMAGE_TAG: unstable

jobs:
# Temporarily commented out, until we set up a suitable e2e environment for running GitHub actions
# e2e:
# runs-on: ubuntu-latest
# environment: e2e

# steps:
# - uses: actions/checkout@v3

# - uses: actions/setup-node@v3
# with:
# node-version: 18
# cache: 'npm'

# - name: Install Dependencies
# run: rm package-lock.json && npm install

# - name: Build Dataverse Design System
# working-directory: packages/design-system
# run: npm run build

# - name: Create and populate .env file
# env:
# DATAVERSE_BACKEND_URL: ${{ secrets.DATAVERSE_BACKEND_URL }}
# run: |
# touch .env
# echo VITE_DATAVERSE_BACKEND_URL="$DATAVERSE_BACKEND_URL" >> .env
# shell: bash

# - name: Cypress run
# uses: cypress-io/github-action@v4
# with:
# build: npm run build
# start: npm run preview
# wait-on: 'npx wait-on --timeout 60000 http://localhost:5173'
e2e:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'

- name: Create .npmrc
run: |
cp .npmrc.example .npmrc
sed -i -e 's/<YOUR_GITHUB_AUTH_TOKEN>/${{ secrets.GITHUB_TOKEN }}/g' .npmrc

- name: Install Dependencies
run: npm install

- name: Build Dataverse Design System
working-directory: packages/design-system
run: npm run build

- name: Create and populate .env file
env:
DATAVERSE_BACKEND_URL: 'http://localhost:8000'
run: |
touch .env
echo VITE_DATAVERSE_BACKEND_URL="$DATAVERSE_BACKEND_URL" >> .env
shell: bash

- name: Update registry for the containerized development environment
working-directory: dev-env
run: |
sed -i~ '/^REGISTRY=/s/=.*/=docker.io/' .env
shell: bash

- name: Start containers
working-directory: dev-env
run: ./run-env.sh "$E2E_DATAVERSE_IMAGE_TAG"

- name: Wait for containers to be ready
run: timeout 300s sh -c 'while ! docker logs dev_dataverse_bootstrap 2>&1 | grep -q "your instance has been configured"; do sleep 2; done'

- name: Run e2e tests
run: npm run test:e2e
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it works! Great!

        Spec                                              Tests  Passing  Failing  Pending  Skipped  
  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ ✔  integration/datasets/DatasetJSDatav      00:24        4        4        -        -        - │
  │    erseRepository.spec.ts                                                                      │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ✔  e2e/sections/dataset/Dataset.spec.t      00:24        6        6        -        -        - │
  │    sx                                                                                          │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ✔  e2e/sections/hello-dataverse/HelloD      00:12        3        3        -        -        - │
  │    ataverse.spec.ts                                                                            │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ✔  integration/info/infrastructure/rep      00:04        1        1        -        -        - │
  │    ositories/DataverseInfoJSDataverseR                                                         │
  │    epository.spec.ts                                                                           │
  ├────────────────────────────────────────────────────────────────────────────────────────────────┤
  │ ✔  integration/users/infrastructure/re      00:07        2        2        -        -        - │
  │    positories/UserJSDataverseRepositor                                                         │
  │    y.spec.ts                                                                                   │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
    ✔  All specs passed!                        01:12       16       16        -        -        -  


component:
runs-on: ubuntu-latest

Expand All @@ -54,7 +70,7 @@ jobs:
sed -i -e 's/<YOUR_GITHUB_AUTH_TOKEN>/${{ secrets.GITHUB_TOKEN }}/g' .npmrc

- name: Install Dependencies
run: rm package-lock.json && npm install
run: npm install

- name: Build Dataverse Design System
working-directory: packages/design-system
Expand Down Expand Up @@ -108,7 +124,7 @@ jobs:
sed -i -e 's/<YOUR_GITHUB_AUTH_TOKEN>/${{ secrets.GITHUB_TOKEN }}/g' .npmrc

- name: Install Dependencies
run: rm package-lock.json && npm install
run: npm install

- name: Build Dataverse Design System
working-directory: packages/design-system
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ There is an Nginx reverse proxy container on top of the frontend and backend con
Inside the `dev-env` folder, run the following command:

```
./run-env.sh <dataverse_branch_name>
./run-env.sh <dataverse_image_tag>
```

As the script argument, add the name of the Dataverse backend branch you want to deploy.
As the script argument, add the name of the Dataverse image tag you want to deploy.

Note that both the branch and the associated tag in the docker registry must to be pre pushed, otherwise the script will fail.
Note that the image tag in the docker registry must to be pre pushed, otherwise the script will fail.

If you are running the script for the first time, it may take a while, since `npm install` has to install all the dependencies. This can also happen if you added new dependencies to package.json.

Expand Down
2 changes: 1 addition & 1 deletion dev-env/docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ services:
dev_dataverse:
container_name: 'dev_dataverse'
hostname: dataverse
image: ${REGISTRY}/gdcc/dataverse:${DATAVERSE_BRANCH_NAME}
image: ${REGISTRY}/gdcc/dataverse:${DATAVERSE_IMAGE_TAG}
restart: on-failure
user: payara
environment:
Expand Down
4 changes: 2 additions & 2 deletions dev-env/run-env.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env bash

export DATAVERSE_BRANCH_NAME=$1
export DATAVERSE_IMAGE_TAG=$1

# To avoid timeout issues on frontend container startup
export COMPOSE_HTTP_TIMEOUT=200

# Timeout for Dataverse bootstrap configbaker
export DATAVERSE_BOOTSTRAP_TIMEOUT="5m"

echo "INFO - Setting up Dataverse on branch ${DATAVERSE_BRANCH_NAME}..."
echo "INFO - Setting up Dataverse on image tag ${DATAVERSE_IMAGE_TAG}..."

echo "INFO - Removing current environment if exists..."
./rm-env.sh
Expand Down