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

[ODS-6577] Verify dependent workflows are success or not- Step Added #1189

Closed
wants to merge 16 commits into from

Conversation

semalaiappan
Copy link
Contributor

No description provided.

@semalaiappan semalaiappan requested a review from a team as a code owner December 11, 2024 02:01
@semalaiappan semalaiappan changed the title [ODS-6577] Wait for dependent workflows to complete- Step Added [ODS-6577] Verify dependent workflows are success or not- Step Added Dec 12, 2024
Copy link
Contributor

@axelmarquezh axelmarquezh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, please make the next changes to Publish to Docker Hub and Docker Test so that they don't execute 3 times every time we merge to main:

  • Remove any github.event.workflow_run.conclusion == 'success' checks
  • Add a call to ahmadnassri/action-workflow-run-wait in a similar way we do in this workflow

@@ -41,7 +42,7 @@ jobs:
build:

runs-on: ubuntu-24.04
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
if: ${{ github.event_name == 'workflow_dispatch' }}
Copy link
Contributor

@axelmarquezh axelmarquezh Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, it will no longer be executed on merges to main; it will only be executed on manual dispatches.
This if should be removed altogether.

Comment on lines 60 to 108
run: |
$workflowNames = @("InitDev, Smoke Tests.yml", "InitDev Postgres, Unit tests, Integration tests.yml", "InitDev, MultiTenancy.yml")
$sha = "${{ github.event.workflow_run.head_sha }}"
Write-Host "sha is $sha"

Write-Host "Checking workflow statuses..."
$allSuccess = $true

foreach ($workflow in $workflowNames) {

$url = "https://api.github.com/repos/Ed-Fi-Alliance-OSS/Ed-Fi-ODS-Implementation/actions/workflows/$workflow/runs?head_sha=$sha"
$headers = @{
Authorization = "Bearer $env:EDFI_ODS_TOKEN"
Accept = "application/vnd.github.v3+json"
}

$response = Invoke-RestMethod -Uri $url -Headers $headers

if ($response.workflow_runs.Count -eq 0) {
Write-Host "No runs found for workflow: $workflow"
$allSuccess = $false
break
}

$latestRun = $response.workflow_runs | Sort-Object -Property created_at -Descending | Select-Object -First 1
if ($latestRun.conclusion -ne "success") {
Write-Host "latest Run status is $latestRun.status"
$allSuccess = $false
break
}
}

if ($allSuccess) {
Write-Host "All workflows completed successfully."
break
}

if (-not $allSuccess) {
Write-Host "one or more workflows failed.So cancelling the build"
exit 1
}
shell: pwsh
# Adding a step to ensure the build job fails if it was skipped
- name: Fail the build job if skipped
if: ${{ needs.FindStandardAndExtensionVersions.result == 'skipped' }}
run: |
echo "Build job was skipped due to a failure in the previous job."
exit 1
shell: pwsh
Copy link
Contributor

@axelmarquezh axelmarquezh Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes aren't needed since the GitHub action ahmadnassri/action-workflow-run-wait that we use below already does these checks internally.

We just need to remove the if from my previous comment so that the GitHub action gets executed.

@axelmarquezh axelmarquezh deleted the ODS-6577 branch January 7, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants