Skip to content

Commit

Permalink
Post statuses earlier (GoogleCloudPlatform#10128)
Browse files Browse the repository at this point in the history
* Post initial statuses earlier so that we are resilient issues during cloning

* force generation

* Revert "force generation"

This reverts commit 864ec92.
  • Loading branch information
melinath authored and balanaguharsha committed May 2, 2024
1 parent 7f95e88 commit 6f44db2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/test-tgc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Get Job URL
if: ${{ !cancelled() }}
id: get_job
run: |
response=$(curl --get -Ss -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs")
html_url=$(echo "$response" | jq -r --arg job_name "${{ github.job }}" '.jobs | map(select(.name == $job_name)) | .[0].html_url')
echo "url=${html_url}" >> $GITHUB_OUTPUT
- name: Post Pending Status to Pull Request
if: ${{ !cancelled() }}
run: |
curl -X POST -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/GoogleCloudPlatform/magic-modules/statuses/${{github.event.inputs.sha}}" \
-d '{
"context": "${{ github.event.inputs.repo }}${{ env.status_suffix }}",
"target_url": "${{ steps.get_job.outputs.url }}",
"state": "pending"
}'
- name: Checkout Repository
uses: actions/checkout@v4
with:
Expand All @@ -58,24 +76,6 @@ jobs:
else
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Get Job URL
if: ${{ !cancelled() }}
id: get_job
run: |
response=$(curl --get -Ss -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs")
html_url=$(echo "$response" | jq -r --arg job_name "${{ github.job }}" '.jobs | map(select(.name == $job_name)) | .[0].html_url')
echo "url=${html_url}" >> $GITHUB_OUTPUT
- name: Post Pending Status to Pull Request
if: ${{ !cancelled() }}
run: |
curl -X POST -H "Authorization: token ${{secrets.GITHUB_TOKEN}}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/GoogleCloudPlatform/magic-modules/statuses/${{github.event.inputs.sha}}" \
-d '{
"context": "${{ github.event.inputs.repo }}${{ env.status_suffix }}",
"target_url": "${{ steps.get_job.outputs.url }}",
"state": "pending"
}'
- name: Set up Go
if: ${{ !failure() && steps.pull_request.outputs.has_changes == 'true' }}
uses: actions/setup-go@v4
Expand Down
31 changes: 15 additions & 16 deletions .github/workflows/test-tpg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
repository: ${{ github.event.inputs.owner }}/${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.branch }}
fetch-depth: 2
- name: Check for Code Changes
id: pull_request
run: |
gofiles=$(git diff --name-only HEAD~1 | { grep -e "\.go$" -e "go.mod$" -e "go.sum$" || test $? = 1; })
if [ -z "$gofiles" ]; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Get Job URL
if: ${{ !cancelled() }}
id: get_job
run: |
response=$(curl --get -Ss -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs")
Expand All @@ -67,6 +51,21 @@ jobs:
"target_url": "${{ steps.get_job.outputs.url }}",
"state": "pending"
}'
- name: Checkout Repository
uses: actions/checkout@v4
with:
repository: ${{ github.event.inputs.owner }}/${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.branch }}
fetch-depth: 2
- name: Check for Code Changes
id: pull_request
run: |
gofiles=$(git diff --name-only HEAD~1 | { grep -e "\.go$" -e "go.mod$" -e "go.sum$" || test $? = 1; })
if [ -z "$gofiles" ]; then
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Set up Go
if: ${{ !failure() && steps.pull_request.outputs.has_changes == 'true' }}
uses: actions/setup-go@v4
Expand Down

0 comments on commit 6f44db2

Please sign in to comment.