From 52acba6c784320cae9e2574b46f6ff6bfb556827 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Fri, 30 Sep 2022 02:29:56 -0600 Subject: [PATCH 1/8] Use well-known JUnit-to-annotations GitHub Action --- .github/workflows/tr.unit.tests.yaml | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tr.unit.tests.yaml b/.github/workflows/tr.unit.tests.yaml index 9e17e3e5ad..0e3bfdfaf8 100644 --- a/.github/workflows/tr.unit.tests.yaml +++ b/.github/workflows/tr.unit.tests.yaml @@ -50,7 +50,7 @@ jobs: - name: Import cached Alpine Docker image run: .github/actions/save-alpine-tar/entrypoint.sh load ${{ env.ALPINE_VERSION }} - name: Cache local Maven repository - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ${{ github.workspace }}/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} @@ -59,23 +59,15 @@ jobs: - name: Run Traffic Router unit tests uses: ./.github/actions/tr-unit-tests - name: Upload Surefire Reports - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: ${{ failure() }} with: name: surefire-reports - path: ${{ github.workspace }}/traffic_router/core/target/surefire-reports/TEST-*.xml - - name: Checkout junit-report-annotations action - uses: actions/checkout@v2 - with: - repository: zrhoffman/junit-report-annotations-action - ref: 399056ab38c3da69c5b27f924357e10aec3caf8f # Fri Sep 25 02:02:53 2020 -0600 Make all properties string type (see actions/toolkit#398) - path: .github/actions/junit-report-annotations - - name: Convert Junit Report to Annotations - uses: ./.github/actions/junit-report-annotations + path: ${{ github.workspace }}/traffic_router/*/target/*-reports/TEST-*.xml + - name: Convert Junit Reports to Annotations + uses: mikepenz/action-junit-report@v3 with: - path: ${{ github.workspace }}/traffic_router/core/target/surefire-reports/TEST-*.xml - numFailures: 999 # The maximum number of test failures to annotate - cwd: ${{ github.workspace }}/traffic_router - if: always() + report_paths: ${{ github.workspace }}/traffic_router/*/target/*-reports/TEST-*.xml + if: ${{ always() }} - name: Save Alpine Docker image run: .github/actions/save-alpine-tar/entrypoint.sh save ${{ env.ALPINE_VERSION }} From 3063d7beef6cc6cf119a4696e68d2e9cf9b38dfe Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Fri, 30 Sep 2022 03:24:24 -0600 Subject: [PATCH 2/8] Run Traffic Router unit tests directly from the GHA runner --- .github/workflows/tr.unit.tests.yaml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tr.unit.tests.yaml b/.github/workflows/tr.unit.tests.yaml index 0e3bfdfaf8..f917c69ebd 100644 --- a/.github/workflows/tr.unit.tests.yaml +++ b/.github/workflows/tr.unit.tests.yaml @@ -18,8 +18,7 @@ name: Traffic Router Unit Tests env: - # alpine:3.13 - ALPINE_VERSION: sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930 + M2_HOME: ${{ github.workspace }}/.m2 on: push: @@ -42,22 +41,18 @@ jobs: steps: - name: Checkout uses: actions/checkout@master - - name: Cache Alpine Docker image - uses: actions/cache@v2 - with: - path: ${{ github.workspace }}/docker-images - key: docker-images/alpine@${{ env.ALPINE_VERSION }}.tar.gz - - name: Import cached Alpine Docker image - run: .github/actions/save-alpine-tar/entrypoint.sh load ${{ env.ALPINE_VERSION }} + - name: Install Java dependencies + run: sudo apt -y install libtcnative-1 maven - name: Cache local Maven repository uses: actions/cache@v3 with: - path: ${{ github.workspace }}/.m2/repository + path: ${{ env.M2_HOME }} key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- - name: Run Traffic Router unit tests - uses: ./.github/actions/tr-unit-tests + run: mvn -Djava.library.path=/usr/lib/x86_64-linux-gnu test + working-directory: ${{ github.workspace }}/traffic_router - name: Upload Surefire Reports uses: actions/upload-artifact@v3 if: ${{ failure() }} @@ -69,5 +64,3 @@ jobs: with: report_paths: ${{ github.workspace }}/traffic_router/*/target/*-reports/TEST-*.xml if: ${{ always() }} - - name: Save Alpine Docker image - run: .github/actions/save-alpine-tar/entrypoint.sh save ${{ env.ALPINE_VERSION }} From a6e9178c8c64ffd2e84ca759e607d07b40f377a3 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Fri, 30 Sep 2022 04:49:34 -0600 Subject: [PATCH 3/8] Remove unused GitHub Action tr-unit-tests --- .github/actions/tr-unit-tests/Dockerfile | 26 ------------ .github/actions/tr-unit-tests/README.md | 54 ------------------------ .github/actions/tr-unit-tests/action.yml | 22 ---------- .github/workflows/tr.unit.tests.yaml | 2 - 4 files changed, 104 deletions(-) delete mode 100644 .github/actions/tr-unit-tests/Dockerfile delete mode 100644 .github/actions/tr-unit-tests/README.md delete mode 100644 .github/actions/tr-unit-tests/action.yml diff --git a/.github/actions/tr-unit-tests/Dockerfile b/.github/actions/tr-unit-tests/Dockerfile deleted file mode 100644 index 5b73ed5b41..0000000000 --- a/.github/actions/tr-unit-tests/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -# -# 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 -# -# https://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. -# - -# alpine:3.13 -FROM alpine@sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930 - -RUN apk add --no-cache \ - openjdk11 \ - maven \ - tomcat-native - -ENTRYPOINT cd traffic_router && \ - export JAVA_HOME="$(command -v java | xargs realpath | xargs dirname)/.." && \ - mvn "-Dmaven.repo.local=${GITHUB_WORKSPACE}/.m2/repository" \ - test -Djava.library.path=/usr/share/java diff --git a/.github/actions/tr-unit-tests/README.md b/.github/actions/tr-unit-tests/README.md deleted file mode 100644 index 71f843d0f8..0000000000 --- a/.github/actions/tr-unit-tests/README.md +++ /dev/null @@ -1,54 +0,0 @@ - - -# tr-unit-tests Docker action -This action runs the Traffic Router unit tests in an Alpine Docker container. - -## Inputs - -## Outputs - -### `exit-code` -0 for success, nonzero for failure - -## Example usage -```yaml -jobs: - tests: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@master - - name: Cache local Maven repository - uses: actions/cache@v2 - with: - path: ${{ github.workspace }}/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven- - - name: Run unit tests - uses: ./.github/actions/tr-unit-tests -``` - -To run the tests locally: -```shell -export GITHUB_WORKSPACE='/github/workspace'; -docker build -f .github/actions/tr-unit-tests/Dockerfile -t tr-unit-tests .; -docker run --rm -te GITHUB_WORKSPACE -v "$(pwd):${GITHUB_WORKSPACE}" -w "$GITHUB_WORKSPACE" tr-unit-tests; -``` diff --git a/.github/actions/tr-unit-tests/action.yml b/.github/actions/tr-unit-tests/action.yml deleted file mode 100644 index 6ae7be74c1..0000000000 --- a/.github/actions/tr-unit-tests/action.yml +++ /dev/null @@ -1,22 +0,0 @@ -# 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 -# -# https://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: tr-unit-tests -description: Runs Traffic Ops unit tests -runs: - using: docker - image: Dockerfile diff --git a/.github/workflows/tr.unit.tests.yaml b/.github/workflows/tr.unit.tests.yaml index f917c69ebd..45ed71c666 100644 --- a/.github/workflows/tr.unit.tests.yaml +++ b/.github/workflows/tr.unit.tests.yaml @@ -23,13 +23,11 @@ env: on: push: paths: - - .github/actions/tr-unit-tests/** - .github/workflows/tr.unit.tests.yaml - traffic_router/** create: pull_request: paths: - - .github/actions/tr-unit-tests/** - .github/workflows/tr.unit.tests.yaml - traffic_router/** types: [ opened, reopened, ready_for_review, synchronize ] From b2abb11cad359293515005caf48f42b52e7aac31 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Fri, 30 Sep 2022 04:58:46 -0600 Subject: [PATCH 4/8] Run integration tests too --- .../{tr.unit.tests.yaml => tr.tests.yaml} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename .github/workflows/{tr.unit.tests.yaml => tr.tests.yaml} (86%) diff --git a/.github/workflows/tr.unit.tests.yaml b/.github/workflows/tr.tests.yaml similarity index 86% rename from .github/workflows/tr.unit.tests.yaml rename to .github/workflows/tr.tests.yaml index 45ed71c666..f97ca46543 100644 --- a/.github/workflows/tr.unit.tests.yaml +++ b/.github/workflows/tr.tests.yaml @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -name: Traffic Router Unit Tests +name: Traffic Router Tests env: M2_HOME: ${{ github.workspace }}/.m2 @@ -23,12 +23,12 @@ env: on: push: paths: - - .github/workflows/tr.unit.tests.yaml + - .github/workflows/tr.tests.yaml - traffic_router/** create: pull_request: paths: - - .github/workflows/tr.unit.tests.yaml + - .github/workflows/tr.tests.yaml - traffic_router/** types: [ opened, reopened, ready_for_review, synchronize ] @@ -48,14 +48,14 @@ jobs: key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- - - name: Run Traffic Router unit tests - run: mvn -Djava.library.path=/usr/lib/x86_64-linux-gnu test + - name: Run Traffic Router tests + run: mvn -Djava.library.path=/usr/lib/x86_64-linux-gnu verify working-directory: ${{ github.workspace }}/traffic_router - - name: Upload Surefire Reports + - name: Upload Surefire and Failsafe Reports uses: actions/upload-artifact@v3 if: ${{ failure() }} with: - name: surefire-reports + name: junit-reports path: ${{ github.workspace }}/traffic_router/*/target/*-reports/TEST-*.xml - name: Convert Junit Reports to Annotations uses: mikepenz/action-junit-report@v3 From 0d8617617f9c8956e51f6eb3659f21af0cf82cd5 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Fri, 30 Sep 2022 03:38:44 -0600 Subject: [PATCH 5/8] Set traffic_router_rpm dummy environment variables --- .github/workflows/tr.tests.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/tr.tests.yaml b/.github/workflows/tr.tests.yaml index f97ca46543..f7cadca5f3 100644 --- a/.github/workflows/tr.tests.yaml +++ b/.github/workflows/tr.tests.yaml @@ -19,6 +19,14 @@ name: Traffic Router Tests env: M2_HOME: ${{ github.workspace }}/.m2 + # environment variables for traffic_router_rpm + BUILD_LOCK: build_lock + BUILD_NUMBER: build_number + RHEL_VERSION: rhel_version + STARTUP_SCRIPT_DIR: /startup-dir + STARTUP_SCRIPT_LOC: ../core/src/main/lib/systemd/system + TOMCAT_RELEASE: tomcat_release + TOMCAT_VERSION: tomcat_version on: push: From fb5f81b0b32f6e4748f92a970fd9e3d4ba4672eb Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Fri, 30 Sep 2022 03:26:08 -0600 Subject: [PATCH 6/8] Only run TPv2 tests workflow when TPV2 tests-related paths are modified --- .github/workflows/tpv2.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tpv2.yml b/.github/workflows/tpv2.yml index 7968059e98..c236d102eb 100644 --- a/.github/workflows/tpv2.yml +++ b/.github/workflows/tpv2.yml @@ -22,6 +22,10 @@ env: on: push: + paths: + - experimental/traffic-portal/** + - .github/workflows/tpv2.yml + - .github/actions/tpv2-integration-tests create: pull_request: paths: From 077d53087c387b52e7fd643dbba3582e4b022188 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Fri, 30 Sep 2022 12:40:56 -0600 Subject: [PATCH 7/8] Use default maven repository path --- .github/workflows/tr.tests.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tr.tests.yaml b/.github/workflows/tr.tests.yaml index f7cadca5f3..095f09c94f 100644 --- a/.github/workflows/tr.tests.yaml +++ b/.github/workflows/tr.tests.yaml @@ -18,7 +18,6 @@ name: Traffic Router Tests env: - M2_HOME: ${{ github.workspace }}/.m2 # environment variables for traffic_router_rpm BUILD_LOCK: build_lock BUILD_NUMBER: build_number @@ -52,7 +51,7 @@ jobs: - name: Cache local Maven repository uses: actions/cache@v3 with: - path: ${{ env.M2_HOME }} + path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- From 7483eaa03256456e36881f1a72d72eabddb94ea4 Mon Sep 17 00:00:00 2001 From: Zach Hoffman Date: Fri, 30 Sep 2022 12:22:57 -0600 Subject: [PATCH 8/8] Revert "Use well-known JUnit-to-annotations GitHub Action" This reverts commit 52acba6c784320cae9e2574b46f6ff6bfb556827. --- .github/workflows/tr.tests.yaml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tr.tests.yaml b/.github/workflows/tr.tests.yaml index 095f09c94f..764f1b01c9 100644 --- a/.github/workflows/tr.tests.yaml +++ b/.github/workflows/tr.tests.yaml @@ -64,8 +64,17 @@ jobs: with: name: junit-reports path: ${{ github.workspace }}/traffic_router/*/target/*-reports/TEST-*.xml - - name: Convert Junit Reports to Annotations - uses: mikepenz/action-junit-report@v3 + - name: Checkout junit-report-annotations action + if: ${{ always() }} + uses: actions/checkout@v3 with: - report_paths: ${{ github.workspace }}/traffic_router/*/target/*-reports/TEST-*.xml + repository: zrhoffman/junit-report-annotations-action + ref: 399056ab38c3da69c5b27f924357e10aec3caf8f # Fri Sep 25 02:02:53 2020 -0600 Make all properties string type (see actions/toolkit#398) + path: .github/actions/junit-report-annotations + - name: Convert Junit Report to Annotations if: ${{ always() }} + uses: ./.github/actions/junit-report-annotations + with: + path: ${{ github.workspace }}/traffic_router/core/*/*-reports/TEST-*.xml + numFailures: 999 # The maximum number of test failures to annotate + cwd: ${{ github.workspace }}/traffic_router