GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Cache on ghes by tiwarishub · Pull Request #363 · actions/setup-python

Conversation

@tiwarishub

@tiwarishub tiwarishub commented Mar 29, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Description:
This PR adds caching support in setup-python for GHES with version 3.5. It checks the presence of Actions cache service(which is used for caching dependencies in GHES and dotcom) using recent @actions/cache tookit package function i.e isFeatureAvailable. This same function can be applied to dotcom scenario (github.com) so this function can be safely applied to dotcom scenario as well.
I have tested the below scenarios

  1. When AC (Action cache) service is not present in GHES

image

  1. AC present in GHES. Cache save

image

  1. AC present in GHES. restored saved cache.

image

  1. Without choosing the cache option in GHES

image

  1. On Dotcom, with the cache option chosen
    save https://github.com/tiwarishub/python-caching/actions/runs/2060198424
    image

restore https://github.com/tiwarishub/python-caching/runs/5741964174?check_suite_focus=true
image

  1. On Dotcom, without cache option is chosen https://github.com/tiwarishub/python-caching/runs/5741986713?check_suite_focus=true
    image

Note
v3 version of setup-python is not published to GHES 3.4 so with this we will also release v3 version of setup-python. Please let us know if there is any issue with that.

Related issue:
#362

Check list:

  • Mark if documentation changes are required.
  • Mark if tests were added or updated to cover the changes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
tiwarishub added 5 commits March 29, 2022 12:54
@tiwarishub
initial changes
c1f6351
@tiwarishub
updated version
0c2c19b
@tiwarishub
format check
e6ed85b
@tiwarishub
refactored code
3dff462
@tiwarishub
updated test cases
d46988a
@tiwarishub

tiwarishub commented Mar 29, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Few CI checks are failing but I believe this is failing on master so I think it ok to ignore it?
I have not added the workflow runs links of the GHES scenarios. If anyone want please ping me on slack then it will GHES host and password

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tiwarishub
tiwarishub marked this pull request as ready for review March 29, 2022 17:54
@tiwarishub
tiwarishub requested a review from a team March 29, 2022 17:54
@tiwarishub tiwarishub mentioned this pull request Mar 29, 2022
Caching Support for GHES #362
Closed
brcrista
brcrista reviewed Mar 29, 2022
View reviewed changes
Comment thread src/utils.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

brcrista
brcrista reviewed Mar 29, 2022
View reviewed changes
Comment thread src/utils.ts Outdated
Comment on lines +111 to +113
throw new Error(
'An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.'
);

@brcrista brcrista Mar 29, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: we don't want an issue with the cache service to block otherwise successful runs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@brcrista brcrista Mar 29, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite the conversation on the case above, I think this still stands as a place where we should warn instead of fail.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tiwarishub tiwarishub Mar 29, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense. I will update the PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tiwarishub tiwarishub Mar 29, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the PR

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
brcrista
brcrista suggested changes Mar 29, 2022
View reviewed changes

@brcrista brcrista left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should consider using warnings instead of errors for caching failures.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
tiwarishub and others added 6 commits March 30, 2022 00:48
@tiwarishub @brcrista
Update src/utils.ts
f477cc3
Co-authored-by: Brian Cristante <[email protected]>
@tiwarishub
Update utils.ts
f3f9e75
@tiwarishub
Update utils.test.ts
74a60ed
@tiwarishub
review comments
c5c30f5
@tiwarishub
Merge branch 'cacheOnGhes' of github.com:tiwarishub/setup-python into…
298ed7c
… cacheOnGhes
@tiwarishub
dist update
85413f7
bishal-pdMSFT
bishal-pdMSFT approved these changes Mar 30, 2022
View reviewed changes

@bishal-pdMSFT bishal-pdMSFT left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
dmitry-shibanov
dmitry-shibanov approved these changes Mar 30, 2022
View reviewed changes
vsafonkin
vsafonkin reviewed Mar 30, 2022
View reviewed changes
Comment thread src/utils.ts
Comment on lines +108 to +110
throw new Error(
'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'
);

@vsafonkin vsafonkin Mar 30, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to throw an error here?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tiwarishub tiwarishub Mar 30, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the previous code, we were throwing an error in the GHES scenario https://github.com/actions/setup-python/blob/main/src/setup-python.ts#L15. Now we don't want to change end-user behaviour and this condition is similar to that that where workflow is running on GHES and workflow has explicitly asked for the cache using cache option but it has not enabled the cache. we had similar discussion here #363 (comment)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vsafonkin reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
dmitry-shibanov
dmitry-shibanov reviewed Mar 30, 2022
View reviewed changes
Comment thread package.json Outdated
{
"name": "setup-python",
"version": "2.2.2",
"version": "2.2.3",

@dmitry-shibanov dmitry-shibanov Mar 30, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please change it to the planning version of the setup-python action?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tiwarishub tiwarishub Mar 30, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmitry-shibanov, Sorry I am not aware of the planned version. Could please share what is planned version.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@dmitry-shibanov dmitry-shibanov Mar 30, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be 3.0.1 or 3.1.0 to be consistent with the setup-python action releases: https://github.com/actions/setup-python/releases/tag/v3.0.0

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tiwarishub tiwarishub Mar 30, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, even I found this to be wired that package.json has 2.2.2 and released tag 3.0.0 which we generally keep the same. So I thought this is already followed to keep them not in sync. Shall I fix this?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
brcrista
brcrista reviewed Mar 30, 2022
View reviewed changes
Comment thread src/utils.ts Outdated
);
} else {
core.warning(
'An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.'

@brcrista brcrista Mar 30, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this message accurate? It looks like cache.isFeatureAvailable() just looks for whether an environment variable is set.

https://github.com/actions/toolkit/blob/b4639928698a6bfe1c4bdae4b2bfdad1cb75016d/packages/cache/src/cache.ts#L53

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@brcrista brcrista Mar 30, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If my understanding is correct, I would say something like

Suggested change
'An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.'
'This runner is not configured to use the cache service. Caching will be skipped.'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tiwarishub tiwarishub Mar 30, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this env var is only set when cache service is present otherwise this var will not be set. This else condition is for dotcom scenario so ideally this scenario should never occur because AC is always there in dotcom. But just to cover corner scenario i have added this

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@brcrista brcrista Mar 30, 2022

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I understand better now https://github.com/actions/runner/blob/408d6c579c36f0eb318acfdafdcbafc872696501/src/Runner.Worker/Handlers/NodeScriptActionHandler.cs

How about:

Suggested change
'An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.'
'The runner was not able to contact the cache service. Caching will be skipped.'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tiwarishub tiwarishub Mar 30, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Let me update the PR with changes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@tiwarishub tiwarishub Mar 30, 2022

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tiwarishub
Review comment
fc72fbd
brcrista
brcrista approved these changes Mar 30, 2022
View reviewed changes
This was referenced Mar 30, 2022
Caching on GHES actions/setup-java#308
Merged
Caching on GHES actions/setup-node#452
Merged
vsafonkin
vsafonkin approved these changes Mar 30, 2022
View reviewed changes
tiwarishub added 2 commits March 31, 2022 15:36
@tiwarishub
update version
3bc0f07
@tiwarishub
updated version
1a05397
marko-zivic-93
marko-zivic-93 approved these changes Mar 31, 2022
View reviewed changes

@marko-zivic-93 marko-zivic-93 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All issues we noticed were referenced :) Everything seems ok now :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@brcrista
brcrista merged commit 05fb98d into actions:main Mar 31, 2022
@tiwarishub tiwarishub mentioned this pull request Apr 1, 2022
dist fix #367
Merged
2 tasks
adilosa added a commit to adilosa/setup-python that referenced this pull request Apr 19, 2022
@adilosa
Merge remote-tracking branch 'upstream/main'
a200bff
* upstream/main: (33 commits)
  Fix virtual-env toolcache links
  Updated @actions/cache (actions#382)
  ci(workflow): add 'npm' cache for actions/setup-node in .github/workflows (actions#379)
  Cache hit output (actions#373)
  Add pyton-version to setup PyPy output (actions#365)
  Rework pipenv caching test (actions#375)
  Update README.md to fix setup-python version  in example (actions#368)
  dist fix (actions#367)
  Cache on ghes (actions#363)
  Update dist
  Use `\n` instead of `os.EOL`
  Update dist
  Initialise pyproject.toml
  Build and format
  Remove console.log
  Remove unused file
  Reduce test matrix
  Parse values from poetry
  Release
  Add more tests
  ...
tdfacer pushed a commit to ifit/setup-python that referenced this pull request Oct 7, 2025
@tiwarishub @brcrista
Cache on ghes (actions#363)
0d788d3
* initial changes

* updated version

* format check

* refactored code

* updated test cases

* Update src/utils.ts

Co-authored-by: Brian Cristante <[email protected]>

* Update utils.ts

* Update utils.test.ts

* review comments

* dist update

* Review comment

* update version

* updated version

Co-authored-by: Brian Cristante <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

5 more reviewers
@dmitry-shibanov dmitry-shibanov dmitry-shibanov approved these changes
@vsafonkin vsafonkin vsafonkin approved these changes
@bishal-pdMSFT bishal-pdMSFT bishal-pdMSFT approved these changes
@brcrista brcrista brcrista approved these changes
@marko-zivic-93 marko-zivic-93 marko-zivic-93 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@tiwarishub @vsafonkin @bishal-pdMSFT @dmitry-shibanov @brcrista @marko-zivic-93
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.