chore: update CI workflow to check PyPI package version updates (#8025)
chore: update CI workflow to check for PyPI package version updates instead of nightly status
This commit is contained in:
parent
056440842a
commit
74adc58370
1 changed files with 57 additions and 27 deletions
84
.github/workflows/ci.yml
vendored
84
.github/workflows/ci.yml
vendored
|
|
@ -46,40 +46,69 @@ concurrency:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-nightly-status:
|
check-nightly-status:
|
||||||
name: Check Nightly Status
|
name: Check PyPI Version Update
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
should-proceed: ${{ steps.check-workflow.outputs.success }}
|
should-proceed: ${{ steps.check-pypi.outputs.success }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check nightly workflow status
|
- name: Check PyPI package update
|
||||||
id: check-workflow
|
id: check-pypi
|
||||||
uses: actions/github-script@v7
|
run: |
|
||||||
with:
|
# Get today's date in ISO format for comparison
|
||||||
script: |
|
TODAY=$(date -u +"%Y-%m-%d")
|
||||||
const workflow_name = 'nightly_build.yml';
|
echo "Today's date: $TODAY"
|
||||||
const today = new Date();
|
|
||||||
today.setHours(0, 0, 0, 0); // Set to beginning of day
|
|
||||||
|
|
||||||
const { data: runs } = await github.rest.actions.listWorkflowRuns({
|
# Query PyPI API for the langflow package
|
||||||
owner: context.repo.owner,
|
HTTP_STATUS=$(curl -s -o response.json -w "%{http_code}" https://pypi.org/pypi/langflow-nightly/json)
|
||||||
repo: context.repo.repo,
|
|
||||||
workflow_id: workflow_name,
|
|
||||||
created: `>=${today.toISOString()}`,
|
|
||||||
per_page: 100, // Get more runs to check
|
|
||||||
status: 'completed'
|
|
||||||
});
|
|
||||||
|
|
||||||
if (runs.workflow_runs.length === 0) {
|
# Check HTTP status code first
|
||||||
console.log('No completed workflow runs found today');
|
if [ "$HTTP_STATUS" -ne 200 ]; then
|
||||||
return core.setOutput('success', 'true');
|
echo "Error: PyPI API returned HTTP status $HTTP_STATUS"
|
||||||
}
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
// Check if any runs today were successful
|
# Check if response is valid JSON before proceeding
|
||||||
const successfulTodayRuns = runs.workflow_runs.filter(run => run.conclusion === 'success');
|
if ! jq -e . response.json >/dev/null 2>&1; then
|
||||||
const hasSuccessfulRunToday = successfulTodayRuns.length > 0;
|
echo "Error: Invalid JSON response from PyPI API"
|
||||||
|
echo "Response preview:"
|
||||||
|
head -n 10 response.json
|
||||||
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
console.log(`Found ${runs.workflow_runs.length} completed runs today, ${successfulTodayRuns.length} successful`);
|
# Extract the latest version
|
||||||
core.setOutput('success', hasSuccessfulRunToday.toString());
|
LATEST_VERSION=$(jq -r '.info.version // empty' response.json)
|
||||||
|
|
||||||
|
if [ -z "$LATEST_VERSION" ]; then
|
||||||
|
echo "Could not extract latest version"
|
||||||
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract the release date of the latest version
|
||||||
|
RELEASE_DATE=$(jq -r --arg ver "$LATEST_VERSION" '.releases[$ver][0].upload_time_iso_8601 // empty' response.json | cut -d'T' -f1)
|
||||||
|
|
||||||
|
if [ -z "$RELEASE_DATE" ]; then
|
||||||
|
echo "Could not extract release date"
|
||||||
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Latest version: $LATEST_VERSION"
|
||||||
|
echo "Release date: $RELEASE_DATE"
|
||||||
|
|
||||||
|
# Check if the release date is today
|
||||||
|
if [[ "$RELEASE_DATE" == "$TODAY" ]]; then
|
||||||
|
echo "Package was updated today"
|
||||||
|
echo "success=true" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "Package was not updated today"
|
||||||
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -f response.json
|
||||||
|
|
||||||
set-ci-condition:
|
set-ci-condition:
|
||||||
needs: check-nightly-status
|
needs: check-nightly-status
|
||||||
|
|
@ -133,6 +162,7 @@ jobs:
|
||||||
uses: ./.github/workflows/python_test.yml
|
uses: ./.github/workflows/python_test.yml
|
||||||
with:
|
with:
|
||||||
python-versions: ${{ inputs.python-versions || '["3.10"]' }}
|
python-versions: ${{ inputs.python-versions || '["3.10"]' }}
|
||||||
|
|
||||||
test-frontend:
|
test-frontend:
|
||||||
needs: [path-filter, set-ci-condition]
|
needs: [path-filter, set-ci-condition]
|
||||||
name: Run Frontend Tests
|
name: Run Frontend Tests
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue