kyma-project / test-infra

Test infrastructure for the Kyma project.
https://status.build.kyma-project.io/
Apache License 2.0
37 stars 180 forks source link

Migrate pre-main-check-users-map to Github action #9768

Open Sawthis opened 10 months ago

Sawthis commented 10 months ago

Description

Create a Cloud Run service that will generate a file in Google Cloud Firestore containing Slack user mappings. Below is the relevant code snippet that demonstrates the function:

from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError

with open('/etc/slack-secret/common-slack-bot-token-test', encoding='utf-8') as token_file:
    slack_bot_token = token_file.readline()

slack_client = WebClient(token=slack_bot_token)

def get_slack_user_mapping():
    '''Fetches Slack users and returns a mapping of real names to Slack IDs'''
    try:
        users = {}
        cursor = None
        while True:
            response = slack_client.users_list(cursor=cursor)
            for member in response['members']:
                real_name = member.get('real_name')
                slack_id = member.get('id')
                if real_name and slack_id:
                    users[real_name] = slack_id
            cursor = response['response_metadata'].get('next_cursor')
            if not cursor:
                break
        return users
    except SlackApiError as e:
        print(LogEntry(
            severity="ERROR",
            message=f"Error fetching Slack users: {e.response['error']}",
            **prepare_log_fields(),
        ))
        return {}

The Cloud Run service should be configured to:

Additionally, modify the SlackMessageSender Cloud Run / GitHub-webhook-gateway Cloud Run to:

If a user is not found, the application should invoke the above Cloud Run service to reload the file and confirm it has completed the operation.

Reasons

Migration out from Prow.

Acceptance Criteria

Attachments

https://github.com/kyma-project/test-infra/issues/9470

github-actions[bot] commented 8 months ago

This issue has been automatically marked as stale due to the lack of recent activity. It will soon be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 7 months ago

This issue has been automatically closed due to the lack of recent activity. /lifecycle rotten

akiioto commented 1 month ago

https://github.com/kyma-project/test-infra/pull/12121