|
| 1 | +# SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +name: OCM Test Suite |
| 4 | + |
| 5 | +on: |
| 6 | + workflow_dispatch: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - master |
| 13 | + |
| 14 | +permissions: |
| 15 | + actions: write |
| 16 | + contents: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + # Orchestrator: compute version |
| 20 | + ocm-prepare: |
| 21 | + name: Prepare |
| 22 | + runs-on: ubuntu-latest |
| 23 | + outputs: |
| 24 | + current_version: ${{ steps.version.outputs.version }} |
| 25 | + |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 1 |
| 30 | + submodules: recursive |
| 31 | + |
| 32 | + - name: Derive current Nextcloud version |
| 33 | + id: version |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + ver=$(grep -Eo '\$OC_Version\s*=\s*\[[^]]+' version.php | |
| 37 | + grep -Eo '[0-9]+' | head -n 3 | paste -sd'.' -) |
| 38 | +
|
| 39 | + if [[ ! $ver =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 40 | + echo "::error::Could not parse version.php (got \"$ver\")" |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | +
|
| 44 | + echo "version=v${ver}" >> "$GITHUB_OUTPUT" |
| 45 | + echo "Detected Nextcloud version: v${ver}" |
| 46 | +
|
| 47 | + # Matrix actor job: runs all OCM combinations in parallel. |
| 48 | + # Each combo pulls its required images directly from registries. |
| 49 | + ocm-actors: |
| 50 | + needs: [ocm-prepare] |
| 51 | + runs-on: ubuntu-latest |
| 52 | + continue-on-error: true |
| 53 | + strategy: |
| 54 | + fail-fast: false |
| 55 | + max-parallel: 4 |
| 56 | + matrix: |
| 57 | + include: |
| 58 | + - combo_id: stub-stub |
| 59 | + display_name: "Stub to Stub" |
| 60 | + sender: ocmstub |
| 61 | + sender_version: v1.0.0 |
| 62 | + receiver: ocmstub |
| 63 | + receiver_version: v1.0.0 |
| 64 | + uses_nextcloud_source: false |
| 65 | + images: | |
| 66 | + mariadb:11.4.4 |
| 67 | + pondersource/cypress:latest |
| 68 | + pondersource/dev-stock:latest |
| 69 | + pondersource/ocmstub:v1.0.0 |
| 70 | + - combo_id: stub-nextcloud |
| 71 | + display_name: "Stub to Nextcloud" |
| 72 | + sender: ocmstub |
| 73 | + sender_version: v1.0.0 |
| 74 | + receiver: nextcloud |
| 75 | + receiver_version: current |
| 76 | + uses_nextcloud_source: true |
| 77 | + images: | |
| 78 | + mariadb:11.4.4 |
| 79 | + pondersource/cypress:latest |
| 80 | + pondersource/dev-stock:latest |
| 81 | + pondersource/ocmstub:v1.0.0 |
| 82 | + ghcr.io/mahdibaghbani/containers/nextcloud:latest |
| 83 | + valkey/valkey:9.0-alpine |
| 84 | + - combo_id: nextcloud-stub |
| 85 | + display_name: "Nextcloud to Stub" |
| 86 | + sender: nextcloud |
| 87 | + sender_version: current |
| 88 | + receiver: ocmstub |
| 89 | + receiver_version: v1.0.0 |
| 90 | + uses_nextcloud_source: true |
| 91 | + images: | |
| 92 | + mariadb:11.4.4 |
| 93 | + pondersource/cypress:latest |
| 94 | + pondersource/dev-stock:latest |
| 95 | + pondersource/ocmstub:v1.0.0 |
| 96 | + ghcr.io/mahdibaghbani/containers/nextcloud:latest |
| 97 | + valkey/valkey:9.0-alpine |
| 98 | + - combo_id: nextcloud-nextcloud |
| 99 | + display_name: "Nextcloud to Nextcloud" |
| 100 | + sender: nextcloud |
| 101 | + sender_version: current |
| 102 | + receiver: nextcloud |
| 103 | + receiver_version: current |
| 104 | + uses_nextcloud_source: true |
| 105 | + images: | |
| 106 | + mariadb:11.4.4 |
| 107 | + pondersource/cypress:latest |
| 108 | + pondersource/dev-stock:latest |
| 109 | + ghcr.io/mahdibaghbani/containers/nextcloud:latest |
| 110 | + valkey/valkey:9.0-alpine |
| 111 | +
|
| 112 | + name: ${{ matrix.display_name }} |
| 113 | + |
| 114 | + steps: |
| 115 | + - uses: actions/checkout@v4 |
| 116 | + with: |
| 117 | + fetch-depth: 1 |
| 118 | + submodules: recursive |
| 119 | + |
| 120 | + - name: Prepare host paths |
| 121 | + run: | |
| 122 | + mkdir -p "${{ github.workspace }}/.ocm-dev-stock-root/cypress/videos" |
| 123 | + mkdir -p "${{ github.workspace }}/.ocm-dev-stock-root/cypress/screenshots" |
| 124 | + sudo ln -sfn "${{ github.workspace }}/.ocm-dev-stock-root" /dev-stock |
| 125 | +
|
| 126 | + - name: Pull images |
| 127 | + shell: bash |
| 128 | + run: | |
| 129 | + echo "${{ matrix.images }}" | while read -r image; do |
| 130 | + if [[ -n "$image" ]]; then |
| 131 | + echo "Pulling $image..." |
| 132 | + docker pull "$image" |
| 133 | + fi |
| 134 | + done |
| 135 | +
|
| 136 | + - name: Run OCM test |
| 137 | + id: run |
| 138 | + env: |
| 139 | + NEXTCLOUD_SOURCE_DIR: ${{ github.workspace }} |
| 140 | + CURRENT_VERSION: ${{ needs.ocm-prepare.outputs.current_version }} |
| 141 | + shell: bash |
| 142 | + run: | |
| 143 | + set +e |
| 144 | +
|
| 145 | + SENDER_VER="${{ matrix.sender_version }}" |
| 146 | + RECEIVER_VER="${{ matrix.receiver_version }}" |
| 147 | + if [[ "$SENDER_VER" == "current" ]]; then |
| 148 | + SENDER_VER="${CURRENT_VERSION}" |
| 149 | + fi |
| 150 | + if [[ "$RECEIVER_VER" == "current" ]]; then |
| 151 | + RECEIVER_VER="${CURRENT_VERSION}" |
| 152 | + fi |
| 153 | +
|
| 154 | + NC_ENV="" |
| 155 | + if [[ "${{ matrix.uses_nextcloud_source }}" == "true" ]]; then |
| 156 | + NC_ENV="-e NEXTCLOUD_SOURCE_DIR=${NEXTCLOUD_SOURCE_DIR}" |
| 157 | + fi |
| 158 | +
|
| 159 | + docker run --rm \ |
| 160 | + --name="dev-stock-${{ github.run_id }}-${{ matrix.combo_id }}" \ |
| 161 | + -e CI_ENVIRONMENT=true \ |
| 162 | + -e DEVSTOCK_DEBUG=true \ |
| 163 | + $NC_ENV \ |
| 164 | + -v /var/run/docker.sock:/var/run/docker.sock \ |
| 165 | + --entrypoint ocm-test-suite \ |
| 166 | + pondersource/dev-stock:latest \ |
| 167 | + share-with ${{ matrix.sender }} ${SENDER_VER} ci electron ${{ matrix.receiver }} ${RECEIVER_VER} |
| 168 | +
|
| 169 | + exit_code=$? |
| 170 | + if [ $exit_code -eq 0 ]; then |
| 171 | + echo "status=pass" >> "$GITHUB_OUTPUT" |
| 172 | + else |
| 173 | + echo "status=fail" >> "$GITHUB_OUTPUT" |
| 174 | + fi |
| 175 | + exit $exit_code |
| 176 | +
|
| 177 | + - name: Write status JSON |
| 178 | + if: always() |
| 179 | + shell: bash |
| 180 | + run: | |
| 181 | + mkdir -p /tmp/status |
| 182 | + STATUS="${{ steps.run.outputs.status }}" |
| 183 | + if [[ -z "$STATUS" ]]; then |
| 184 | + STATUS="unknown" |
| 185 | + fi |
| 186 | + echo "{\"combo_id\":\"${{ matrix.combo_id }}\",\"status\":\"${STATUS}\"}" > /tmp/status/status.json |
| 187 | +
|
| 188 | + - name: Upload status artifact |
| 189 | + if: always() |
| 190 | + uses: actions/upload-artifact@v4 |
| 191 | + with: |
| 192 | + name: ocm-matrix-status-${{ matrix.combo_id }} |
| 193 | + path: /tmp/status/status.json |
| 194 | + retention-days: 1 |
| 195 | + |
| 196 | + - name: Upload Cypress artifacts |
| 197 | + if: always() |
| 198 | + uses: actions/upload-artifact@v4 |
| 199 | + with: |
| 200 | + name: cypress-${{ matrix.combo_id }} |
| 201 | + path: | |
| 202 | + ${{ github.workspace }}/.ocm-dev-stock-root/cypress/videos |
| 203 | + ${{ github.workspace }}/.ocm-dev-stock-root/cypress/screenshots |
| 204 | + if-no-files-found: ignore |
| 205 | + |
| 206 | + # Summary: collect results from matrix actors (always runs, never blocks) |
| 207 | + ocm-summary: |
| 208 | + name: Summary |
| 209 | + needs: |
| 210 | + - ocm-prepare |
| 211 | + - ocm-actors |
| 212 | + if: always() |
| 213 | + runs-on: ubuntu-latest |
| 214 | + |
| 215 | + steps: |
| 216 | + - name: Install jq |
| 217 | + run: | |
| 218 | + sudo apt-get update -qq |
| 219 | + sudo apt-get install -y jq |
| 220 | +
|
| 221 | + - name: Download status artifacts |
| 222 | + uses: actions/download-artifact@v4 |
| 223 | + with: |
| 224 | + pattern: ocm-matrix-status-* |
| 225 | + path: /tmp/status-artifacts |
| 226 | + merge-multiple: false |
| 227 | + |
| 228 | + - name: Generate OCM Test Summary |
| 229 | + env: |
| 230 | + CURRENT_VERSION: ${{ needs.ocm-prepare.outputs.current_version }} |
| 231 | + shell: bash |
| 232 | + run: | |
| 233 | + { |
| 234 | + echo "## OCM Test Suite Results" |
| 235 | + echo "" |
| 236 | + echo "Nextcloud version: \`${CURRENT_VERSION}\`" |
| 237 | + echo "" |
| 238 | + echo "| Combination | Scenario | Status | Artifacts |" |
| 239 | + echo "|-------------|----------|--------|-----------|" |
| 240 | +
|
| 241 | + for combo in stub-stub stub-nextcloud nextcloud-stub nextcloud-nextcloud; do |
| 242 | + status_file="/tmp/status-artifacts/ocm-matrix-status-${combo}/status.json" |
| 243 | + if [[ -f "$status_file" ]]; then |
| 244 | + status=$(jq -r '.status' "$status_file") |
| 245 | + else |
| 246 | + status="UNKNOWN" |
| 247 | + fi |
| 248 | +
|
| 249 | + case "$combo" in |
| 250 | + stub-stub) |
| 251 | + display="Stub v1.0.0 <-> Stub v1.0.0" |
| 252 | + ;; |
| 253 | + stub-nextcloud) |
| 254 | + display="Stub v1.0.0 <-> Nextcloud (current)" |
| 255 | + ;; |
| 256 | + nextcloud-stub) |
| 257 | + display="Nextcloud (current) <-> Stub v1.0.0" |
| 258 | + ;; |
| 259 | + nextcloud-nextcloud) |
| 260 | + display="Nextcloud (current) <-> Nextcloud (current)" |
| 261 | + ;; |
| 262 | + esac |
| 263 | +
|
| 264 | + echo "| ${display} | share-with | ${status} | cypress-${combo} |" |
| 265 | + done |
| 266 | +
|
| 267 | + echo "" |
| 268 | + echo "Note: This workflow is non-blocking. Failures are reported above but do not fail the overall workflow." |
| 269 | + } >> "$GITHUB_STEP_SUMMARY" |
| 270 | +
|
| 271 | + - name: Delete status artifacts |
| 272 | + uses: geekyeggo/delete-artifact@v5 |
| 273 | + with: |
| 274 | + name: ocm-matrix-status-* |
| 275 | + failOnError: false |
0 commit comments