Skip to content

Commit be8cf71

Browse files
authored
Merge pull request #109 from pdsinterop/cleanup/ci
Change GitHub test suite action (and cleanup `Dockerfile` and `run-solid-test-suite.sh`)
2 parents 6344e9c + 9e1e053 commit be8cf71

File tree

3 files changed

+185
-65
lines changed

3 files changed

+185
-65
lines changed

.github/workflows/ci.yml

Lines changed: 115 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,130 @@
1-
# This workflow will do a clean install of node dependencies, build the source
2-
# code and run tests across different versions of node
3-
# For more information see:
4-
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
1+
---
2+
name: Solid Test Suites
53

6-
name: CI
4+
env:
5+
# Docker Hub digest (i.e. hash) of the used Docker Images that do not have a version tag.
6+
PUBSUB_TAG: latest@sha256:35166933e3d30bde801fd156bd2f21ebba9cdeca464ebd574c6be4cdb14d35cd
7+
COOKIE_TAG: latest@sha256:c71a3947f97d96ce09823743182582e0d919738be0d4ef5c8c55a9c22c615b91
78

89
on:
910
push:
10-
branches: [ main ]
11+
branches:
12+
- main
1113
pull_request:
1214
branches: [ main ]
1315

16+
# Cancels all previous workflow runs for the same branch that have not yet completed.
17+
concurrency:
18+
# The concurrency group contains the workflow name and the branch name.
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
1422
jobs:
15-
build:
23+
# @TODO: Instead of building the docker image here, take a pre-build image and mount the code
24+
# (only build when the Dockerfile changes)
25+
build-docker-nextcloud:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Create docker tag from git reference
29+
# A tag name may only contain lower- and uppercase letters, digits, underscores, periods and dashes.
30+
run: |
31+
echo "TAG=$(echo -n "${{ github.ref_name }}" \
32+
| tr --complement --squeeze-repeats '[:alnum:]._-' '_')" \
33+
>> "${GITHUB_ENV}"
34+
35+
- uses: actions/cache@v3
36+
id: cache-solid-nextcloud-docker
37+
with:
38+
path: cache/solid-nextcloud
39+
key: solid-nextcloud-docker-${{ github.sha }}
40+
41+
- uses: actions/checkout@v3
1642

17-
runs-on: ${{ matrix.os }}
43+
- uses: docker/login-action@v2
44+
with:
45+
registry: ghcr.io
46+
username: ${{ github.actor }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
1848

49+
- name: Build Solid-Nextcloud Docker image
50+
run: |
51+
docker build \
52+
--tag "solid-nextcloud:${{ env.TAG }}" \
53+
--tag "ghcr.io/pdsinterop/solid-nextcloud:${{ env.TAG }}" \
54+
.
55+
docker push "ghcr.io/pdsinterop/solid-nextcloud:${{ env.TAG }}"
56+
mkdir -p cache/solid-nextcloud
57+
docker image save solid-nextcloud:${{ env.TAG }} --output ./cache/solid-nextcloud/${{ github.sha }}.tar
58+
59+
solid-testsuite:
1960
strategy:
61+
fail-fast: false
2062
matrix:
21-
os: [ ubuntu-latest ]
63+
test:
64+
- 'solidtestsuite/solid-crud-tests:v7.0.5'
65+
- 'solidtestsuite/web-access-control-tests:v7.1.0'
66+
- 'solidtestsuite/webid-provider-tests:v2.1.0'
67+
68+
needs:
69+
- build-docker-nextcloud
70+
71+
runs-on: ubuntu-latest
2272

2373
steps:
24-
- uses: actions/checkout@v2
25-
# Run the Solid test-suite
26-
- name: Run the Solid test suite
27-
shell: 'script -q -e -c "bash {0}"'
74+
- name: Create docker tag from git reference
75+
# A tag name may only contain lower- and uppercase letters, digits, underscores, periods and dashes.
76+
run: |
77+
echo "TAG=$(echo -n "${{ github.ref_name }}" \
78+
| tr --complement --squeeze-repeats '[:alnum:]._-' '_')" \
79+
>> "${GITHUB_ENV}"
80+
81+
- uses: actions/checkout@v3
82+
83+
- uses: actions/cache@v3
84+
id: cache-solid-nextcloud-docker
85+
with:
86+
path: cache/solid-nextcloud
87+
key: solid-nextcloud-docker-${{ github.sha }}
88+
89+
- uses: docker/login-action@v2
90+
with:
91+
registry: ghcr.io
92+
username: ${{ github.actor }}
93+
password: ${{ secrets.GITHUB_TOKEN }}
94+
95+
- name: Pull docker Images
96+
run: |
97+
docker image load --input ./cache/solid-nextcloud/${{ github.sha }}.tar
98+
docker pull michielbdejong/nextcloud-cookie:${{ env.COOKIE_TAG }}
99+
docker pull ${{ matrix.test }}
100+
docker pull ghcr.io/pdsinterop/php-solid-pubsub-server:${{ env.PUBSUB_TAG }}
101+
102+
- name: Start Docker Containers
28103
run: |
29-
bash ./run-solid-test-suite.sh
104+
docker network create testnet
105+
docker run \
106+
--detach \
107+
--interactive \
108+
--name 'pubsub' \
109+
--network=testnet \
110+
"ghcr.io/pdsinterop/php-solid-pubsub-server:${{ env.PUBSUB_TAG }}"
111+
112+
source ./run-solid-test-suite.sh
113+
startSolidNextcloud 'server' "solid-nextcloud:${{ env.TAG }}" ${{ matrix.test }}
114+
startSolidNextcloud 'thirdparty' "solid-nextcloud:${{ env.TAG }}" ${{ matrix.test }}
115+
116+
echo "COOKIE_server=${COOKIE_server}" >> "${GITHUB_ENV}"
117+
echo "COOKIE_thirdparty=${COOKIE_thirdparty}" >> "${GITHUB_ENV}"
118+
119+
- name: Run tests - ${{ matrix.test }}
120+
run: |
121+
export COOKIE_server="${{ env.COOKIE_server }}"
122+
export COOKIE_thirdparty="${{ env.COOKIE_thirdparty }}"
123+
124+
docker run -i --rm --network=testnet \
125+
--name tester \
126+
--env COOKIE="$COOKIE_server" \
127+
--env COOKIE_ALICE="$COOKIE_server" \
128+
--env COOKIE_BOB="$COOKIE_thirdparty" \
129+
--env-file ./env-vars-testers.list \
130+
${{ matrix.test }}

Dockerfile

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
FROM nextcloud:24.0.1
2-
COPY site.conf /etc/apache2/sites-enabled/000-default.conf
3-
RUN a2enmod ssl
4-
RUN mkdir /tls
5-
RUN openssl req -new -x509 -days 365 -nodes \
6-
-out /tls/server.cert \
7-
-keyout /tls/server.key \
8-
-subj "/C=RO/ST=Bucharest/L=Bucharest/O=IT/CN=www.example.ro"
2+
93
RUN apt-get update && apt-get install -yq \
10-
git \
11-
vim \
12-
sudo
13-
WORKDIR /install
14-
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
15-
RUN php composer-setup.php
16-
RUN php -r "unlink('composer-setup.php');"
17-
ADD ./solid /usr/src/nextcloud/apps/solid
18-
# Run composer:
19-
WORKDIR /usr/src/nextcloud/apps/solid
20-
RUN ls
21-
RUN php /install/composer.phar update
22-
RUN php /install/composer.phar install --no-dev --prefer-dist
4+
git \
5+
sudo \
6+
vim \
7+
zip \
8+
&& rm -rf /var/lib/apt/lists/* \
9+
&& a2enmod ssl \
10+
&& mkdir /tls \
11+
&& openssl req -new -x509 -days 365 -nodes \
12+
-keyout /tls/server.key \
13+
-out /tls/server.cert \
14+
-subj "/C=RO/ST=Bucharest/L=Bucharest/O=IT/CN=www.example.ro"
15+
16+
COPY solid/ /usr/src/nextcloud/apps/solid
17+
COPY init.sh /
18+
COPY init-live.sh /
19+
COPY site.conf /etc/apache2/sites-enabled/000-default.conf
20+
21+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
22+
RUN composer install --working-dir=/usr/src/nextcloud/apps/solid --no-dev --prefer-dist \
23+
&& rm /usr/local/bin/composer
24+
2325
WORKDIR /var/www/html
24-
ADD init.sh /
25-
ADD init-live.sh /
2626
EXPOSE 443

run-solid-test-suite.sh

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
23
set -e
34

45
function setup {
5-
docker network create testnet
6-
docker build -t solid-nextcloud .
76
docker build -t pubsub-server https://github.com/pdsinterop/php-solid-pubsub-server.git#main
7+
docker build -t solid-nextcloud .
8+
9+
docker network create testnet
10+
811
docker pull michielbdejong/nextcloud-cookie
9-
docker pull solidtestsuite/webid-provider-tests:v2.1.0
10-
docker tag solidtestsuite/webid-provider-tests:v2.1.0 webid-provider-tests
1112
docker pull solidtestsuite/solid-crud-tests:v7.0.5
12-
docker tag solidtestsuite/solid-crud-tests:v7.0.5 solid-crud-tests
1313
docker pull solidtestsuite/web-access-control-tests:v7.1.0
14+
docker pull solidtestsuite/webid-provider-tests:v2.1.0
15+
16+
docker tag solidtestsuite/solid-crud-tests:v7.0.5 solid-crud-tests
1417
docker tag solidtestsuite/web-access-control-tests:v7.1.0 web-access-control-tests
18+
docker tag solidtestsuite/webid-provider-tests:v2.1.0 webid-provider-tests
1519
}
20+
1621
function teardown {
17-
docker stop `docker ps --filter network=testnet -q`
18-
docker rm `docker ps --filter network=testnet -qa`
22+
docker stop "$(docker ps --filter network=testnet -q)"
23+
docker rm "$(docker ps --filter network=testnet -qa)"
1924
docker network remove testnet
2025
}
2126

@@ -24,21 +29,21 @@ function startPubSub {
2429
}
2530

2631
function startSolidNextcloud {
27-
docker run -d --name $1 --network=testnet --env-file ./env-vars-$1.list solid-nextcloud
28-
until docker run --rm --network=testnet solidtestsuite/webid-provider-tests curl -kI https://$1 2> /dev/null > /dev/null
32+
docker run -d --name "$1" --network=testnet --env-file "./env-vars-$1.list" "${2:-solid-nextcloud}"
33+
until docker run --rm --network=testnet solidtestsuite/webid-provider-tests curl -kI "https://$1" 2> /dev/null > /dev/null
2934
do
30-
echo Waiting for $1 to start, this can take up to a minute ...
35+
echo Waiting for "$1" to start, this can take up to a minute ...
3136
docker ps -a
32-
docker logs $1
37+
docker logs "$1"
3338
sleep 1
3439
done
3540

36-
docker logs $1
37-
echo Running init script for Nextcloud $1 ...
38-
docker exec -u www-data -it -e SERVER_ROOT=https://$1 $1 sh /init.sh
39-
docker exec -u root -it $1 service apache2 reload
40-
echo Getting cookie for $1...
41-
export COOKIE_$1="`docker run --cap-add=SYS_ADMIN --network=testnet --env-file ./env-vars-$1.list michielbdejong/nextcloud-cookie`"
41+
docker logs "$1"
42+
echo "Running init script for Nextcloud $1 ..."
43+
docker exec -u www-data -i -e SERVER_ROOT="https://$1" "$1" sh /init.sh
44+
docker exec -u root -i "$1" service apache2 reload
45+
echo Getting cookie for "$1"...
46+
export COOKIE_$1="$(docker run --cap-add=SYS_ADMIN --network=testnet --env-file "./env-vars-$1.list" michielbdejong/nextcloud-cookie)"
4247
}
4348

4449
function runTests {
@@ -48,16 +53,30 @@ function runTests {
4853
--env COOKIE="$COOKIE_server" \
4954
--env COOKIE_ALICE="$COOKIE_server" \
5055
--env COOKIE_BOB="$COOKIE_thirdparty" \
51-
--env-file ./env-vars-testers.list $1-tests
56+
--env-file ./env-vars-testers.list \
57+
"$1-tests"
58+
}
59+
60+
run_solid_test_suite() {
61+
# ...
62+
teardown || true
63+
setup
64+
startPubSub
65+
startSolidNextcloud server
66+
startSolidNextcloud thirdparty
67+
runTests webid-provider
68+
runTests web-access-control
69+
runTests solid-crud
70+
teardown
5271
}
5372

54-
# ...
55-
teardown || true
56-
setup
57-
startPubSub
58-
startSolidNextcloud server
59-
startSolidNextcloud thirdparty
60-
runTests webid-provider
61-
runTests web-access-control
62-
runTests solid-crud
63-
teardown
73+
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
74+
run_solid_test_suite "${@}"
75+
else
76+
export -f run_solid_test_suite
77+
export -f runTests
78+
export -f setup
79+
export -f startPubSub
80+
export -f startSolidNextcloud
81+
export -f teardown
82+
fi

0 commit comments

Comments
 (0)