Skip to content

Small code improvements #156

Small code improvements

Small code improvements #156

---
name: Solid Test Suites
env:
# Docker Hub digest (i.e. hash) of the used Docker Images that do not have a version tag.
PUBSUB_TAG: latest@sha256:b73a2a5c98d2005bb667dfc69d1c859d704366024298b9caa24ea2e182c456c2
COOKIE_TAG: latest@sha256:b2815496a1291a8f0f8bf2524c42d6000a4a1d6a202b319fe01e1afacf1cec7d
on:
push:
branches:
- main
pull_request:
branches: [ main ]
# Allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# @TODO: Instead of building the docker image here, take a pre-build image and mount the code?
# (only build when the Dockerfile changes) Or only push when tagged/main?
build-docker-nextcloud:
runs-on: ubuntu-latest
strategy:
matrix:
# For the latest version information see: https://github.com/nextcloud/server/wiki/Maintenance-and-Release-Schedule
# Versions before 22 are not tested as they run on PHP versions lower than 8.0
# Versions before 24 are not tested as they do not support `.well-known` entries
# Version 24 comes with PHP 8.0, which is no longer supported;
# Latest is not tested here, as that could cause failures unrelated to project changes
nextcloud_version:
- 28
- 29
- 30
steps:
- name: Create docker tag from git reference
# A tag name may only contain lower- and uppercase letters, digits, underscores, periods and dashes.
run: |
echo "TAG=$(echo -n "${{ github.ref_name }}-${{ matrix.nextcloud_version }}" \
| tr --complement --squeeze-repeats '[:alnum:]._-' '_')" \
>> "${GITHUB_ENV}"
- uses: actions/cache@v4
id: cache-solid-nextcloud-docker
with:
path: cache/solid-nextcloud
key: solid-nextcloud-docker-${{ matrix.nextcloud_version }}-${{ github.sha }}
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Solid-Nextcloud Docker image from NC-${{ matrix.nextcloud_version }}
run: |
docker build \
--tag "solid-nextcloud:${{ env.TAG }}" \
--tag "ghcr.io/${{ github.repository }}:${{ env.TAG }}" \
--build-arg 'NEXTCLOUD_VERSION=${{ matrix.nextcloud_version }}' \
.
docker push "ghcr.io/${{ github.repository }}:${{ env.TAG }}"
mkdir -p cache/solid-nextcloud
docker image save solid-nextcloud:${{ env.TAG }} --output ./cache/solid-nextcloud/${{ github.sha }}-${{ matrix.nextcloud_version }}.tar
solid-testsuite:
timeout-minutes: 30
needs:
- build-docker-nextcloud
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
nextcloud_version:
- 28
- 29
- 30
test:
- 'solidtestsuite/solid-crud-tests:v7.0.5'
- 'solidtestsuite/web-access-control-tests:v7.1.0'
- 'solidtestsuite/webid-provider-tests:v2.1.1'
# Prevent EOL or non-stable versions of Nextcloud to fail the test-suite
continue-on-error: ${{ contains(fromJson('[28,29,30]'), matrix.nextcloud_version) == false }}
steps:
- name: Create docker tag from git reference
# A tag name may only contain lower- and uppercase letters, digits, underscores, periods and dashes.
run: |
echo "TAG=$(echo -n "${{ github.ref_name }}-${{ matrix.nextcloud_version }}" \
| tr --complement --squeeze-repeats '[:alnum:]._-' '_')" \
>> "${GITHUB_ENV}"
- uses: actions/checkout@v4
- uses: actions/cache@v4
id: cache-solid-nextcloud-docker
with:
path: cache/solid-nextcloud
key: solid-nextcloud-docker-${{ matrix.nextcloud_version }}-${{ github.sha }}
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# FIXME: The `docker pull` should be moved to a previous step and cached
- name: Pull docker Images
run: |
docker image load --input ./cache/solid-nextcloud/${{ github.sha }}-${{ matrix.nextcloud_version }}.tar
docker pull michielbdejong/nextcloud-cookie:${{ env.COOKIE_TAG }}
docker pull ${{ matrix.test }}
docker pull ghcr.io/pdsinterop/php-solid-pubsub-server:${{ env.PUBSUB_TAG }}
- name: Start Docker Containers
run: |
docker network create testnet
docker run \
--detach \
--interactive \
--name 'pubsub' \
--network=testnet \
"ghcr.io/pdsinterop/php-solid-pubsub-server:${{ env.PUBSUB_TAG }}"
source ./run-solid-test-suite.sh
startSolidNextcloud 'server' "solid-nextcloud:${{ env.TAG }}" ${{ matrix.test }}
startSolidNextcloud 'thirdparty' "solid-nextcloud:${{ env.TAG }}" ${{ matrix.test }}
echo "COOKIE_server=${COOKIE_server}" >> "${GITHUB_ENV}"
echo "COOKIE_thirdparty=${COOKIE_thirdparty}" >> "${GITHUB_ENV}"
- name: Run tests - ${{ matrix.test }}
run: |
export COOKIE_server="${{ env.COOKIE_server }}"
export COOKIE_thirdparty="${{ env.COOKIE_thirdparty }}"
docker run -i --rm --network=testnet \
--name tester \
--env COOKIE="$COOKIE_server" \
--env COOKIE_ALICE="$COOKIE_server" \
--env COOKIE_BOB="$COOKIE_thirdparty" \
--env-file ./env-vars-testers.list \
${{ matrix.test }}
# - name: Setup tmate session - ${{ matrix.test }}
# if: failure()
# uses: mxschmitt/action-tmate@v3
- name: Show nextcloud logs - ${{ matrix.test }}
if: always()
run: |
docker exec -i server cat /var/www/html/data/nextcloud.log