From 8af2196c240399f9656e5d9f30f21e15731240db Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Mon, 19 Aug 2024 21:35:34 -0400 Subject: [PATCH 1/5] Add allure steps to CI workflow --- .github/workflows/ci.yml | 30 +++++++++++++++++++++++++++--- poetry.lock | 32 +++++++++++++++++++++++++++++++- pyproject.toml | 1 + 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e3390cd..b5950c76 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,18 +59,42 @@ jobs: - run: poetry install --no-root --all-extras - run: poe lint - run: poe build-develop - - run: poe test -s -o log_cli_level=DEBUG + - run: poe test -s --alluredir allure-results -o log_cli_level=DEBUG # Time skipping doesn't yet support ARM - if: ${{ !endsWith(matrix.os, '-arm') }} - run: poe test -s -o log_cli_level=DEBUG --workflow-environment time-skipping + run: poe test -s --alluredir allure-results -o log_cli_level=DEBUG --workflow-environment time-skipping # Check cloud if proper target and not on fork - if: ${{ matrix.cloudTestTarget && (github.event.pull_request.head.repo.full_name == '' || github.event.pull_request.head.repo.full_name == 'temporalio/sdk-python') }} - run: poe test -s -o log_cli_level=DEBUG -k test_cloud_client + run: poe test -s --alluredir allure-results -o log_cli_level=DEBUG -k test_cloud_client env: TEMPORAL_CLIENT_CLOUD_API_KEY: ${{ secrets.TEMPORAL_CLIENT_CLOUD_API_KEY }} TEMPORAL_CLIENT_CLOUD_API_VERSION: 2024-05-13-00 TEMPORAL_CLIENT_CLOUD_NAMESPACE: sdk-ci.a2dd6 + # https://allurereport.org/docs/integrations-github/ + + - name: "Allure: load test report history" + uses: actions/checkout@v4 + if: always() + continue-on-error: true + with: + ref: gh-pages + path: allure-data + - name: "Allure: build test report" + uses: simple-elf/allure-report-action@v1.9 + if: always() + with: + gh_pages: allure-data + allure_history: allure-history + allure_results: allure-results + - name: "Allure: publish test report" + uses: peaceiris/actions-gh-pages@v4 + if: always() + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_branch: gh-pages + publish_dir: allure-history + # Confirm protos are already generated properly with older protobuf # library and run test with that older version. We must downgrade protobuf # so we can generate 3.x and 4.x compatible API. We have to use older diff --git a/poetry.lock b/poetry.lock index 9d63ea1f..0274b58b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,5 +1,35 @@ # This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +[[package]] +name = "allure-pytest" +version = "2.13.5" +description = "Allure pytest integration" +optional = false +python-versions = "*" +files = [ + {file = "allure-pytest-2.13.5.tar.gz", hash = "sha256:0ef8e1790c44a988db6b83c4d4f5e91451e2c4c8ea10601dfa88528d23afcf6e"}, + {file = "allure_pytest-2.13.5-py3-none-any.whl", hash = "sha256:94130bac32964b78058e62cf4b815ad97a5ac82a065e6dd2d43abac2be7640fc"}, +] + +[package.dependencies] +allure-python-commons = "2.13.5" +pytest = ">=4.5.0" + +[[package]] +name = "allure-python-commons" +version = "2.13.5" +description = "('Contains the API for end users as well as helper functions and classes to build Allure adapters for Python test frameworks',)" +optional = false +python-versions = ">=3.6" +files = [ + {file = "allure-python-commons-2.13.5.tar.gz", hash = "sha256:a232e7955811f988e49a4c1dd6c16cce7e9b81d0ea0422b1e5654d3254e2caf3"}, + {file = "allure_python_commons-2.13.5-py3-none-any.whl", hash = "sha256:8b0e837b6e32d810adec563f49e1d04127a5b6770e0232065b7cb09b9953980d"}, +] + +[package.dependencies] +attrs = ">=16.0.0" +pluggy = ">=0.4.0" + [[package]] name = "appdirs" version = "1.4.4" @@ -1754,4 +1784,4 @@ opentelemetry = ["opentelemetry-api", "opentelemetry-sdk"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "0e394859d0cd8522c57955db0e9358eacf18609cd0bd4bb0611403f2de7952c4" +content-hash = "1cf07eeb6b5bc0fcab9b618459b836b6653df8f2e67003e99abe51f1dc05754c" diff --git a/pyproject.toml b/pyproject.toml index a4ad2890..70a42e14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,7 @@ types-protobuf = ">=3.20" typing-extensions = "^4.2.0" [tool.poetry.dev-dependencies] +allure-pytest = "^2.13.5" cibuildwheel = "^2.19.0" grpcio-tools = "^1.48.0" mypy = "^1.0.0" From 0e41233a2af510e60ef6e6065dbf3d02f46ad6cb Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Tue, 20 Aug 2024 07:11:11 -0400 Subject: [PATCH 2/5] Use separate job for allure to support non-linux builds Run simple-elf/allure-report-action@v1.9 Error: Container action is only supported on Linux --- .github/workflows/ci.yml | 76 ++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5950c76..608f5966 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,42 +59,27 @@ jobs: - run: poetry install --no-root --all-extras - run: poe lint - run: poe build-develop + # TODO: handle matrix build structure with allure - run: poe test -s --alluredir allure-results -o log_cli_level=DEBUG + - name: "Allure: upload artifact" + uses: actions/upload-artifact@master + if: always() + with: + # TODO: handle matrix build structure with allure + name: allure-results + path: allure-results + retention-days: 30 # Time skipping doesn't yet support ARM - if: ${{ !endsWith(matrix.os, '-arm') }} - run: poe test -s --alluredir allure-results -o log_cli_level=DEBUG --workflow-environment time-skipping + run: poe test -s -o log_cli_level=DEBUG --workflow-environment time-skipping # Check cloud if proper target and not on fork - if: ${{ matrix.cloudTestTarget && (github.event.pull_request.head.repo.full_name == '' || github.event.pull_request.head.repo.full_name == 'temporalio/sdk-python') }} - run: poe test -s --alluredir allure-results -o log_cli_level=DEBUG -k test_cloud_client + run: poe test -s -o log_cli_level=DEBUG -k test_cloud_client env: TEMPORAL_CLIENT_CLOUD_API_KEY: ${{ secrets.TEMPORAL_CLIENT_CLOUD_API_KEY }} TEMPORAL_CLIENT_CLOUD_API_VERSION: 2024-05-13-00 TEMPORAL_CLIENT_CLOUD_NAMESPACE: sdk-ci.a2dd6 - # https://allurereport.org/docs/integrations-github/ - - - name: "Allure: load test report history" - uses: actions/checkout@v4 - if: always() - continue-on-error: true - with: - ref: gh-pages - path: allure-data - - name: "Allure: build test report" - uses: simple-elf/allure-report-action@v1.9 - if: always() - with: - gh_pages: allure-data - allure_history: allure-history - allure_results: allure-results - - name: "Allure: publish test report" - uses: peaceiris/actions-gh-pages@v4 - if: always() - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_branch: gh-pages - publish_dir: allure-history - # Confirm protos are already generated properly with older protobuf # library and run test with that older version. We must downgrade protobuf # so we can generate 3.x and 4.x compatible API. We have to use older @@ -135,3 +120,42 @@ jobs: version: ${{github.event.pull_request.head.ref}} version-is-repo-ref: true features-repo-ref: python-update-updates + + # https://allurereport.org/docs/integrations-github/ + # https://github.com/simple-elf/allure-report-action/issues/28#issuecomment-1139332329 + + create-allure-report: + name: "Allure: load previous history, create report, and publish" + needs: build-lint-test + runs-on: ubuntu-latest + steps: + - name: "Allure: Download Artifacts" + uses: actions/download-artifact@v3 + id: download + with: + name: allure-results + path: allure-results + + - name: "Allure: load test report history" + uses: actions/checkout@v4 + if: always() + continue-on-error: true + with: + ref: gh-pages + path: allure-report-data + + - name: "Allure: build test report" + uses: simple-elf/allure-report-action@v1.9 + if: always() + with: + gh_pages: allure-report-data + allure_results: allure-results + allure_history: allure-history + + - name: "Allure: publish test report" + uses: peaceiris/actions-gh-pages@v4 + if: always() + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_branch: gh-pages + publish_dir: allure-history From f14c05593cb9db34a342e72fde3f9fee72ce40c3 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Tue, 20 Aug 2024 07:28:55 -0400 Subject: [PATCH 3/5] Use build matrix for allure --- .github/workflows/ci.yml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 608f5966..267461e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,15 +59,14 @@ jobs: - run: poetry install --no-root --all-extras - run: poe lint - run: poe build-develop - # TODO: handle matrix build structure with allure - - run: poe test -s --alluredir allure-results -o log_cli_level=DEBUG + - run: poe test -s --alluredir allure-results-${{ matrix.python }}-${{ matrix.os }} -o log_cli_level=DEBUG - name: "Allure: upload artifact" uses: actions/upload-artifact@master if: always() with: # TODO: handle matrix build structure with allure - name: allure-results - path: allure-results + name: allure-results-${{ matrix.python }}-${{ matrix.os }} + path: allure-results-${{ matrix.python }}-${{ matrix.os }} retention-days: 30 # Time skipping doesn't yet support ARM - if: ${{ !endsWith(matrix.os, '-arm') }} @@ -128,13 +127,20 @@ jobs: name: "Allure: load previous history, create report, and publish" needs: build-lint-test runs-on: ubuntu-latest + strategy: + matrix: + python: ["3.8", "3.12"] + os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest] + exclude: + - os: macos-arm + python: "3.8" steps: - name: "Allure: Download Artifacts" uses: actions/download-artifact@v3 id: download with: + path: allure-results-${{ matrix.python }}-${{ matrix.os }} name: allure-results - path: allure-results - name: "Allure: load test report history" uses: actions/checkout@v4 @@ -142,15 +148,15 @@ jobs: continue-on-error: true with: ref: gh-pages - path: allure-report-data + path: allure-report-data-${{ matrix.python }}-${{ matrix.os }} - name: "Allure: build test report" uses: simple-elf/allure-report-action@v1.9 if: always() with: - gh_pages: allure-report-data + gh_pages: allure-report-data-${{ matrix.python }}-${{ matrix.os }} allure_results: allure-results - allure_history: allure-history + allure_history: allure-history-${{ matrix.python }}-${{ matrix.os }} - name: "Allure: publish test report" uses: peaceiris/actions-gh-pages@v4 @@ -158,4 +164,4 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_branch: gh-pages - publish_dir: allure-history + publish_dir: allure-history-${{ matrix.python }}-${{ matrix.os }} From 4d620543a13335f7fa45c32a7b3d99c3bf7b83c9 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Tue, 20 Aug 2024 08:12:13 -0400 Subject: [PATCH 4/5] Creat allure report even if `needs` job failed --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 267461e6..9b631f65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,6 +126,7 @@ jobs: create-allure-report: name: "Allure: load previous history, create report, and publish" needs: build-lint-test + if: always() runs-on: ubuntu-latest strategy: matrix: From 520799e5faabd9946a87b8d0b053c07ae85ec319 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Tue, 20 Aug 2024 10:58:11 -0400 Subject: [PATCH 5/5] Retry the pushes to gh-pages to try to avoid reject-on-push failure --- .github/workflows/ci.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b631f65..981e69bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,7 +121,7 @@ jobs: features-repo-ref: python-update-updates # https://allurereport.org/docs/integrations-github/ - # https://github.com/simple-elf/allure-report-action/issues/28#issuecomment-1139332329 + # This must be a separate job since it uses container actions that are linux-only. create-allure-report: name: "Allure: load previous history, create report, and publish" @@ -160,9 +160,11 @@ jobs: allure_history: allure-history-${{ matrix.python }}-${{ matrix.os }} - name: "Allure: publish test report" - uses: peaceiris/actions-gh-pages@v4 if: always() + uses: Wandalen/wretry.action@master with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_branch: gh-pages - publish_dir: allure-history-${{ matrix.python }}-${{ matrix.os }} + action: peaceiris/actions-gh-pages@v4 + with: | + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_branch: gh-pages + publish_dir: allure-history-${{ matrix.python }}-${{ matrix.os }}