Skip to content

fix: write WebID turtle to temp files before curling; apply same fix … #8

fix: write WebID turtle to temp files before curling; apply same fix …

fix: write WebID turtle to temp files before curling; apply same fix … #8

name: Solid Specification Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
spec-tests:
name: CTH (ubuntu)
runs-on: ubuntu-latest
steps:
- name: Checkout solid-community-rs
uses: actions/checkout@v4
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust build artefacts
uses: Swatinem/rust-cache@v2
- name: Install Podman
run: |
sudo apt-get update -qq
sudo apt-get install -y podman
- name: Build server (release)
run: cargo build --release -p cli
- name: Start solid-community-rs
shell: bash
run: |
./target/release/cli \
--port 3000 \
--host 0.0.0.0 \
--base-url http://127.0.0.1:3000/ &
echo "SERVER_PID=$!" >> "$GITHUB_ENV"
- name: Wait for server
shell: bash
run: |
for i in $(seq 1 30); do
curl --silent --fail --output /dev/null http://127.0.0.1:3000/ && break
echo "Waiting... ($i)"
sleep 1
done
curl --silent --fail --output /dev/null http://127.0.0.1:3000/ \
|| (echo "Server never became ready" && exit 1)
- name: Seed WebID profile documents
shell: bash
run: |
# Write Turtle cards to temp files to avoid shell quoting issues,
# then PUT them onto the server via curl --data-binary @file.
cat > /tmp/alice-card.ttl <<'TTL'
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://127.0.0.1:3000/alice/profile/card#me>
a foaf:Person ;
foaf:name "Alice" .
TTL
cat > /tmp/bob-card.ttl <<'TTL'
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://127.0.0.1:3000/bob/profile/card#me>
a foaf:Person ;
foaf:name "Bob" .
TTL
for USER in alice bob; do
echo "--- seeding ${USER} ---"
# Create parent containers (ignore errors if they already exist)
curl --silent --output /dev/null \
--request POST \
--header 'Content-Type: text/turtle' \
--header "Slug: ${USER}" \
http://127.0.0.1:3000/ || true
curl --silent --output /dev/null \
--request POST \
--header 'Content-Type: text/turtle' \
--header 'Slug: profile' \
http://127.0.0.1:3000/${USER}/ || true
# PUT the WebID card from the temp file
HTTP_STATUS=$(curl --silent --output /dev/null --write-out "%{http_code}" \
--request PUT \
--header 'Content-Type: text/turtle' \
--data-binary @/tmp/${USER}-card.ttl \
http://127.0.0.1:3000/${USER}/profile/card)
echo "PUT ${USER}/profile/card -> HTTP ${HTTP_STATUS}"
if [[ "$HTTP_STATUS" != "200" && "$HTTP_STATUS" != "201" && "$HTTP_STATUS" != "204" ]]; then
echo "ERROR: unexpected status ${HTTP_STATUS} seeding ${USER} WebID"
exit 1
fi
done
# Verify both cards are readable
echo "--- verifying ---"
curl --silent --fail --header 'Accept: text/turtle' \
http://127.0.0.1:3000/alice/profile/card && echo "alice OK"
curl --silent --fail --header 'Accept: text/turtle' \
http://127.0.0.1:3000/bob/profile/card && echo "bob OK"
- name: Clone specification-tests
shell: bash
run: |
git clone --depth=1 \
https://github.com/solid-contrib/specification-tests.git \
specification-tests
- name: Write config/application.yaml
shell: bash
run: |
mkdir -p config
cat > config/application.yaml <<'YAML'
subjects: /app/config/test-subjects.ttl
sources:
- https://solidproject.org/TR/protocol
- https://github.com/solid-contrib/specification-tests/blob/main/protocol/solid-protocol-test-manifest.ttl
- https://github.com/solid-contrib/specification-tests/blob/main/protocol/requirement-comments.ttl
mappings:
- prefix: https://github.com/solid-contrib/specification-tests/blob/main
path: /data
YAML
- name: Write config/test-subjects.ttl
shell: bash
run: |
cat > config/test-subjects.ttl <<'TTL'
@prefix solid-test: <https://github.com/solid/conformance-test-harness/vocab#> .
@prefix earl: <http://www.w3.org/ns/earl#> .
@prefix doap: <http://usefulinc.com/ns/doap#> .
<https://github.com/tuned-org-uk/solid-community-rs#server>
a earl:Software, earl:TestSubject ;
doap:name "solid-community-rs" ;
doap:programming-language "Rust" ;
doap:homepage <https://github.com/tuned-org-uk/solid-community-rs> ;
solid-test:skip "acp wac authentication" ;
solid-test:serverRoot <http://127.0.0.1:3000/> .
TTL
- name: Write CTH env file
shell: bash
run: |
cat > cth.env <<'ENV'
SERVER_ROOT=http://127.0.0.1:3000/
users.alice.webid=http://127.0.0.1:3000/alice/profile/card#me
users.alice.username=alice
users.alice.password=unused
users.bob.webid=http://127.0.0.1:3000/bob/profile/card#me
users.bob.username=bob
users.bob.password=unused
ORIGIN=http://example.org
CTH_TIMEOUT=10000
ENV
- name: Show generated config (debug)
shell: bash
run: |
echo "=== test-subjects.ttl ==="
cat config/test-subjects.ttl
echo "=== cth.env ==="
cat cth.env
- name: Create output directories
shell: bash
run: mkdir -p reports target
- name: Pull CTH image
run: podman pull solidproject/conformance-test-harness
- name: Run CTH
shell: bash
run: |
podman run --rm \
--network=host \
--env-file="$(pwd)/cth.env" \
--volume "$(pwd)/specification-tests:/data:ro" \
--volume "$(pwd)/config:/app/config:ro" \
--volume "$(pwd)/reports:/reports" \
--volume "$(pwd)/target:/app/target" \
solidproject/conformance-test-harness \
--output=/reports \
--target=https://github.com/tuned-org-uk/solid-community-rs#server \
--skip-teardown
- name: Upload CTH reports
if: always()
uses: actions/upload-artifact@v4
with:
name: cth-reports-ubuntu
path: reports/
if-no-files-found: warn
- name: Stop server
if: always()
shell: bash
run: kill "$SERVER_PID" 2>/dev/null || true