Skip to content

ci: automate Apache release candidate staging #11860

ci: automate Apache release candidate staging

ci: automate Apache release candidate staging #11860

Workflow file for this run

# 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: e2e
on:
# Required checks must report a result even for documentation-only PRs.
pull_request:
push:
branches:
- master
paths-ignore:
- '*.md'
- '**/README*.md'
- 'docs/**'
- '**/docs/**'
- '.github/ISSUE_TEMPLATE/**'
- '.github/PULL_REQUEST_TEMPLATE.md'
concurrency:
# Give every non-PR run its own group, including runs still waiting for a runner.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
changes:
runs-on: ubuntu-latest
outputs:
e2e: ${{ steps.filter.outputs.e2e }}
run_e2e: ${{ steps.cases.outputs.run_e2e }}
run_storage: ${{ steps.cases.outputs.run_storage }}
run_e2e_cases: ${{ steps.cases.outputs.run_e2e_cases }}
storage_matrix: ${{ steps.cases.outputs.storage_matrix }}
e2e_matrix: ${{ steps.cases.outputs.e2e_matrix }}
e2e_shards: ${{ steps.shards.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Test conditional disk cleanup
run: bash .github/scripts/free-disk-space-test.sh
- name: Test local HTTP upstream fixture and Compose wiring
run: python3 -B shenyu-e2e/shenyu-e2e-case/compose/fixtures/test_httpbin.py
- name: Test E2E Maven input handoff
run: bash .github/scripts/prepare-e2e-maven-repository-test.sh
- uses: ./actions/paths-filter
id: filter
with:
list-files: "json"
predicate-quantifier: every
filters: |
e2e:
- '{shenyu-e2e/**,**/e2e/**,shenyu-*/**,db/**,pom.xml,**/pom.xml,.github/workflows/e2e-k8s.yml,.github/scripts/*e2e-maven-repository*,.github/scripts/resolve-test-case-matrix*.sh,.github/scripts/**,actions/**,mvnw,mvnw.cmd,.mvn/**}'
- '!.asf.yaml'
- '!.gitignore'
- '!.licenserc.yaml'
- '!LICENSE'
- '!NOTICE'
- '!.github/ISSUE_TEMPLATE/**'
- '!*.md'
- '!**/README*.md'
- '!docs/**'
- '!**/docs/**'
- '!.github/PULL_REQUEST_TEMPLATE.md'
- name: Resolve E2E cases
id: cases
if: steps.filter.outputs.e2e == 'true'
env:
CHANGED_FILES_JSON: ${{ steps.filter.outputs.e2e_files }}
CI_CASE_MODE: e2e
run: bash .github/scripts/resolve-test-case-matrix.sh
- name: Expand protocol and sync channel shards
id: shards
if: steps.cases.outputs.run_e2e_cases == 'true'
env:
E2E_MATRIX: ${{ steps.cases.outputs.e2e_matrix }}
run: |
matrix=$(jq -c '{include: [.include[] |
if ((.script | endswith("-sync-compose")) or .script == "e2e-logging-rocketmq-compose") then
. as $entry | ["websocket", "http", "zookeeper"][] | $entry + {sync: .}
else . + {sync: ""} end]}' <<< "$E2E_MATRIX")
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
build-docker-images:
needs: changes
if: ${{ needs.changes.outputs.run_e2e == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Free disk space when needed
run: bash .github/scripts/free-disk-space.sh
- name: Set up JDK 17 for Building ShenYu
uses: ./actions/setup-java-with-retry
with:
java-version: "17"
distribution: "temurin"
cache: maven
- name: Build with Maven
shell: bash
run: |
exec bash .github/scripts/maven-with-retry.sh ./mvnw -B clean install -Prelease,docker -Dmaven.javadoc.skip=true -Drat.skip=true -Dmaven.test.skip=true -Djacoco.skip=true -DskipITs -DskipTests -T1C
- name: Prepare selected example and E2E Maven inputs
env:
E2E_MATRIX: ${{ needs.changes.outputs.e2e_matrix }}
STORAGE_MATRIX: ${{ needs.changes.outputs.storage_matrix }}
run: bash .github/scripts/prepare-e2e-maven-repository.sh /tmp/shenyu-m2
- name: Build Docker Image
run: |
docker save apache/shenyu-bootstrap:latest > /tmp/apache-shenyu-bootstrap.tar
docker save apache/shenyu-admin:latest > /tmp/apache-shenyu-admin.tar
- name: Upload Docker Image Artifacts
uses: actions/upload-artifact@v4
with:
name: shenyu-images
path: /tmp/apache-shenyu-*.tar
retention-days: 1
if-no-files-found: error
- name: Upload ShenYu local Maven repository
uses: actions/upload-artifact@v4
with:
name: shenyu-local-maven-repository
compression-level: 0
path: |
/tmp/shenyu-m2/repository.tar.gz
/tmp/shenyu-m2/settings.xml
retention-days: 1
if-no-files-found: error
e2e-storage:
runs-on: ubuntu-latest
needs:
- changes
- build-docker-images
if: github.repository == 'apache/shenyu' && needs.changes.outputs.run_storage == 'true'
# if: (github.repository == 'apache/shenyu')
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.changes.outputs.storage_matrix || '{"include":[]}') }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Free disk space when needed
run: |
bash .github/scripts/free-disk-space.sh
rm -rf /tmp/shenyu
mkdir -p /tmp/shenyu
# - name: Install k8s
# if: steps.filter.outputs.changed == 'true'
# run: |
# curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.29.6+k3s2 K3S_KUBECONFIG_MODE=777 sh -
# cat /etc/rancher/k3s/k3s.yaml
# mkdir -p ~/.kube
# cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
- name: Set up JDK 17 for Building ShenYu
uses: ./actions/setup-java-with-retry
with:
java-version: "17"
distribution: "temurin"
- uses: actions/download-artifact@v4
with:
name: shenyu-images
path: /tmp/shenyu/
- name: Verify the image artifacts are present
run: |
missing=()
for tar in apache-shenyu-admin.tar apache-shenyu-bootstrap.tar; do
[[ -f "/tmp/shenyu/${tar}" ]] || missing+=("${tar}")
done
if [[ ${#missing[@]} -gt 0 ]]; then
echo "::error::shenyu-images does not contain ${missing[*]}."
echo "::error::A failed-job rerun cannot regenerate these files. Rerun all jobs; /retest does this automatically when a required artifact is missing or expired."
exit 1
fi
- uses: actions/download-artifact@v4
with:
name: shenyu-local-maven-repository
path: /tmp/shenyu-m2
- name: Restore E2E Maven inputs
run: |
python3 .github/scripts/e2e-maven-repository.py restore /tmp/shenyu-m2 /tmp/shenyu-e2e-maven
cp /tmp/shenyu-e2e-maven/wrapper/maven-wrapper.jar .mvn/wrapper/maven-wrapper.jar
echo 'MAVEN_CONFIG=-s /tmp/shenyu-e2e-maven/settings.xml' >> "$GITHUB_ENV"
echo 'MAVEN_USER_HOME=/tmp/shenyu-e2e-maven/maven-user-home' >> "$GITHUB_ENV"
- name: Load ShenYu Docker Images
run: |
docker load --input /tmp/shenyu/apache-shenyu-admin.tar
docker load --input /tmp/shenyu/apache-shenyu-bootstrap.tar
docker image ls -a
# - name: Build k8s Cluster
# if: steps.filter.outputs.changed == 'true'
# run: |
# sudo k3s ctr images import /tmp/shenyu/apache-shenyu-admin.tar
# sudo k3s ctr images import /tmp/shenyu/apache-shenyu-bootstrap.tar
- name: Run E2E Tests
run: |
bash ./shenyu-e2e/shenyu-e2e-case/${{ matrix.case }}/compose/script/${{ matrix.script }}.sh
# - name: Cluster Test after Healthcheck
# if: steps.filter.outputs.changed == 'true'
# run: |
# kubectl get all
# kubectl get events --all-namespaces
e2e-case:
name: e2e-case (${{ matrix.script }}, ${{ matrix.sync || 'default' }})
runs-on: ubuntu-latest
needs:
- changes
- build-docker-images
if: github.repository == 'apache/shenyu' && needs.changes.outputs.run_e2e_cases == 'true'
# if: (github.repository == 'apache/shenyu')
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.changes.outputs.e2e_shards || '{"include":[]}') }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Free disk space when needed
run: |
bash .github/scripts/free-disk-space.sh
rm -rf /tmp/shenyu
mkdir -p /tmp/shenyu
# - name: Install k8s
# if: steps.filter.outputs.changed == 'true'
# run: |
# curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.29.6+k3s2 K3S_KUBECONFIG_MODE=777 sh -
# cat /etc/rancher/k3s/k3s.yaml
# mkdir -p ~/.kube
# cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
- name: Set up JDK 17 for Building ShenYu
uses: ./actions/setup-java-with-retry
with:
java-version: "17"
distribution: "temurin"
- uses: actions/download-artifact@v4
with:
name: shenyu-images
path: /tmp/shenyu/
- uses: actions/download-artifact@v4
with:
name: shenyu-local-maven-repository
path: /tmp/shenyu-m2
- name: Verify the image artifacts are present
run: |
missing=()
for tar in apache-shenyu-admin.tar apache-shenyu-bootstrap.tar; do
[[ -f "/tmp/shenyu/${tar}" ]] || missing+=("${tar}")
done
if [[ ${#missing[@]} -gt 0 ]]; then
echo "::error::shenyu-images does not contain ${missing[*]}."
echo "::error::A failed-job rerun cannot regenerate these files. Rerun all jobs; /retest does this automatically when a required artifact is missing or expired."
exit 1
fi
- name: Restore E2E Maven inputs
run: |
python3 .github/scripts/e2e-maven-repository.py restore /tmp/shenyu-m2 /tmp/shenyu-e2e-maven
cp /tmp/shenyu-e2e-maven/wrapper/maven-wrapper.jar .mvn/wrapper/maven-wrapper.jar
echo 'MAVEN_CONFIG=-s /tmp/shenyu-e2e-maven/settings.xml' >> "$GITHUB_ENV"
echo 'MAVEN_USER_HOME=/tmp/shenyu-e2e-maven/maven-user-home' >> "$GITHUB_ENV"
- name: Build examples with Maven
shell: bash
env:
EXAMPLE_PROJECTS: ${{ matrix.example_projects }}
run: |
./mvnw -B -ntp -o clean install -Pexample -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -pl "${EXAMPLE_PROJECTS}" -am -f ./shenyu-examples/pom.xml
- name: Load ShenYu Docker Images
run: |
docker load --input /tmp/shenyu/apache-shenyu-admin.tar
docker load --input /tmp/shenyu/apache-shenyu-bootstrap.tar
docker image ls -a
# - name: Build k8s Cluster
# if: steps.filter.outputs.changed == 'true'
# run: |
# sudo k3s ctr images import /tmp/shenyu/apache-shenyu-admin.tar
# sudo k3s ctr images import /tmp/shenyu/apache-shenyu-bootstrap.tar
# - name: Setup Debug Session
# uses: mxschmitt/action-tmate@v3
# timeout-minutes: 15
# with:
# detached: true
- name: Run E2E Tests
env:
SHENYU_E2E_SYNC: ${{ matrix.sync }}
run: |
bash ./shenyu-e2e/shenyu-e2e-case/${{ matrix.case }}/compose/script/${{ matrix.script }}.sh
# - name: Cluster Test after Healthcheck
# if: steps.filter.outputs.changed == 'true'
# run: |
# kubectl get all
# kubectl get events --all-namespaces
requirement:
name: e2e
if: ${{ !cancelled() }}
needs:
- changes
- build-docker-images
- e2e-storage
- e2e-case
runs-on: ubuntu-latest
steps:
- name: checking job status
run: |
if [[ "${{ needs.changes.result }}" != "success" ]]; then
echo '::error::E2E prerequisite failed: case selection (${{ needs.changes.result }}).'
exit 1
fi
if [[ "${{ needs.changes.outputs.run_e2e }}" == "true" ]]; then
if [[ "${{ needs.build-docker-images.result }}" != "success" ]]; then
echo '::error::E2E prerequisite failed: image and Maven input preparation (${{ needs.build-docker-images.result }}).'
exit 1
fi
fi
failed=0
if [[ "${{ needs.changes.outputs.run_storage }}" == "true" ]]; then
if [[ "${{ needs.e2e-storage.result }}" != "success" ]]; then
echo '::error::E2E storage matrix failed (${{ needs.e2e-storage.result }}).'
failed=1
fi
fi
if [[ "${{ needs.changes.outputs.run_e2e_cases }}" == "true" ]]; then
if [[ "${{ needs.e2e-case.result }}" != "success" ]]; then
echo '::error::E2E case matrix failed (${{ needs.e2e-case.result }}).'
failed=1
fi
fi
exit "$failed"