diff --git a/.github/scripts/dependencies-management/link-worklow-to-pr.js b/.github/scripts/dependencies-management/link-worklow-to-pr.js new file mode 100644 index 0000000000..49f17b49b2 --- /dev/null +++ b/.github/scripts/dependencies-management/link-worklow-to-pr.js @@ -0,0 +1,30 @@ +module.exports = async ({github, context, branchTargetted}) => { + // The current pull request number to link the workflow run. + const pullRequestNumber = process.env.PULL_REQUEST_NUMBER; + + // Retrieve the workflow runs for the repository. + 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' + } + }) + + // Retrieve the workflow run for the branch targetted. + const workflow = runs.data.workflow_runs.find(run => run.head_branch == branchTargetted) + + // Handle the error case. + let message = `No tests found for the branch ${branchTargetted}`; + if (workflow) { + message = `Tests ran: [Tests results](${workflow.html_url})`; + } + + // Update the pull request with the link to the workflow run. + github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pullRequestNumber, + body: message, + }); +} \ No newline at end of file diff --git a/.github/scripts/dependencies-management/run-workflow.js b/.github/scripts/dependencies-management/run-workflow.js new file mode 100644 index 0000000000..762e0c2011 --- /dev/null +++ b/.github/scripts/dependencies-management/run-workflow.js @@ -0,0 +1,8 @@ +module.exports = async ({github, context, branchTargetted, workflowToTrigger}) => { + await github.rest.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: workflowToTrigger, + ref: branchTargetted, + }) +} \ No newline at end of file diff --git a/.github/scripts/run-overall-tests.js b/.github/scripts/run-overall-tests.js deleted file mode 100644 index 24d39da545..0000000000 --- a/.github/scripts/run-overall-tests.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = async ({github, context, core, branchTargetted}) => { - const workflowRunId = process.env.PULL_REQUEST_NUMBER; - - await github.rest.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: 'overall-tests.yml', - ref: branchTargetted, - }) - 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' - } - }) - - const workflow = runs.data.workflow_runs.find(run => run.head_branch == branchTargetted) - github.rest.pulls.update({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: workflowRunId, - body: `Tests: ${workflow.html_url}`, - }); -} \ No newline at end of file diff --git a/.github/workflows/dependencies-management.yml b/.github/workflows/dependencies-management.yml index 0edab81785..4232fa2c59 100644 --- a/.github/workflows/dependencies-management.yml +++ b/.github/workflows/dependencies-management.yml @@ -12,7 +12,7 @@ jobs: timeout-minutes: 20 strategy: matrix: - python-version: ['3.8'] #, '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] os: [ubuntu-latest] permissions: contents: write @@ -40,21 +40,21 @@ jobs: 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 - # 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 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 + 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' @@ -79,6 +79,11 @@ jobs: with: github-token: ${{ secrets.TRIGGER_GITHUB_PR }} script: | - const script = require('.github/scripts/run-overall-tests.js') + const runTests = require('.github/scripts/dependencies-management/run-workflow.js') + const linkTests = require('.github/scripts/dependencies-management/link-workflow-to-pr.js') + const branchTargetted = `dependencies/update-python${{matrix.python-version}}` - await script({github, context, core, branchTargetted}) + const workflowToTrigger = 'overall-tests.yml'; + + await runTests({github, context, branchTargetted, workflowToTrigger}) + await linkTests({github, context, branchTargetted})