Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/docker/demo/elk-stack/extensions/…
Browse files Browse the repository at this point in the history
…curator/untergeek/curator-8.0.15
  • Loading branch information
jamshale authored May 31, 2024
2 parents 1bb7ee2 + 667a6fa commit dbfd35f
Show file tree
Hide file tree
Showing 22 changed files with 932 additions and 718 deletions.
4 changes: 0 additions & 4 deletions .codecov.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/actions/run-integration-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
TEST_SCOPE:
description: "Set of flags that defines the test scope"
required: false
default: "-t @GHA"
default: "-t @PR"
IN_LEDGER_URL:
description: "URL to the von network ledger browser"
required: false
Expand All @@ -27,7 +27,7 @@ runs:
PUBLIC_TAILS_URL: ${{ inputs.IN_PUBLIC_TAILS_URL }}
LOG_LEVEL: warning
NO_TTY: "1"
working-directory: acapy/demo
working-directory: ./demo
branding:
icon: "mic"
color: "purple"
55 changes: 55 additions & 0 deletions .github/actions/run-unit-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Run Unit Tests
description: "Run unit tests for the project"

inputs:
python-version:
description: "Python version"
required: true
os:
description: "Operating system"
required: true
is_pr:
description: "Is this a PR?"
required: false
default: "true"

runs:
using: "composite"
steps:
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: 'pip'
cache-dependency-path: 'requirements*.txt'
- name: Install the project dependencies
shell: bash
run: |
pip install poetry
poetry install --all-extras
- name: Tests
shell: bash
run: |
poetry run pytest --cov=aries_cloudagent --cov-report term-missing --cov-report xml --ignore-glob=/tests/* --ignore-glob=demo/* --ignore-glob=docker/* --ignore-glob=docs/* --ignore-glob=scripts/* 2>&1 | tee pytest.log
PYTEST_EXIT_CODE=${PIPESTATUS[0]}
if grep -Eq "RuntimeWarning: coroutine .* was never awaited" pytest.log; then
echo "Failure: Detected unawaited coroutine warning in pytest output."
exit 1
fi
exit $PYTEST_EXIT_CODE
- name: Save PR number to file
if: inputs.is_pr == 'true'
shell: bash
run: echo ${{ github.event.number }} > PR_NUMBER
- name: Archive PR number
if: inputs.is_pr == 'true'
uses: actions/upload-artifact@v4
with:
name: PR_NUMBER
path: PR_NUMBER
- name: Archive Test Results
if: inputs.is_pr == 'true'
uses: actions/upload-artifact@v4
with:
name: TEST_COV
path: test-reports/coverage.xml
50 changes: 40 additions & 10 deletions .github/workflows/integrationtests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: acapy-integration-tests

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
pull_request:
branches:
Expand All @@ -18,17 +20,45 @@ jobs:
test:
runs-on: ubuntu-latest
if: (github.event_name == 'pull_request' && github.repository == 'hyperledger/aries-cloudagent-python') || (github.event_name != 'pull_request')
outputs:
is_release: ${{ steps.check_if_release.outputs.is_release }}
steps:
- name: checkout-acapy
uses: actions/checkout@v4
with:
path: acapy
#- name: run-von-network
# uses: ./acapy/.github/actions/run-von-network
#- name: run-indy-tails-server
# uses: ./acapy/.github/actions/run-indy-tails-server
- name: run-integration-tests
uses: ./acapy/.github/actions/run-integration-tests
# to run with a specific set of tests include the following parameter:
# with:
# TEST_SCOPE: "-t @T001-RFC0037"
fetch-depth: 0
- name: Check if PR is a release
id: check_if_release
continue-on-error: true
run: |
# Get the diff between the current commit and the last merge commit on the upstream/main branch
git remote add upstream https://github.com/hyperledger/aries-cloudagent-python.git
git fetch upstream
last_merge=$(git rev-list --no-merges -n 1 upstream/main)
echo event = ${{ github.event_name }}
echo last upstream commit = "$last_merge"
echo current pr commit = "${{ github.sha }}"
echo Will exit with code 1 if the pull request is not a release
changes=$(git diff "${{ github.sha }}" "$last_merge" pyproject.toml)
# Extract the version of aries-cloudagent from the diff of pyproject.toml
version=$(echo "$changes" | grep -A1 'name = "aries_cloudagent"' | head -n 2 | tail -n 1 | awk '{print $3}' | tr -d '"')
echo "$version"
if [ "$version" ]; then
echo "This is a release because the aries-cloudagent version in pyproject.toml has changes"
echo is_release=true >> $GITHUB_OUTPUT
fi
- name: run-pr-integration-tests
uses: ./.github/actions/run-integration-tests
if: (steps.check_if_release.outputs.is_release != 'true' && github.event_name == 'pull_request')
- name: run-release-or-cron-integration-tests
if: (steps.check_if_release.outputs.is_release == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
uses: ./.github/actions/run-integration-tests
with:
TEST_SCOPE: "-t @Release"
17 changes: 11 additions & 6 deletions .github/workflows/nigthly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ on:

jobs:
tests:
if: github.repository == 'hyperledger/aries-cloudagent-python' || github.event_name == 'workflow_dispatch'
name: Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.9", "3.10"]
uses: ./.github/workflows/tests.yml
with:
python-version: ${{ matrix.python-version }}
os: ${{ matrix.os }}
if: github.repository == 'hyperledger/aries-cloudagent-python' || github.event_name == 'workflow_dispatch'
steps:
- name: checkout
uses: actions/checkout@v4
- name: Tests
uses: ./.github/actions/run-unit-tests
with:
python-version: ${{ matrix.python-version }}
os: ${{ matrix.os }}
is_pr: "false"

setup_and_check_pub:
name: Setup Publish
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ concurrency:

jobs:
tests:
name: Tests
uses: ./.github/workflows/tests.yml
with:
python-version: "3.9"
os: "ubuntu-latest"
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Tests
uses: ./.github/actions/run-unit-tests
with:
python-version: "3.9"
os: "ubuntu-latest"
is_pr: "true"
34 changes: 34 additions & 0 deletions .github/workflows/sonar-merge-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Sonar Scan and Coverage
on:
push:
branches:
- main

jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Tests
uses: ./.github/actions/run-unit-tests
with:
python-version: "3.9"
os: "ubuntu-latest"
is_pr: "false"
- name: Adjust Test Coverage Source
run: |
# Need to change source in coverage report because it was generated from another context
sed -i 's/\/home\/runner\/work\/aries-cloudagent-python\/aries-cloudagent-python\//\/github\/workspace\//g' test-reports/coverage.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.python.coverage.reportPaths=test-reports/coverage.xml
-Dsonar.coverage.exclusions=**/tests/*,**/demo/*,**/docs/*,**/docker/*,**/scripts/*
-Dsonar.sources=./
73 changes: 73 additions & 0 deletions .github/workflows/sonar-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Sonar Scan and Coverage

on:
workflow_run:
workflows: [ PR Tests ]
types:
- completed

jobs:
SonarCloud:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download PR number artifact
uses: dawidd6/action-download-artifact@v3
with:
workflow: Tests
run_id: ${{ github.event.workflow_run.id }}
name: PR_NUMBER
- name: Read PR_NUMBER
id: pr_number
uses: juliangruber/read-file-action@v1
with:
path: ./PR_NUMBER
- name: Download Test Coverage
uses: dawidd6/action-download-artifact@v3
with:
workflow: Tests
run_id: ${{ github.event.workflow_run.id }}
name: TEST_COV
- name: Request GitHub API for PR data
uses: octokit/[email protected]
id: get_pr_data
with:
route: GET /repos/${{ github.event.repository.full_name }}/pulls/${{ steps.pr_number.outputs.content }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout base branch
run: |
echo forked repo = ${{ fromJson(steps.get_pr_data.outputs.data).head.repo.html_url }}.git
echo base repo = ${{ github.event.repository.clone_url }}
git remote add upstream ${{ fromJson(steps.get_pr_data.outputs.data).head.repo.html_url }}.git
git fetch --all
echo pr number = ${{ fromJson(steps.get_pr_data.outputs.data).number }}
echo forked branch = ${{ fromJson(steps.get_pr_data.outputs.data).head.ref }}
echo base branch = ${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}
git checkout -B temp-branch-for-scanning upstream/${{ fromJson(steps.get_pr_data.outputs.data).head.ref }}
- name: Move Coverage Report And Adjust Source
run: |
mkdir test-reports
mv coverage.xml test-reports
# Need to change source in coverage report because it was generated from another context
sed -i 's/\/home\/runner\/work\/aries-cloudagent-python\/aries-cloudagent-python\//\/github\/workspace\//g' test-reports/coverage.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.scm.revision=${{ github.event.workflow_run.head_sha }}
-Dsonar.pullrequest.key=${{ fromJson(steps.get_pr_data.outputs.data).number }}
-Dsonar.pullrequest.branch=${{ fromJson(steps.get_pr_data.outputs.data).head.ref }}
-Dsonar.pullrequest.base=${{ fromJson(steps.get_pr_data.outputs.data).base.ref }}
-Dsonar.coverage.exclusions=**/tests/*,**/demo/*,**/docs/*,**/docker/*,**/scripts/*
-Dsonar.python.coverage.reportPaths=test-reports/coverage.xml
-Dsonar.sources=./
37 changes: 0 additions & 37 deletions .github/workflows/tests.yml

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Hyperledger Aries Cloud Agent - Python <!-- omit in toc -->

[![pypi releases](https://img.shields.io/pypi/v/aries_cloudagent)](https://pypi.org/project/aries-cloudagent/)
[![codecov](https://codecov.io/gh/hyperledger/aries-cloudagent-python/branch/main/graph/badge.svg)](https://codecov.io/gh/hyperledger/aries-cloudagent-python)

<!-- ![logo](/doc/assets/aries-cloudagent-python-logo-bw.png) -->

Expand Down
23 changes: 23 additions & 0 deletions aries_cloudagent/ledger/indy_vdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,29 @@ async def get_revoc_reg_delta(
) from err

response_value = response["data"]["value"]
accum_to = response_value.get("accum_to")

# If accum_to is not present, then the timestamp_to was before the registry
# was created. In this case, we need to fetch the registry creation timestamp and
# re-calculate the delta.
if not accum_to:
try:
(_, timestamp) = await self.get_revoc_reg_entry(
revoc_reg_id, int(time())
)
fetch_req = ledger.build_get_revoc_reg_delta_request(
public_info and public_info.did,
revoc_reg_id,
timestamp_from,
timestamp,
)
response = await self._submit(fetch_req, sign_did=public_info)
response_value = response["data"]["value"]
except VdrError as err:
raise LedgerError(
f"get_revoc_reg_delta failed for revoc_reg_id='{revoc_reg_id}'"
) from err

delta_value = {
"accum": response_value["accum_to"]["value"]["accum"],
"issued": response_value.get("issued", []),
Expand Down
Loading

0 comments on commit dbfd35f

Please sign in to comment.