Skip to content

Dependencies management #37

Dependencies management

Dependencies management #37

name: Dependencies management
on:
schedule:
# Run each Sunday at mid day
- cron: 00 12 * * 0
workflow_dispatch:
jobs:
latest-versions:
timeout-minutes: 20
strategy:
matrix:
python-version: ['3.8'] #, '3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest]
permissions:
contents: write
pull-requests: write
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version}}
- name: Check if the latest version supported is up to date.
id: ensure-dependencies-are-up-to-date
working-directory: tools/packages
run: |
# Ensure dependencies are aligned between Taipy packages
pip install -r requirements.txt
python check-dependencies.py ensure-same-version
# Try to update the Pipfile.
# Any new packages available are printed to stdout.
# If nothing is printed, the Pipfile is up to date and workflow can stop.
echo 'diff<<EOF' >> "$GITHUB_OUTPUT"
bash check-dependencies.sh pipfiles/Pipfile${{matrix.python-version}}.max >> "$GITHUB_OUTPUT"
echo EOF >> "$GITHUB_OUTPUT"
cat pipfiles/Pipfile${{matrix.python-version}}.max
# - name: Create the pull request updating the dependencies (3.12 only)
# if: steps.ensure-dependencies-are-up-to-date.outputs.diff != '' and ${{matrix.python-version}} == '3.12'
# uses: peter-evans/create-pull-request@v5
# id: cpr
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# commit-message: Update Python${{matrix.python-version}} dependencies
# branch: dependencies/update-python${{matrix.python-version}}
# base: develop
# title: 'New dependencies available for Python${{matrix.python-version}}'
# body: |
# ${{ steps.ensure-dependencies-are-up-to-date.outputs.diff }}
# draft: false
# add-paths: |
# tools/packages/pipfiles/Pipfile${{matrix.python-version}}.max
# tools/packages/taipy*/*requirements.txt
- name: Create the pull request updating the Pipfile max
if: steps.ensure-dependencies-are-up-to-date.outputs.diff != '' and ${{matrix.python-version}} != '3.12'
uses: peter-evans/create-pull-request@v5
id: cpr
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update Python${{matrix.python-version}} Pipfile
branch: dependencies/update-python${{matrix.python-version}}
base: develop
title: 'New Pipfile available for Python${{matrix.python-version}}'
body: |
${{ steps.ensure-dependencies-are-up-to-date.outputs.diff }}
draft: false
add-paths: |
tools/packages/pipfiles/Pipfile${{matrix.python-version}}.max
# tests:
# needs: latest-versions
# uses: ./.github/workflows/overall-tests.yml
# strategy:
# matrix:
# python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
# with:
# branch: dependencies/update-python${{matrix.python-version}}
# PRs created with the GITHUB_TOKEN don't trigger workflows.
# This action triggers the overall-tests.yml workflow on the PR
# to allow the tests to run on the new dependencies.
- name: Run tests on PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.TRIGGER_GITHUB_PR }}
script: |
const result = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'overall-tests.yml',
ref: 'dependencies/update-python${{matrix.python-version}}',
})
const runs = await github.request('GET /repos/{owner}/{repo}/actions/runs', {
owner: context.repo.owner,
repo: context.repo.repo,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
})
console.log(runs.data.workflow_runs[0]);
const workflow = runs.data.workflow_runs.find(run => run.head_branch == 'dependencies/update-python${{matrix.python-version}}')
github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ steps.cpr.outputs.pull-request-number }},
body: 'Tests: ' + workflow.html_url,
});