Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/ci/path-policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 1,
"rules": [
{
"class": "generated-docs",
"include": "^docs/src/main/(paradox|categories)/.*\\.[mM][dD]$"
},
{
"class": "prose",
"include": "\\.[mM][dD]$",
"exclude": "(^|/)src/"
},
{
"class": "prose",
"include": "^remote/src/test/resources/ssl/(pem/)?README\\.md$"
}
]
}
8 changes: 7 additions & 1 deletion .github/workflows/binary-compatibility-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ on:
permissions: {}

jobs:
classify-changes:
if: github.event_name == 'pull_request'
uses: ./.github/workflows/classify-pr-changes.yml
permissions:
contents: read
check-binary-compatibility:
needs: classify-changes
if: always() && !cancelled() && github.repository == 'apache/pekko' && (github.event_name != 'pull_request' || needs.classify-changes.result != 'success' || (needs.classify-changes.outputs.validation-plan != 'prose' && needs.classify-changes.outputs.validation-plan != 'generated'))
name: Check / Binary Compatibility
runs-on: ubuntu-22.04
if: github.repository == 'apache/pekko'
strategy:
fail-fast: false
env:
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/build-test-prValidation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ concurrency:
cancel-in-progress: true

jobs:
classify-changes:
uses: ./.github/workflows/classify-pr-changes.yml
permissions:
contents: read
check-code-style:
needs: classify-changes
if: always() && !cancelled() && (needs.classify-changes.result != 'success' || (needs.classify-changes.outputs.validation-plan != 'prose' && needs.classify-changes.outputs.validation-plan != 'generated'))
name: Check / Code Style
runs-on: ubuntu-22.04
env:
Expand Down Expand Up @@ -53,6 +59,8 @@ jobs:
-Dsbt.log.noformat=false \
checkCodeStyle
pull-request-validation:
needs: classify-changes
if: always() && !cancelled() && (needs.classify-changes.result != 'success' || (needs.classify-changes.outputs.validation-plan != 'prose' && needs.classify-changes.outputs.validation-plan != 'generated'))
name: Check / Tests
runs-on: ubuntu-22.04
env:
Expand Down Expand Up @@ -118,9 +126,10 @@ jobs:
"++ ${scala_version}! validatePullRequest"

pekko-classic-remoting-tests:
needs: classify-changes
if: always() && !cancelled() && github.repository == 'apache/pekko' && (needs.classify-changes.result != 'success' || (needs.classify-changes.outputs.validation-plan != 'prose' && needs.classify-changes.outputs.validation-plan != 'generated'))
name: Pekko Classic Remoting Tests
runs-on: ubuntu-22.04
if: github.repository == 'apache/pekko'
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -167,6 +176,8 @@ jobs:
clean ${{ matrix.command }}

jdk-21-extra-tests:
needs: classify-changes
if: always() && !cancelled() && (needs.classify-changes.result != 'success' || (needs.classify-changes.outputs.validation-plan != 'prose' && needs.classify-changes.outputs.validation-plan != 'generated'))
name: Java 21 Extra Tests
runs-on: ubuntu-22.04
env:
Expand Down
104 changes: 104 additions & 0 deletions .github/workflows/classify-pr-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

name: Classify pull request changes

on:
workflow_call:
inputs:
policy-path:
description: Repository-relative path to the classification policy on the PR base
type: string
default: .github/ci/path-policy.json
outputs:
validation-plan:
description: Validation level (full, prose, or generated)
value: ${{ jobs.classify.outputs.validation-plan }}

permissions:
contents: read

jobs:
classify:
runs-on: ubuntu-22.04
timeout-minutes: 2
outputs:
validation-plan: ${{ steps.changed-paths.outputs.validation-plan }}
steps:
- id: changed-paths
shell: bash
env:
GH_TOKEN: ${{ github.token }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
CHANGED_FILES: ${{ github.event.pull_request.changed_files }}
POLICY_PATH: ${{ inputs.policy-path }}
run: |
# Read the repository's policy from the immutable base, never the PR's proposed policy.
# Compare supplies at most 300 files. Missing policy, data, or classifications run full CI.
validation_plan=full
if [[ "$CHANGED_FILES" =~ ^[1-9][0-9]{0,2}$ && "$CHANGED_FILES" -le 300 &&
"$BASE_SHA" =~ ^[0-9a-f]{40}$ && "$HEAD_SHA" =~ ^[0-9a-f]{40}$ &&
"$POLICY_PATH" =~ ^[A-Za-z0-9._-]+(/[A-Za-z0-9._-]+)*$ &&
"$POLICY_PATH" != *..* && "/$POLICY_PATH/" != *"/./"* ]]; then
if policy=$(gh api "repos/$GITHUB_REPOSITORY/contents/$POLICY_PATH?ref=$BASE_SHA" |
jq -er 'select(.type == "file" and .encoding == "base64") | .content' | base64 --decode) &&
result=$(gh api "repos/$GITHUB_REPOSITORY/compare/$BASE_SHA...$HEAD_SHA?per_page=1" |
jq -r --argjson count "$CHANGED_FILES" --argjson policy "$policy" --arg policy_path "$POLICY_PATH" '
def valid_regex:
. as $pattern |
type == "string" and length > 0 and
(try ("" | test($pattern) | type == "boolean") catch false);
def valid_rule:
(.class == "prose" or .class == "generated-docs")
and (.include | valid_regex)
and (.exclude == null or (.exclude | valid_regex));
def matches($name; $kind):
any($policy.rules[]; .class == $kind and
(.include as $include | .exclude as $exclude |
($name | test($include)) and ($exclude == null or ($name | test($exclude) | not))));
def path_class:
. as $name |
if type != "string" or length == 0 or $name == $policy_path or
test("^\\.github/(workflows|actions|ci)/") then "full"
elif matches($name; "generated-docs") then "generated"
elif matches($name; "prose") then "prose"
else "full"
end;
def changed_paths:
if .status == "renamed" and (.previous_filename | type == "string")
then [.filename, .previous_filename]
elif (.status == "added" or .status == "removed" or .status == "modified") and .previous_filename == null
then [.filename]
else [null]
end;
if $policy.version != 1 or ($policy.rules | type != "array" or length == 0 or
(all(.[]; valid_rule) | not)) then "full"
elif (.files | type != "array" or length != $count) then "full"
else [.files[] | changed_paths[] | path_class] |
if any(.[]; . == "full") then "full"
elif any(.[]; . == "generated") then "generated"
else "prose"
end
end
'); then
case "$result" in
prose|generated) validation_plan="$result" ;;
esac
fi
fi
echo "validation-plan=$validation_plan" >> "$GITHUB_OUTPUT"
7 changes: 7 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ on:
branches: ['**']

jobs:
classify-changes:
uses: ./.github/workflows/classify-pr-changes.yml
permissions:
contents: read
build:
# Keep emitting this required check; an uncertain classification runs the original job.
needs: classify-changes
if: always() && !cancelled() && (needs.classify-changes.result != 'success' || (needs.classify-changes.outputs.validation-plan != 'prose' && needs.classify-changes.outputs.validation-plan != 'generated'))
name: Code is formatted
runs-on: ubuntu-26.04
steps:
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/generate-doc-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ permissions:
contents: read

jobs:
classify-changes:
uses: ./.github/workflows/classify-pr-changes.yml
permissions:
contents: read
generate-doc-check:
needs: classify-changes
if: always() && !cancelled() && github.repository == 'apache/pekko' && (needs.classify-changes.result != 'success' || needs.classify-changes.outputs.validation-plan != 'prose')
name: Generate doc check
runs-on: ubuntu-22.04
if: github.repository == 'apache/pekko'
steps:
- name: Checkout
uses: actions/checkout@v7.0.1
Expand All @@ -52,7 +57,14 @@ jobs:
run: |-
sudo apt-get install graphviz

- name: Generate Paradox documentation
if: needs.classify-changes.result == 'success' && needs.classify-changes.outputs.validation-plan == 'generated'
env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
run: sbt docs/paradox

- name: Compile testClass&docs for all Scala versions
if: needs.classify-changes.result != 'success' || needs.classify-changes.outputs.validation-plan != 'generated'
env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
run: sbt ";+TestJdk21 / compile ; +compile:doc"
7 changes: 7 additions & 0 deletions .github/workflows/headers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ on:
permissions: {}

jobs:
classify-changes:
uses: ./.github/workflows/classify-pr-changes.yml
permissions:
contents: read
check-headers:
# Keep emitting this required check; an uncertain classification runs the original job.
needs: classify-changes
if: always() && !cancelled() && (needs.classify-changes.result != 'success' || (needs.classify-changes.outputs.validation-plan != 'prose' && needs.classify-changes.outputs.validation-plan != 'generated'))
name: Check headers
runs-on: ubuntu-22.04
steps:
Expand Down