diff --git a/.github/actions/plugins-test/action.yml b/.github/actions/build/action.yml similarity index 62% rename from .github/actions/plugins-test/action.yml rename to .github/actions/build/action.yml index 3b931b1f7..506aa9dff 100644 --- a/.github/actions/plugins-test/action.yml +++ b/.github/actions/build/action.yml @@ -16,12 +16,9 @@ # specific language governing permissions and limitations # under the License. # -name: "Run Plugin Test" -description: "Common steps when running a plugin test" +name: "Build Plugin Agent" +description: "Build Plugin Agent before running a plugin test" inputs: - test_case: - description: "The plugin test name" - required: true java_version: description: "The Java version under which this test case will run" required: false @@ -29,12 +26,6 @@ inputs: runs: using: "composite" steps: - - name: Cache local Maven repository - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-agent-test - restore-keys: ${{ runner.os }}-maven-agent-test - name: Check License uses: apache/skywalking-eyes@a63f4afcc287dfb3727ecc45a4afc55a5e69c15f - name: Add checkstyle-plugin @@ -43,25 +34,43 @@ runs: echo "::group::Add checkstyle plugin to the pom.xml" sed -i "/<\/sourceDirectories>/i scenarios\/""${{ inputs.test_case }}""<\/sourceDirectory>" test/plugin/pom.xml echo "::endgroup::" + - name: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-agent-test-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-maven-agent-test- - name: Build SkyWalking Agent shell: bash run: | echo "::group::Build SkyWalking Agent" # Retry one more time due to frequent "maven connection reset" - ./mvnw --batch-mode clean package -DskipTests || \ - ./mvnw --batch-mode clean package -DskipTests + ./mvnw --batch-mode clean package -Dmaven.test.skip || \ + ./mvnw --batch-mode clean package -Dmaven.test.skip echo "::endgroup::" + - uses: actions/upload-artifact@v2 + name: Upload Agent + with: + name: skywalking-agent + path: skywalking-agent - name: Build Docker Image shell: bash run: | echo "::group::Build Docker Image" # Retry one more time due to frequent "maven connection reset" - ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests -P${{ inputs.java_version }} || \ - ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests -P${{ inputs.java_version }} + ./mvnw --batch-mode -f test/plugin/pom.xml clean package -Dmaven.test.skip -P${{ inputs.java_version }} || \ + ./mvnw --batch-mode -f test/plugin/pom.xml clean package -Dmaven.test.skip -P${{ inputs.java_version }} echo "::endgroup::" - - name: Run Plugin Test ${{ inputs.test_case }} - shell: bash - run: | - echo "::group::Run Plugin Test ${{ inputs.test_case }}" - bash test/plugin/run.sh --image_version=${{ inputs.java_version }}-1.0.0 ${{ inputs.test_case }} + + echo "::group::Save Docker Image" + mkdir -p test-containers + docker save -o test-containers/skywalking-agent-test-jvm-${{ inputs.java_version }}-1.0.0.tgz skywalking/agent-test-jvm:${{ inputs.java_version }}-1.0.0 + docker save -o test-containers/skywalking-agent-test-tomcat-${{ inputs.java_version }}-1.0.0.tgz skywalking/agent-test-tomcat:${{ inputs.java_version }}-1.0.0 echo "::endgroup::" + - uses: actions/upload-artifact@v2 + name: Upload Test Containers + with: + name: test-tools + path: | + test-containers + test/plugin/dist/plugin-runner-helper.jar diff --git a/.github/actions/run/action.yml b/.github/actions/run/action.yml new file mode 100644 index 000000000..b264c3773 --- /dev/null +++ b/.github/actions/run/action.yml @@ -0,0 +1,59 @@ +# +# 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: "Run Plugin Test" +description: "Common steps when running a plugin test" +inputs: + test_case: + description: "The plugin test name" + required: true + java_version: + description: "The Java version under which this test case will run" + required: false + default: "jdk8" +runs: + using: "composite" + steps: + - uses: actions/download-artifact@v2 + with: + name: skywalking-agent + path: skywalking-agent + - uses: actions/download-artifact@v2 + with: + name: test-tools + - name: Load Test Containers + shell: bash + run: | + if ls test-containers/skywalking-agent-test-jvm-${{ inputs.java_version }}-1.0.0.tgz; then + docker load -i test-containers/skywalking-agent-test-jvm-${{ inputs.java_version }}-1.0.0.tgz + fi + if ls test-containers/skywalking-agent-test-tomcat-${{ inputs.java_version }}-1.0.0.tgz; then + docker load -i test-containers/skywalking-agent-test-tomcat-${{ inputs.java_version }}-1.0.0.tgz + fi + - name: Cache local Maven repository + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-agent-test-run-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-maven-agent-test-run- + - name: Run Plugin Test ${{ inputs.test_case }} + shell: bash + run: | + echo "::group::Run Plugin Test ${{ inputs.test_case }}" + bash test/plugin/run.sh --image_version=${{ inputs.java_version }}-1.0.0 ${{ inputs.test_case }} + echo "::endgroup::" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 893a4fa2c..c765f4c81 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,17 +20,33 @@ on: pull_request: schedule: - cron: '0 18 * * *' # TimeZone: UTC 0 + push: + branches: + - test/ci/* concurrency: group: ci-it-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: - matrix: - name: ${{ matrix.os }} - ${{ matrix.java-version }} - if: (github.event_name == 'schedule' && github.repository == 'apache/skywalking-java') || (github.event_name != 'schedule') + license: + name: Check License + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Check License Header + uses: apache/skywalking-eyes@9bd5feb86b5817aa6072b008f9866a2c3bbc8587 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build: + name: Java ${{ matrix.java-version }} / ${{ matrix.os }} runs-on: ${{ matrix.os }}-latest timeout-minutes: 60 + needs: [ license ] strategy: fail-fast: true matrix: @@ -43,17 +59,12 @@ jobs: - uses: actions/checkout@v2 with: submodules: true - - name: Check License Header - if: matrix.os == 'ubuntu' # Container GHA is only supported in Linux system - uses: apache/skywalking-eyes@9bd5feb86b5817aa6072b008f9866a2c3bbc8587 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Cache local Maven repository uses: actions/cache@v2 with: path: ~/.m2/repository - key: ${{ runner.os }}-maven-ci-${{ matrix.os }} - restore-keys: ${{ runner.os }}-maven-${{ matrix.os }} + key: ${{ runner.os }}-maven-ci-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-maven-ci- - uses: actions/setup-java@v2 with: distribution: adopt @@ -70,6 +81,6 @@ jobs: ci: name: CI runs-on: ubuntu-latest - needs: [ matrix ] + needs: [ build ] steps: - run: echo 'Success' diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index 6b093f62f..10e029e3f 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -19,8 +19,12 @@ name: "CodeQL" on: push: branches: [ 'main' ] + paths: + - '**/*.java' pull_request: branches: [ 'main' ] + paths: + - '**/*.java' schedule: - cron: '28 3 * * *' diff --git a/.github/workflows/plugins-jdk14-test.0.yaml b/.github/workflows/plugins-jdk14-test.0.yaml index 8e2bcfabf..9c5bb1448 100644 --- a/.github/workflows/plugins-jdk14-test.0.yaml +++ b/.github/workflows/plugins-jdk14-test.0.yaml @@ -26,20 +26,31 @@ on: - 'apm-sniffer/**' - 'test/plugin/**' - '**/pom.xml' - - '!test/e2e/**' - - '!apm-webapp/**' - - '!apm-dist/**' - - '!apm-dist-es7/**' - - '!apm-docker/**' - - '!oap-server/**' - '!**.md' + push: + branches: + - test/ci/* concurrency: group: plugins-jdk14-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: - PluginsJDK14Test: + build: + name: Build + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Build + uses: ./.github/actions/build + with: + java_version: jdk14 + + test: + needs: [ build ] name: ${{ matrix.case }} runs-on: ubuntu-latest timeout-minutes: 90 @@ -54,8 +65,8 @@ jobs: - uses: actions/setup-java@v1 with: java-version: 14 - - name: Run Plugin Test - uses: ./.github/actions/plugins-test + - name: Run Test + uses: ./.github/actions/run with: test_case: ${{ matrix.case }} java_version: jdk14 diff --git a/.github/workflows/plugins-test.0.yaml b/.github/workflows/plugins-test.0.yaml index 4cd2335fd..d21190329 100644 --- a/.github/workflows/plugins-test.0.yaml +++ b/.github/workflows/plugins-test.0.yaml @@ -26,20 +26,29 @@ on: - 'apm-sniffer/**' - 'test/plugin/**' - '**/pom.xml' - - '!test/e2e/**' - - '!apm-webapp/**' - - '!apm-dist/**' - - '!apm-dist-es7/**' - - '!apm-docker/**' - - '!oap-server/**' - '!**.md' + push: + branches: + - test/ci/* concurrency: group: plugins-0-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: - PluginsTest: + build: + name: Build + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Build + uses: ./.github/actions/build + + test: + needs: [ build ] name: ${{ matrix.case }} runs-on: ubuntu-latest timeout-minutes: 90 @@ -83,6 +92,6 @@ jobs: with: java-version: 8 - name: Run Plugin Test - uses: ./.github/actions/plugins-test + uses: ./.github/actions/run with: test_case: ${{ matrix.case }} diff --git a/.github/workflows/plugins-test.1.yaml b/.github/workflows/plugins-test.1.yaml index b63deba5b..25a9538ff 100644 --- a/.github/workflows/plugins-test.1.yaml +++ b/.github/workflows/plugins-test.1.yaml @@ -26,20 +26,29 @@ on: - 'apm-sniffer/**' - 'test/plugin/**' - '**/pom.xml' - - '!test/e2e/**' - - '!apm-webapp/**' - - '!apm-dist/**' - - '!apm-dist-es7/**' - - '!apm-docker/**' - - '!oap-server/**' - '!**.md' + push: + branches: + - test/ci/* concurrency: group: plugins-1-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: - PluginsTest: + build: + name: Build + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Build + uses: ./.github/actions/build + + test: + needs: [ build ] name: ${{ matrix.case }} runs-on: ubuntu-latest timeout-minutes: 90 @@ -75,6 +84,6 @@ jobs: with: java-version: 8 - name: Run Plugin Test - uses: ./.github/actions/plugins-test + uses: ./.github/actions/run with: test_case: ${{ matrix.case }} diff --git a/.github/workflows/plugins-test.2.yaml b/.github/workflows/plugins-test.2.yaml index 96f052ff3..2ded7f693 100644 --- a/.github/workflows/plugins-test.2.yaml +++ b/.github/workflows/plugins-test.2.yaml @@ -26,20 +26,29 @@ on: - 'apm-sniffer/**' - 'test/plugin/**' - '**/pom.xml' - - '!test/e2e/**' - - '!apm-webapp/**' - - '!apm-dist/**' - - '!apm-dist-es7/**' - - '!apm-docker/**' - - '!oap-server/**' - '!**.md' + push: + branches: + - test/ci/* concurrency: group: plugins-2-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: - PluginsTest: + build: + name: Build + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Build + uses: ./.github/actions/build + + test: + needs: [ build ] name: ${{ matrix.case }} runs-on: ubuntu-latest timeout-minutes: 90 @@ -77,6 +86,6 @@ jobs: with: java-version: 8 - name: Run Plugin Test - uses: ./.github/actions/plugins-test + uses: ./.github/actions/run with: test_case: ${{ matrix.case }} diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml index 8dd1cc41a..e019e19aa 100644 --- a/.github/workflows/plugins-test.3.yaml +++ b/.github/workflows/plugins-test.3.yaml @@ -26,20 +26,29 @@ on: - 'apm-sniffer/**' - 'test/plugin/**' - '**/pom.xml' - - '!test/e2e/**' - - '!apm-webapp/**' - - '!apm-dist/**' - - '!apm-dist-es7/**' - - '!apm-docker/**' - - '!oap-server/**' - '!**.md' + push: + branches: + - test/ci/* concurrency: group: plugins-3-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: - PluginsTest: + build: + name: Build + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v2 + with: + submodules: true + - name: Build + uses: ./.github/actions/build + + test: + needs: [ build ] name: ${{ matrix.case }} runs-on: ubuntu-latest timeout-minutes: 90 @@ -78,6 +87,7 @@ jobs: - jsonrpc4j-1.x-scenario - gateway-3.x-scenario - neo4j-4.x-scenario + - oracle-scenario steps: - uses: actions/checkout@v2 with: @@ -85,31 +95,14 @@ jobs: - uses: actions/setup-java@v1 with: java-version: 8 - - name: Run Plugin Test - uses: ./.github/actions/plugins-test - with: - test_case: ${{ matrix.case }} - - Oracle: - name: Oracle - runs-on: ubuntu-latest - timeout-minutes: 90 - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - uses: actions/setup-java@v1 - with: - java-version: 8 - - name: Add checkstyle-plugin - run: sed -i '/<\/sourceDirectories>/i scenarios\/oracle-scenario<\/sourceDirectory>' test/plugin/pom.xml - - name: Build SkyWalking Agent - run: ./mvnw -q --batch-mode clean package -Dmaven.test.skip - - name: Build Docker image - run: ./mvnw -q --batch-mode -f test/plugin/pom.xml clean package -Dmaven.test.skip - - name: Oracle 10.2.0.4.0 + - name: Install Oracle Libs + if: matrix.case == 'oracle-scenario' run: | + mkdir -p skywalking-agent/plugins curl -O https://skyapm.github.io/ci-assist/jars/ojdbc14-10.2.0.4.0.jar curl -L -o ./skywalking-agent/plugins/apm-oracle-10.x-plugin-2.0.0.jar https://github.com/SkyAPM/java-plugin-extensions/releases/download/2.0.0/apm-oracle-10.x-plugin-2.0.0.jar ./mvnw -q --batch-mode install:install-file -Dfile=ojdbc14-10.2.0.4.0.jar -DgroupId=com.oracle -DartifactId=ojdbc14 -Dversion=10.2.0.4.0 -Dpackaging=jar - bash test/plugin/run.sh oracle-scenario + - name: Run Plugin Test + uses: ./.github/actions/run + with: + test_case: ${{ matrix.case }} diff --git a/.github/workflows/publish-docker.yaml b/.github/workflows/publish-docker.yaml index 0327e24da..9f332277c 100644 --- a/.github/workflows/publish-docker.yaml +++ b/.github/workflows/publish-docker.yaml @@ -44,8 +44,8 @@ jobs: uses: actions/cache@v2 with: path: ~/.m2/repository - key: ${{ runner.os }}-maven-publish-docker - restore-keys: ${{ runner.os }}-maven- + key: ${{ runner.os }}-maven-publish-docker-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-maven-publish-docker- - name: Log in to the Container registry uses: docker/login-action@v1.10.0 with: