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

Merge NSQA into main #6

Merged
merged 20 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
99 changes: 99 additions & 0 deletions .github/workflows/Quality_Assessment_&_Awarding_v1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Quality_Assessment_&_Awarding_v1

on:
workflow_dispatch

jobs:

build:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Create Docker volumes
run: |
docker volume create neo4j_data
docker volume create neo4j_logs
docker volume create yprov_data

- name: Create Docker network
run: docker network create yprov_net

- name: Start Neo4j service
run: |
docker run \
--name db \
--network=yprov_net \
-p 7474:7474 -p 7687:7687 \
-d \
-v neo4j_data:/data \
-v neo4j_logs:/logs \
-v $HOME/neo4j/import:/var/lib/neo4j/import \
-v $HOME/neo4j/plugins:/plugins \
--env NEO4J_AUTH=neo4j/password \
--env NEO4J_ACCEPT_LICENSE_AGREEMENT=eval \
-e NEO4J_apoc_export_file_enabled=true \
-e NEO4J_apoc_import_file_enabled=true \
-e NEO4J_apoc_import_file_use__neo4j__config=true \
-e NEO4J_PLUGINS='["apoc"]' \
neo4j:enterprise

- name: Start API service
run: |
docker run \
--restart on-failure \
--name web \
--network=yprov_net \
-p 3000:3000 \
-d \
-v yprov_data:/app/conf \
--env USER=neo4j \
--env PASSWORD=password \
hpci/yprov:latest

- name: Wait for API to be ready
run: |
echo "Waiting for API to be ready..."
max_attempts=30
attempt=0
until [ $attempt -ge $max_attempts ]
do
if curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/api/v0/documents | grep -q "200"; then
echo "API is ready!"
break
fi
attempt=$((attempt+1))
echo "Attempt $attempt/$max_attempts: API is not ready yet. Waiting..."
sleep 10
done

- name: Set up Python environment
run: |
python3 -m pip install --upgrade pip
pip install pytest

- name: Run tests
run: |
python3 -m pytest -v

- name: Quality Tests
uses: eosc-synergy/sqaaas-assessment-action@v2
with:
repo: 'https://github.com/HPCI-Lab/yProv.git'
branch: 'main'

- name: Clean up
run: |
docker stop web
docker rm web
docker stop db
docker rm db
docker network rm yprov_net
docker volume rm neo4j_data
docker volume rm neo4j_logs
docker volume rm yprov_data
113 changes: 113 additions & 0 deletions .github/workflows/Quality_Assessment_&_Awarding_v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Quality_Assessment_&_Awarding_v2

on:
push:
branches:
- '**'


jobs:
tests:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Create Docker volumes
run: |
docker volume create neo4j_data
docker volume create neo4j_logs
docker volume create yprov_data

- name: Create Docker network
run: docker network create yprov_net

- name: Start Neo4j service
run: |
docker run \
--name db \
--network=yprov_net \
-p 7474:7474 -p 7687:7687 \
-d \
-v neo4j_data:/data \
-v neo4j_logs:/logs \
-v $HOME/neo4j/import:/var/lib/neo4j/import \
-v $HOME/neo4j/plugins:/plugins \
--env NEO4J_AUTH=neo4j/password \
--env NEO4J_ACCEPT_LICENSE_AGREEMENT=eval \
-e NEO4J_apoc_export_file_enabled=true \
-e NEO4J_apoc_import_file_enabled=true \
-e NEO4J_apoc_import_file_use__neo4j__config=true \
-e NEO4J_PLUGINS='["apoc"]' \
neo4j:enterprise

- name: Start API service
run: |
docker run \
--restart on-failure \
--name web \
--network=yprov_net \
-p 3000:3000 \
-d \
-v yprov_data:/app/conf \
--env USER=neo4j \
--env PASSWORD=password \
hpci/yprov:latest

- name: Wait for API to be ready
run: |
echo "Waiting for API to be ready..."
max_attempts=30
attempt=0
until [ $attempt -ge $max_attempts ]
do
if curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/api/v0/documents | grep -q "200"; then
echo "API is ready!"
break
fi
attempt=$((attempt+1))
echo "Attempt $attempt/$max_attempts: API is not ready yet. Waiting..."
sleep 10
done

- name: Set up Python environment
run: |
python3 -m pip install --upgrade pip
pip install pytest

- name: Run tests
run: |
python3 -m pytest -v SQA/tests/test_auth.py SQA/tests/test_documents.py

- name: Step definition for validating the workflow
uses: eosc-synergy/sqaaas-step-action@v1
with:
name: pytest-test
tool: commands
commands: pytest /app/tests/test_mock_auth.py /app/tests/test_mock_documents.py
container: hpci/yprov-sqa:mocktest

- name: SQAaaS assessment with unit testing (QC.Uni) step
uses: eosc-synergy/sqaaas-assessment-action@v2
with:
qc_uni_steps: pytest-test
repo: https://github.com/HPCI-Lab/yProv.git
branch: main

- name: Clean up
run: |
docker stop web
docker rm web
docker stop db
docker rm db
docker network rm yprov_net
docker volume rm neo4j_data
docker volume rm neo4j_logs
docker volume rm yprov_data



26 changes: 26 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cff-version: 1.2.0
message: 'If you use yProv, please cite it as below'
title: yProv
type: software
authors:
- family-names: Fiore
given-names: Sandro
email: [email protected]
affiliation: University of Trento
- family-names: Antonio
given-names: Fabrizio
email: [email protected]
affiliation: CMCC
date-released: 2025-01-14
repository-code: 'https://github.com/HPCI-Lab/yProv'
license: MIT
version: 1.1
keywords:
- provenance
- W3C Provenance
- multi-level provenance
- yProv
abstract: >-
yProv is a provenance service aimed at addressing multi-level provenance as well as reproducibility challenges in climate analytics experiments.
It allows scientists to manage provenance information compliant with the W3C PROV standard in a more structured way and navigate and explore the provenance space
across multiple dimensions, thus enabling the possibility to get coarse- or fine-grained information according to the level requested.
1 change: 1 addition & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Code of Conduct
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Contributing to yProv

Thank you for your interest in contributing to yProv!
To contribute, please follow these steps:

1. Fork the repository.
2. Make your changes in a new branch.
3. Test your changes locally.
4. Submit a pull request describing your changes.

For any questions, feel free to open an issue or contact us.

We appreciate your contributions!
20 changes: 20 additions & 0 deletions SQA/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Usa l'immagine ufficiale di Python come base
FROM python:3.9-slim

# Imposta la directory di lavoro nel container
WORKDIR /app

# Installa curl
RUN apt-get update && apt-get install -y curl

# Copia l'intero contenuto della directory del progetto nella directory di lavoro del container
COPY . .

# Assegna i permessi di esecuzione allo script 'tests.sh'
RUN chmod +x /app/tests/tests.sh

# Installa le dipendenze del progetto, se necessario
RUN pip install --no-cache-dir -r requirements.txt

# Comando di default: esegue lo script 'tests.sh'
CMD ["/app/tests/tests.sh"]
24 changes: 24 additions & 0 deletions SQA/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Test Suite and SQAaaS

The unit and mock tests are split into two files, auth and documents, respectively, to respect the division of the swagger documentation files.
To run the tests you need to start Docker Desktop locally and run the command in any folder of the project:
```
pytest
```
or if you want a more detailed output:
```
pytest -v
```

### SQAaaS

Every time a push is made to the SQA branch, the Github Action QAA file is invoked. It automatically starts the SQAaaS platform pipeline and runs mock tests inside it. Unit tests are instead run locally, so it is always necessary to start docker desktop. The file automatically generates the volumes, containers and docker network and removes them once the files have finished running. The file uses the hpci-yprov:mocktest image to run mock tests inside the SQAaaS platform, the dockerfile code is in the hpci-yprov:mocktest folder.

### Future works

The SQAaaS platform is not yet able to handle multi-container architectures like yProv, however it is working on a solution that can include a docker-compose file. This approach has already been implemented and the code is contained in the docker-compose and dockerfile files in the root folder. To run it use the commands:
```
docker-compose build --no-cache
docker-compose up
```
There is also an image that allows you to run both unit tests and mock tests inside a single container and this is contained in the hpci-yprov:1.3 folder.
49 changes: 49 additions & 0 deletions SQA/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: "3"
services:
web:
image: hpci/yprov:latest
restart: on-failure
depends_on:
- db
links:
- db
networks:
- yprov_net
ports:
- "3000:3000"
environment:
USER: neo4j
PASSWORD: password
ADDRESS: db:7687
volumes:
- yprov_data:/app/conf

db:
image: "neo4j:enterprise"
ports:
- "7474:7474"
- "7687:7687"
environment:
NEO4J_AUTH: neo4j/password
NEO4J_ACCEPT_LICENSE_AGREEMENT: eval
NEO4J_PLUGINS: '["graph-data-science"]'
volumes:
- neo4j_data:/data
- neo4j_logs:/logs
networks:
- yprov_net

test:
image: hpci/yprov-sqa:1.4
depends_on:
- web
networks:
- yprov_net

volumes:
neo4j_data:
neo4j_logs:
yprov_data:

networks:
yprov_net:
26 changes: 26 additions & 0 deletions SQA/hpci-yprov:1.3/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.9-slim

# Install dependencies
RUN apt-get update && apt-get install -y \
curl \
git \
docker.io \
docker-compose

# Work Directory
WORKDIR /app

# Clean and clone updated GitHub repo
RUN rm -rf /app/* && \
git clone --branch sqa https://github.com/HPCI-Lab/yProv.git .

# Install requirements
COPY requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt

# Make the script_dockerfile.sh script executable and run it
COPY tests.sh /app/tests.sh
RUN chmod +x /app/tests.sh

# Default command to keep the container running
CMD ["/app/tests.sh"]
Loading
Loading