Skip to content

Commit

Permalink
Merge pull request #54 from jamshale/release
Browse files Browse the repository at this point in the history
Release Workflows
  • Loading branch information
jamshale authored Apr 16, 2024
2 parents e6e754e + 8411171 commit d63fafb
Show file tree
Hide file tree
Showing 9 changed files with 2,917 additions and 21 deletions.
194 changes: 194 additions & 0 deletions .github/workflows/create-release-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
name: Create Release PR

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"


permissions:
contents: write

jobs:

checks:
name: "Create Release PR"
permissions: write-all
runs-on: ubuntu-latest
outputs:
current_available_version: ${{ steps.current_available_version.outputs.version }}
current_global_version: ${{ steps.current_global_version.outputs.version }}
upgrade_available: ${{ steps.current_global_version.outputs.available }}
lint_plugins: ${{ steps.lint_plugins.outputs.lint_plugins }}
unit_test_plugins: ${{ steps.unit_test_plugins.outputs.unit_test_plugins }}
integration_test_plugins: ${{ steps.integration_test_plugins.outputs.integration_test_plugins }}
defaults:
run:
working-directory: .
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Install poetry
run: pipx install poetry
id: setup-poetry

- name: Get latest aries-cloudagent version
id: current_available_version
run: |
remote_version=$(pip index versions aries-cloudagent)
version=$(grep -oP '(?<=Available versions: ).*?(?=,)' <<< "$remote_version")
echo current_available_version=$version >> $GITHUB_OUTPUT
echo "Remote version = $version"
- name: Get global aries-cloudagent version from plugins repo
id: current_global_version
run: |
cd plugin_globals
lock_version=$(grep -A1 'name = "aries-cloudagent"' poetry.lock | grep -v 'name = "aries-cloudagent"')
version=$(grep -oP '(?<=").*?(?=")' <<< "$lock_version")
echo current_global_version=$version >> $GITHUB_OUTPUT
echo "Global version = $version"
- name: Check if aries-cloudagent upgrade available
run: |
current_available_version="${{steps.current_available_version.outputs.current_available_version}}"
echo "Remote version = $current_available_version"
current_global_version="${{steps.current_global_version.outputs.current_global_version}}"
echo "Global version = $current_global_version"
sem_version () {
echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }';
}
if [ $(sem_version $current_global_version) -ge $(sem_version $current_available_version) ]; then
echo "Version of aries-cloudagent is up to date"
available=false
exit 1
fi
echo "Detected aries-cloudagent upgrade available..."
available=true
- name: Update global acapy version
run: |
python repo_manager.py 2
echo "Update global acapy version"
- name: Run global updates
run: |
python repo_manager.py 3
echo "Upgrade all plugins"
- name: Lint plugins
id: lint_plugins
continue-on-error: true
run: |
declare -a failed_plugins=()
for dir in ./*/; do
current_folder=$(basename "$dir")
if [[ $current_folder == "plugin_globals" ]]; then
continue
fi
cd $current_folder
poetry install --no-interaction --no-root --extras "aca-py"
if poetry run ruff check .; then
echo "plugin $current_folder passed lint check"
else
echo "plugin $current_folder failed lint check"
failed_plugins+=("$current_folder")
fi
cd ..
done
echo lint_plugins=${failed_plugins[*]} >> $GITHUB_OUTPUT
- name: Unit Test Plugins
id: unit_test_plugins
continue-on-error: true
run: |
declare -a failed_plugins=()
for dir in ./*/; do
current_folder=$(basename "$dir")
if [[ $current_folder == "plugin_globals" ]]; then
continue
fi
cd $current_folder
poetry install --no-interaction --no-root --extras "aca-py"
if poetry run pytest; then
echo "plugin $current_folder passed unit test check"
else
echo "plugin $current_folder failed unit test check"
failed_plugins+=("$current_folder")
fi
cd ..
done
echo unit_test_plugins=${failed_plugins[*]} >> $GITHUB_OUTPUT
# - name: Initialize Docker Compose
# uses: isbang/[email protected]
# - name: Integration Test Plugins
# id: integration_test_plugins
# continue-on-error: true
# run: |
# declare -a failed_plugins=()
# for dir in ./*/; do
# current_folder=$(basename "$dir")
# if [[ $current_folder == "plugin_globals" ]]; then
# continue
# fi
# cd $current_folder/integration
# docker compose down --remove-orphans
# docker compose build
# if docker compose run tests; then
# echo "plugin $current_folder passed integration test check"
# else
# echo "plugin $current_folder failed integration test check"
# failed_plugins+=("$current_folder")
# fi
# cd ../..
# done
# echo integration_test_plugins=${failed_plugins[*]} >> $GITHUB_OUTPUT
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "${{steps.lint_plugins.outputs.lint_plugins}}"
echo "${{steps.unit_test_plugins.outputs.unit_test_plugins}}"
echo "${{steps.integration_test_plugins.outputs.integration_test_plugins}}"
echo "Merging failed plugins"
failed_plugins=()
lint_plugins=(${{steps.lint_plugins.outputs.lint_plugins}})
unit_test_plugins=(${{steps.unit_test_plugins.outputs.unit_test_plugins}})
for plugin in "${lint_plugins[@]}"; do
if [[ ! " ${failed_plugins[@]} " =~ " $plugin " ]]; then
failed_plugins+=("$plugin")
fi
done
for plugin in "${unit_test_plugins[@]}"; do
if [[ ! " ${failed_plugins[@]} " =~ " $plugin " ]]; then
failed_plugins+=("$plugin")
fi
done
echo "Failed plugins: ${failed_plugins[*]}"
release="${{steps.current_available_version.outputs.current_available_version}}"
echo "Remote version = $release"
git config --global user.name 'Release Bot'
git config --global user.email '[email protected]'
git remote set-url --push origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/jamshale/aries-acapy-plugins
git fetch --all
git checkout -b "release-v$release"
git add .
for plugin in "${failed_plugins[@]}"; do
git restore --staged $plugin
git checkout -- $plugin
done
body=$(python repo_manager.py 4)
git add ./*pyproject.toml
git commit -s -m "Pre-Release Upgrades"
git push --set-upstream origin "release-v$release"
title="Release for aries-cloudagent v$release"
gh pr create --title "$title" --body "$body" --base main --head "release-v$release"
56 changes: 56 additions & 0 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Create Release

on: workflow_dispatch

permissions:
contents: write

jobs:

checks:
name: "Create Release"
permissions: write-all
runs-on: ubuntu-latest
defaults:
run:
working-directory: .
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Creating release"
remote_version=$(pip index versions aries-cloudagent)
version=$(grep -oP '(?<=Available versions: ).*?(?=,)' <<< "$remote_version")
git config --global user.name 'Release Bot'
git config --global user.email '[email protected]'
git remote set-url --push origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/jamshale/aries-acapy-plugins
git fetch --all
tag_output=(git tag -n0 "*$version*")
tags=0
for item in $tag_output
do
tags=$((tags+1))
done
echo "Tags: $tags"
tag=""
if [ $tags -eq 0 ]
then
tag=$version
else
tag="$version.$((tags+1))"
fi
git tag -a $tag -m "Release $tag"
git push origin $tag
gh release create $tag --title "Release for aries-cloudagent v$version" --notes "Release $tag"
2 changes: 1 addition & 1 deletion .github/workflows/pr-integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
echo "changed-plugins=${changed_dirs[*]}" >> $GITHUB_OUTPUT
#----------------------------------------------
# Get changed plugins
# Run Integation Tests
#----------------------------------------------
- name: Run Integration Tests
id: integration-tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ async def test_basic_message_send_does_not_save_if_disabled(
with asynctest.patch.object(test_module, "get_config") as mock_config:
mock_config.return_value = asynctest.Mock(wallet_enabled=True)
await plugin_connections_send_message(self.request)
assert not mock_basic_message_rec.save.assert_called()
assert not mock_basic_message_rec.save.assert_called()
13 changes: 7 additions & 6 deletions connection_update/connection_update/v1_0/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import logging

from aiohttp import web
from aiohttp_apispec import docs, match_info_schema, response_schema, request_schema
from aiohttp_apispec import (docs, match_info_schema, request_schema,
response_schema)
from aries_cloudagent.admin.request_context import AdminRequestContext
from aries_cloudagent.connections.models.conn_record import ConnRecord, ConnRecordSchema
from aries_cloudagent.connections.models.conn_record import (ConnRecord,
ConnRecordSchema)
from aries_cloudagent.messaging.models.base import BaseModelError
from aries_cloudagent.messaging.models.openapi import OpenAPISchema
from aries_cloudagent.protocols.connections.v1_0.routes import (
ConnectionsConnIdMatchInfoSchema,
)
from aries_cloudagent.storage.error import StorageNotFoundError, StorageError
from aries_cloudagent.protocols.connections.v1_0.routes import \
ConnectionsConnIdMatchInfoSchema
from aries_cloudagent.storage.error import StorageError, StorageNotFoundError
from marshmallow import fields

LOGGER = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def test_connections_update_saves_with_alias_from_body(self, mock_retrieve

mock_retrieve.return_value.save.assert_called
assert mock_retrieve.return_value.alias == 'test-alias'

async def test_register(self):
mock_app = async_mock.MagicMock()
mock_app.add_routes = async_mock.MagicMock()
Expand Down
Loading

0 comments on commit d63fafb

Please sign in to comment.