Skip to content

Confine asset servlet paths to the resource root (#38590) #18

Confine asset servlet paths to the resource root (#38590)

Confine asset servlet paths to the resource root (#38590) #18

# Copyright 2021 Collate
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Builds and tests openmetadata-collate against this OpenMetadata change by dispatching its
# "OpenMetadata Collate Test" workflow (openmetadata-dispatch.yml) and waiting for it. The event is
# passed along and decides what runs there. Approved merge groups and pushes to main run the
# Collate checks. PR runs skip the dispatch because it requires credentials.
name: Maven Collate Tests
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "openmetadata-service/**"
- "openmetadata-ui/**"
- "!openmetadata-ui/src/main/resources/ui/playwright/doc-generator/**"
- "!openmetadata-ui/src/main/resources/ui/playwright/docs/**"
- "openmetadata-spec/src/main/resources/json/schema/**"
- "openmetadata-dist/**"
- "openmetadata-clients/**"
- "openmetadata-sdk/**"
- "openmetadata-integration-tests/**"
- "openmetadata-mcp/**"
- "common/**"
- "pom.xml"
- "Makefile"
- "bootstrap/**"
pull_request:
types: [opened, synchronize, ready_for_review]
paths:
- "openmetadata-service/**"
- "openmetadata-ui/src/main/resources/ui/src/**"
- "!openmetadata-ui/src/main/resources/ui/src/test/**"
- "!openmetadata-ui/src/main/resources/ui/src/**/*.test.ts"
- "!openmetadata-ui/src/main/resources/ui/src/**/*.test.tsx"
- "openmetadata-spec/src/main/resources/json/schema/**"
- "openmetadata-integration-tests/**"
- "openmetadata-mcp/**"
# merge_group takes no `paths:` filter; the `changes` job applies one in-job instead.
merge_group:
permissions:
contents: read
concurrency:
group: maven-build-collate-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
jobs:
# UI-only merge groups still need a Collate build because PR jobs never dispatch one.
changes:
name: Detect Changes
runs-on: ubuntu-latest
timeout-minutes: 10
if: ${{ github.event_name == 'merge_group' }}
permissions:
contents: read
pull-requests: read
outputs:
backend: ${{ steps.filter.outputs.backend }}
ui: ${{ steps.filter.outputs.ui }}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
filter: blob:none
persist-credentials: false
- uses: dorny/paths-filter@v4
id: filter
with:
base: ${{ github.event.merge_group.base_sha }}
filters: |
backend:
- 'openmetadata-service/**'
- 'openmetadata-spec/src/main/resources/json/schema/**'
- 'openmetadata-sdk/**'
- 'openmetadata-integration-tests/**'
- 'openmetadata-mcp/**'
- 'common/**'
- 'pom.xml'
- 'bootstrap/**'
ui:
- 'openmetadata-ui/src/main/resources/ui/src/**'
maven-collate-ci:
needs: changes
runs-on: ubuntu-latest
# The status function lets push and dispatch proceed when the queue-only filter is skipped.
if: ${{ !cancelled() && github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || github.ref == 'refs/heads/main') && (github.event_name != 'merge_group' || needs.changes.outputs.backend == 'true' || needs.changes.outputs.ui == 'true') }}
steps:
# Collate mirrors each OpenMetadata release line on an identically named branch, so build the
# Collate branch matching the PR or merge-queue base: dispatching main for a 1.13 PR builds
# main-only Collate code against a 1.13 checkout. A push or a manual run builds its own ref.
- name: Resolve the Collate branch
id: collate-ref
env:
BASE_REF: ${{ github.event.pull_request.base.ref || github.event.merge_group.base_ref || github.ref_name || 'main' }}
run: echo "ref=${BASE_REF#refs/heads/}" >> "$GITHUB_OUTPUT"
# Dispatched by file name straight to the REST endpoint, not through
# benc-uk/workflow-dispatch: that action finds the workflow by paging through the list of
# every Collate workflow, GitHub serves those pages in two different orders at random, and
# the lookup missed the workflow with "Unable to find workflow" on about one run in four.
- name: Trigger Collate build & wait
# Must stay above WAIT_SECONDS below. The step timeout kills the script outright, so when
# it is the smaller of the two the wait can never run out on its own and the step
# reports a bare "has timed out" with no downstream conclusion.
timeout-minutes: 100
env:
GH_TOKEN: ${{ secrets.COLLATE_PAT }}
COLLATE_REPO: open-metadata/openmetadata-collate
COLLATE_REF: ${{ steps.collate-ref.outputs.ref }}
SHA: ${{ github.event_name == 'push' && github.event.after || github.event.pull_request.head.sha || github.sha }}
# Collate's existing PR mode builds UI-only groups without its backend ITs. This is a
# downstream input value, not a pull_request_target trigger or an unapproved PR run.
EVENT: ${{ (github.event_name == 'merge_group' && needs.changes.outputs.backend != 'true') && 'pull_request_target' || github.event_name }}
# The Collate job caps itself at timeout-minutes: 90, so waiting past that point is
# what guarantees we report its real conclusion instead of giving up first. Successful
# main builds run 58-68 min, which the previous 61-min budget sat inside: the wait
# expired mid-build and failed this check on nearly every PR while the Collate run it
# was watching went on to pass.
WAIT_SECONDS: 5700
run: |
run_id=$(gh api -X POST "repos/$COLLATE_REPO/actions/workflows/openmetadata-dispatch.yml/dispatches" \
-f ref="$COLLATE_REF" -f "inputs[sha]=$SHA" -f "inputs[event]=$EVENT" \
-F return_run_details=true --jq .workflow_run_id)
if [ -z "$run_id" ]; then
echo "::error::The dispatch returned no run id; find the run at https://github.com/$COLLATE_REPO/actions/workflows/openmetadata-dispatch.yml"
exit 1
fi
run_url="https://github.com/$COLLATE_REPO/actions/runs/$run_id"
echo "Collate run: $run_url"
status=0
timeout "$WAIT_SECONDS" gh run watch "$run_id" --repo "$COLLATE_REPO" \
--interval 60 --compact --exit-status || status=$?
if [ "$status" -eq 124 ]; then
echo "::error::Collate run still in progress after ${WAIT_SECONDS}s: $run_url"
elif [ "$status" -ne 0 ]; then
echo "::error::Collate run did not succeed: $run_url"
fi
exit "$status"