From 9e6e016a99a17f89ae5f548b5d8b02ad429ed3d9 Mon Sep 17 00:00:00 2001 From: Nicholas Felt Date: Mon, 10 Jun 2024 11:01:50 -0700 Subject: [PATCH] ci: Update the updater workflow to skip running poetry-audit during the updater process (#235) * ci: Update the updater workflow to skip running a hook that can't be run * ci: Update publisher workflows to better handle secondary rate limitations from GitHub --- .github/workflows/publish-api-comparison.yml | 39 +++++++++++++------ .github/workflows/publish-test-results.yml | 39 +++++++++++++------ ...ate-python-and-pre-commit-dependencies.yml | 2 +- 3 files changed, 57 insertions(+), 23 deletions(-) diff --git a/.github/workflows/publish-api-comparison.yml b/.github/workflows/publish-api-comparison.yml index f101f5fe..d1e17854 100644 --- a/.github/workflows/publish-api-comparison.yml +++ b/.github/workflows/publish-api-comparison.yml @@ -31,18 +31,35 @@ jobs: uses: actions/github-script@v7 with: script: | - const response = await github.rest.search.issuesAndPullRequests({ - q: 'repo:${{ github.repository }} is:pr sha:${{ github.event.workflow_run.head_sha }}', - per_page: 1, - }) - const items = response.data.items - if (items.length < 1) { - console.error('No PRs found') - return + const maxAttempts = 5; + let attempt = 0; + let pullRequestNumber; + while (attempt < maxAttempts) { + try { + const response = await github.rest.search.issuesAndPullRequests({ + q: 'repo:${{ github.repository }} is:pr sha:${{ github.event.workflow_run.head_sha }}', + per_page: 1, + }); + const items = response.data.items; + if (items.length < 1) { + throw new Error('No PRs found'); + } + pullRequestNumber = items[0].number; + console.info("Pull request number is", pullRequestNumber); + break; // Exit loop on success + } catch (error) { + console.error(`Attempt ${attempt + 1} failed:`, error.message); + if (attempt < maxAttempts - 1) { // Check if not last attempt + console.log(`Waiting for 2 minutes before retrying...`); + await new Promise(resolve => setTimeout(resolve, 120000)); // Wait for 2 minutes + } + } + attempt++; } - const pullRequestNumber = items[0].number - console.info("Pull request number is", pullRequestNumber) - return pullRequestNumber + if (!pullRequestNumber) { + core.setFailed("Failed to fetch PR number after 5 attempts"); + } + return pullRequestNumber; - name: Publish API Breaking Changes Check Results uses: marocchino/sticky-pull-request-comment@v2 if: ${{ env.BREAKING_CHANGES == 'true' }} diff --git a/.github/workflows/publish-test-results.yml b/.github/workflows/publish-test-results.yml index fa8943e2..a5a4daff 100644 --- a/.github/workflows/publish-test-results.yml +++ b/.github/workflows/publish-test-results.yml @@ -28,18 +28,35 @@ jobs: uses: actions/github-script@v7 with: script: | - const response = await github.rest.search.issuesAndPullRequests({ - q: 'repo:${{ github.repository }} is:pr sha:${{ github.event.workflow_run.head_sha }}', - per_page: 1, - }) - const items = response.data.items - if (items.length < 1) { - console.error('No PRs found') - return + const maxAttempts = 5; + let attempt = 0; + let pullRequestNumber; + while (attempt < maxAttempts) { + try { + const response = await github.rest.search.issuesAndPullRequests({ + q: 'repo:${{ github.repository }} is:pr sha:${{ github.event.workflow_run.head_sha }}', + per_page: 1, + }); + const items = response.data.items; + if (items.length < 1) { + throw new Error('No PRs found'); + } + pullRequestNumber = items[0].number; + console.info("Pull request number is", pullRequestNumber); + break; // Exit loop on success + } catch (error) { + console.error(`Attempt ${attempt + 1} failed:`, error.message); + if (attempt < maxAttempts - 1) { // Check if not last attempt + console.log(`Waiting for 2 minutes before retrying...`); + await new Promise(resolve => setTimeout(resolve, 120000)); // Wait for 2 minutes + } + } + attempt++; } - const pullRequestNumber = items[0].number - console.info("Pull request number is", pullRequestNumber) - return pullRequestNumber + if (!pullRequestNumber) { + core.setFailed("Failed to fetch PR number after 5 attempts"); + } + return pullRequestNumber; - name: Publish Test Results uses: marocchino/sticky-pull-request-comment@v2 with: diff --git a/.github/workflows/update-python-and-pre-commit-dependencies.yml b/.github/workflows/update-python-and-pre-commit-dependencies.yml index 2e632698..a68551ea 100644 --- a/.github/workflows/update-python-and-pre-commit-dependencies.yml +++ b/.github/workflows/update-python-and-pre-commit-dependencies.yml @@ -41,7 +41,7 @@ jobs: - name: Run pre-commit continue-on-error: true env: - SKIP: ${{ inputs.pre-commit-hook-skip-list || 'pylint,pyright,pyright-verifytypes,pyroma' }} + SKIP: ${{ inputs.pre-commit-hook-skip-list || 'pylint,pyright,pyright-verifytypes,pyroma,poetry-audit' }} run: python -m pre_commit run --all - uses: stefanzweifel/git-auto-commit-action@v5 with: