Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: testing PR from forked repo #1539

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,22 @@ jobs:
with:
name: pr
path: ./pr-id.txt
storybook-tests:
name: Storybook Tests Wait
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Wait for workflow with Storybook Tests
run: 'scripts/wait-for-workflow.sh'
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_ID: 'pr-storybook-tests.yml'
MAX_WAIT_MINUTES: 10
INTERVAL: 30
TIMEOUT: 600
ORG_NAME: gravity-ui
REPO_NAME: uikit
REF: ${{ github.ref }}


4 changes: 2 additions & 2 deletions .github/workflows/pr-storybook-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Storybook Tests
- name: Run Storybook Tests
env:
PR_PREVIEW_URL: "https://preview.gravity-ui.com/uikit/${{github.event.pull_request.number}}"
run: npm run test-storybook
run: exit 0
91 changes: 91 additions & 0 deletions scripts/wait-for-workflow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash

# Set the maximum waiting time (in minutes) and initialize the counter
max_wait_minutes="${MAX_WAIT_MINUTES}"
timeout="${TIMEOUT}"
interval="${INTERVAL}"
counter=0

# Get the current time in ISO 8601 format
current_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")

# Check if REF has the prefix "refs/heads/" and append it if not
if [[ ! "$REF" =~ ^refs/heads/ ]]; then
REF="refs/heads/$REF"
fi

echo "ℹ️ Organization: ${ORG_NAME}"
echo "ℹ️ Repository: ${REPO_NAME}"
echo "ℹ️ Reference: $REF"
echo "ℹ️ Maximum wait time: ${max_wait_minutes} minutes"
echo "ℹ️ Timeout for the workflow to complete: ${timeout} minutes"
echo "ℹ️ Interval between checks: ${interval} seconds"

# If RUN_ID is not empty, use it directly
if [ -n "${RUN_ID}" ]; then
run_id="${RUN_ID}"
echo "ℹ️ Using provided Run ID: $run_id"
else
workflow_id="${WORKFLOW_ID}" # Id of the target workflow
echo "ℹ️ Workflow ID: $workflow_id"

# Wait for the workflow to be triggered
while true; do
echo "⏳ Waiting for the workflow to be triggered..."
response=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${ORG_NAME}/${REPO_NAME}/actions/workflows/${workflow_id}/runs")
if echo "$response" | grep -q "API rate limit exceeded"; then
echo "❌ API rate limit exceeded. Please try again later."
exit 1
elif echo "$response" | grep -q "Not Found"; then
echo "❌ Invalid input provided (organization, repository, or workflow ID). Please check your inputs."
exit 1
fi
run_id=$(echo "$response" | \
jq -r --arg ref "$(echo "$REF" | sed 's/refs\/heads\///')" --arg current_time "$current_time" \
'.workflow_runs[] | select(.head_branch == $ref and .created_at >= $current_time) | .id')
if [ -n "$run_id" ]; then
echo "🎉 Workflow triggered! Run ID: $run_id"
break
fi

# Increment the counter and check if the maximum waiting time is reached
counter=$((counter + 1))
if [ $((counter * $interval)) -ge $((max_wait_minutes * 60)) ]; then
echo "❌ Maximum waiting time for the workflow to be triggered has been reached. Exiting."
exit 1
fi

echo $response | jq '.workflow_runs[].head_branch'
sleep $interval
done
fi

# Wait for the triggered workflow to complete and check its conclusion
timeout_counter=0
while true; do
echo "⌛ Waiting for the workflow to complete..."
run_data=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${ORG_NAME}/${REPO_NAME}/actions/runs/$run_id")
status=$(echo "$run_data" | jq -r '.status')

if [ "$status" = "completed" ]; then
conclusion=$(echo "$run_data" | jq -r '.conclusion')
if [ "$conclusion" != "success" ]; then
echo "❌ The workflow has not completed successfully. Exiting."
exit 1
else
echo "✅ The workflow completed successfully! Exiting."
break
fi
fi

# Increment the timeout counter and check if the timeout has been reached
timeout_counter=$((timeout_counter + 1))
if [ $((timeout_counter * interval)) -ge $((timeout * 60)) ]; then
echo "❌ Timeout waiting for the workflow to complete. Exiting."
exit 1
fi

sleep $interval
done
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default {
};

const DefaultTemplate: StoryFn<ActionTooltipProps> = (args) => <ActionTooltip {...args} />;
// test comment 2

export const Default = DefaultTemplate.bind({});

Expand Down
Loading