Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 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
7 changes: 6 additions & 1 deletion .github/workflows/build-with-profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ jobs:
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile.fivesafes-profile
push: true
# Add the five-safes profile (via EXTRA_PROFILES_PATH) and warm its
# cache, using the shared Dockerfile's build args.
build-args: |
FIVE_SAFES_PROFILE_VERSION=five-safes-0.7.4-beta
PROFILES_ARCHIVE_URL=https://github.com/eScienceLab/rocrate-validator/archive/refs/tags/five-safes-0.7.4-beta.tar.gz
EXTRA_PROFILES_PATH=/app/extra-profiles
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Lint

on:
pull_request:
branches: [ develop ]

jobs:
ruff:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Within the RSE team we're moving to specifying the exact hash of the action we want to use, rather than only the version number (c.f.: https://github.com/UoMResearchIT/Actions/blob/20365fa75ab643043ec188ef0b67fd5e537d326c/reuse/action.yml#L67). Should we do the same here?


- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install ruff
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Lint
run: ruff check .

- name: Format check
run: ruff format --check .
15 changes: 7 additions & 8 deletions .github/workflows/test_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest requests minio docker
pip install pytest requests boto3

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we pin our pytest, requests, boto3 versions here? The most recent tests for this PR ran with pytest-9.1.0, requests-2.33.1, and boto3-1.43.29


- name: Build Docker Compose Containers
- name: Run integration tests (brings up the compose stack)
run: |
cp example.env .env
docker compose -f docker-compose-develop.yml build
pytest -s -v tests/test_integration.py

- name: Spin Up Docker Compose and Run Tests
run: pytest -s -v tests/test_integration.py

- name: Ensure that Docker Compose is Shutdown
- name: Ensure Docker Compose is shut down
if: always()
run: docker compose down
run: >
docker compose -f docker-compose-develop.yml -p cratey_integration

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need the project name string here? (-p cratey_integration)

--profile objectstore down -v || true
3 changes: 1 addition & 2 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-mock
pip install -r requirements-dev.txt

- name: Run tests (excluding integration tests)
run: |
Expand Down
38 changes: 34 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,46 @@
FROM python:3.11-slim

# Install required system packages, including git
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
# git is needed by some dependencies; wget is only used when baking a profile.
RUN apt-get update && apt-get install -y git wget && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

COPY cratey.py LICENSE /app/
COPY wsgi.py LICENSE /app/
COPY app /app/app

# Optionally fetch an extra RO-Crate profile into a normal directory. It is
# *added* to the bundled profiles at runtime via EXTRA_PROFILES_PATH.
# A plain build leaves PROFILES_ARCHIVE_URL empty
# and skips this; the "with profiles" image build passes it as --build-arg.
ARG PROFILES_ARCHIVE_URL=""
ARG FIVE_SAFES_PROFILE_VERSION=""
# Set EXTRA_PROFILES_PATH only for the profiles build (passed as a build arg).
ARG EXTRA_PROFILES_PATH=""
ENV EXTRA_PROFILES_PATH=${EXTRA_PROFILES_PATH}
ENV CACHE_PATH=/app/.rocrate-cache
RUN if [ -n "$PROFILES_ARCHIVE_URL" ]; then \
mkdir -p /app/extra-profiles && \
wget -O /tmp/profiles.tar.gz "$PROFILES_ARCHIVE_URL" && \
tar -xzf /tmp/profiles.tar.gz \
-C /app/extra-profiles \
--strip-components=3 \
"rocrate-validator-${FIVE_SAFES_PROFILE_VERSION}/rocrate_validator/profiles/five-safes-crate" && \
rm /tmp/profiles.tar.gz ; \
fi

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We can, and should, organise this RUN command better:

RUN <<EOF_PROFILES
if [ -n "$PROFILES_ARCHIVE_URL" ]; then
   mkdir -p /app/extra-profiles
   wget -O /tmp/profiles.tar.gz "$PROFILES_ARCHIVE_URL"
   tar -xzf /tmp/profiles.tar.gz
            -C /app/extra-profiles \
            --strip-components=3 \
            "rocrate-validator-${FIVE_SAFES_PROFILE_VERSION}/rocrate_validator/profiles/five-safes-crate"
   rm /tmp/profiles.tar.gz
fi
EOF_PROFILES


# Pre-populate the HTTP cache so opt-in offline validation
# (VALIDATION_OFFLINE=true) works without network at runtime.
RUN if [ -n "$EXTRA_PROFILES_PATH" ]; then \
rocrate-validator cache warm --all-profiles \
--extra-profiles-path "$EXTRA_PROFILES_PATH" --cache-path "$CACHE_PATH" ; \
else \
rocrate-validator cache warm --all-profiles --cache-path "$CACHE_PATH" ; \
fi

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as above, let's do this better:

RUN <<<EOF_PROFILES_PATH
if [ -n "$EXTRA_PROFILES_PATH" ]; then
    rocrate-validator cache warm --all-profiles \
            --extra-profiles-path "$EXTRA_PROFILES_PATH" --cache-path "$CACHE_PATH"
else
    rocrate-validator cache warm --all-profiles --cache-path "$CACHE_PATH"
fi
EOF_PROFILES_PATH


RUN useradd -ms /bin/bash flaskuser
RUN chown -R flaskuser:flaskuser /app

Expand All @@ -21,4 +50,5 @@ EXPOSE 5000

CMD ["flask", "run", "--host=0.0.0.0"]

LABEL org.opencontainers.image.source="https://github.com/eScienceLab/Cratey-Validator"
LABEL org.opencontainers.image.source="https://github.com/eScienceLab/RO-Crate-Validation-Service"
LABEL org.ro-crate-validation-service.five-safes-profile-version="${FIVE_SAFES_PROFILE_VERSION}"
39 changes: 0 additions & 39 deletions Dockerfile.fivesafes-profile

This file was deleted.

Loading
Loading