dependencies-management.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # This workflow is used to manage the dependencies of the Taipy packages.
  2. # - Runs each Sunday.
  3. # - For each Python version supported:
  4. # - Call a custom script to align dependencies between Taipy packages.
  5. # - Call a custom script to update dependencies (Pipfile and requirements.txt).
  6. # - If a new package version is available for the Python version:
  7. # - The Python version's Pull Request (PR) is created.
  8. # - If the Python version is the latest supported, the PR contains an updated Pipfile and requirements.txt.
  9. # - Otherwise, the PR contains the updated Pipfile.
  10. # - The action triggers tests workflow to test compatibility and link the workflow to the PR in the description.
  11. name: Dependencies management
  12. on:
  13. schedule:
  14. # Run each Sunday at mid day
  15. - cron: 00 12 * * 0
  16. workflow_dispatch:
  17. jobs:
  18. latest-versions:
  19. timeout-minutes: 20
  20. strategy:
  21. matrix:
  22. python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
  23. os: [ubuntu-latest]
  24. permissions:
  25. contents: write
  26. pull-requests: write
  27. runs-on: ${{ matrix.os }}
  28. steps:
  29. - uses: actions/checkout@v4
  30. - uses: actions/setup-python@v5
  31. with:
  32. python-version: ${{matrix.python-version}}
  33. - name: Check if the latest version supported is up to date.
  34. id: ensure-dependencies-are-up-to-date
  35. working-directory: tools/packages
  36. run: |
  37. # Ensure dependencies are aligned between Taipy packages
  38. pip install -r requirements.txt
  39. python check-dependencies.py ensure-same-version
  40. # Try to update the Pipfile.
  41. # Any new packages available are printed to stdout.
  42. # If nothing is printed, the Pipfile is up to date and workflow can stop.
  43. echo 'diff<<EOF' >> "$GITHUB_OUTPUT"
  44. bash check-dependencies.sh pipfiles/Pipfile${{matrix.python-version}}.max >> "$GITHUB_OUTPUT"
  45. echo EOF >> "$GITHUB_OUTPUT"
  46. cat pipfiles/Pipfile${{matrix.python-version}}.max
  47. - name: Create the pull request updating the dependencies (3.12 only)
  48. if: steps.ensure-dependencies-are-up-to-date.outputs.diff != '' && matrix.python-version == '3.12'
  49. uses: peter-evans/create-pull-request@v5
  50. with:
  51. token: ${{ secrets.GITHUB_TOKEN }}
  52. commit-message: Update Python${{matrix.python-version}} dependencies
  53. branch: dependencies/update-python${{matrix.python-version}}
  54. base: develop
  55. title: 'New dependencies available for Python${{matrix.python-version}}'
  56. body: |
  57. ${{ steps.ensure-dependencies-are-up-to-date.outputs.diff }}
  58. draft: false
  59. add-paths: |
  60. tools/packages/pipfiles/Pipfile${{matrix.python-version}}.max
  61. tools/packages/taipy*/*requirements.txt
  62. - name: Create the pull request updating the Pipfile max
  63. if: steps.ensure-dependencies-are-up-to-date.outputs.diff != '' && matrix.python-version != '3.12'
  64. uses: peter-evans/create-pull-request@v5
  65. with:
  66. token: ${{ secrets.GITHUB_TOKEN }}
  67. commit-message: Update Python${{matrix.python-version}} Pipfile
  68. branch: dependencies/update-python${{matrix.python-version}}
  69. base: develop
  70. title: 'New Pipfile available for Python${{matrix.python-version}}'
  71. body: |
  72. ${{ steps.ensure-dependencies-are-up-to-date.outputs.diff }}
  73. draft: false
  74. add-paths: |
  75. tools/packages/pipfiles/Pipfile${{matrix.python-version}}.max
  76. # PRs created with the GITHUB_TOKEN don't trigger workflows.
  77. # This action triggers the overall-tests.yml workflow on the PR
  78. # to allow the tests to run on the new dependencies.
  79. - name: Run tests on PR
  80. uses: actions/github-script@v7
  81. with:
  82. github-token: ${{ secrets.TRIGGER_GITHUB_PR }}
  83. script: |
  84. const runTests = require('.github/scripts/run-workflow.js')
  85. const linkTests = require('.github/scripts/link-workflow-to-pr.js')
  86. // Branch to target with the workflow run.
  87. const branchTargeted = "dependencies/update-python${{matrix.python-version}}";
  88. // The current pull request number to link the workflow run.
  89. const pullRequestNumber = process.env.PULL_REQUEST_NUMBER;
  90. // The workflow file to trigger.
  91. const workflowToTrigger = 'overall-tests.yml';
  92. const waitForWorkflowCreation = 120000; // 2 minutes
  93. // Run the tests.
  94. await runTests({github, context, branchTargeted, workflowToTrigger});
  95. // Wait for the workflow to be created.
  96. await new Promise(r => setTimeout(r, waitForWorkflowCreation));
  97. // Link the workflow to the PR.
  98. await linkTests({github, context, branchTargeted, pullRequestNumber});