Skip to content

Commit

Permalink
Update dependencies managemnt
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-vuillemot committed Apr 12, 2024
1 parent 327bd1d commit 4379258
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 43 deletions.
30 changes: 30 additions & 0 deletions .github/scripts/dependencies-management/link-worklow-to-pr.js
Original file line number Diff line number Diff line change
@@ -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.

Check failure on line 14 in .github/scripts/dependencies-management/link-worklow-to-pr.js

View workflow job for this annotation

GitHub Actions / Check for spelling errors

targetted ==> targeted
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,
});
}
8 changes: 8 additions & 0 deletions .github/scripts/dependencies-management/run-workflow.js
Original file line number Diff line number Diff line change
@@ -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,
})
}
25 changes: 0 additions & 25 deletions .github/scripts/run-overall-tests.js

This file was deleted.

41 changes: 23 additions & 18 deletions .github/workflows/dependencies-management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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})

0 comments on commit 4379258

Please sign in to comment.