Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(actions): swap sha256sum for shasum -a 256 #1390

Merged
merged 1 commit into from
Nov 4, 2023

Conversation

kenibrewer
Copy link
Contributor

This addresses an issue in macOS builds may be impacting caching. The command sha256sum which doesn't exist in macOS-latest is replaced with shasum -a 256 which is present in both ubuntu-latest and macOS-latest

Closes #1389

@kenibrewer kenibrewer marked this pull request as ready for review October 29, 2023 11:02
@codecov
Copy link

codecov bot commented Oct 29, 2023

Codecov Report

Merging #1390 (6141276) into master (99bdd11) will increase coverage by 0.06%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #1390      +/-   ##
==========================================
+ Coverage   97.24%   97.30%   +0.06%     
==========================================
  Files          48       48              
  Lines        4423     4423              
==========================================
+ Hits         4301     4304       +3     
+ Misses        122      119       -3     
Flag Coverage Δ
unittests 97.30% <ø> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 1 file with indirect coverage changes

Copy link
Member

@sisp sisp left a comment

Choose a reason for hiding this comment

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

Thanks for discovering this error and taking the initiative to fix it, @kenibrewer! 🙏

Your current fix works for macOS and Ubuntu, but it doesn't work for Windows:

D:\a\_temp\29fa6760-37f4-4d7b-9324-e184f44d2852.sh: line 1: shasum: command not found

I see three options:

  1. Use Python's hashlib module (see my inline suggestions).
  2. Use the cache key computation from Poetry's own CI config.
  3. Make this step conditioned on the OS and add another one with sha256sum for Windows.

I'm leaning towards solution 2, but solution 1 is less intrusive. Solution 3 adds too much duplicate code for my taste, but I wanted to mention it nevertheless.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
@kenibrewer
Copy link
Contributor Author

  1. Use Python's hashlib module (see my inline suggestions).
  2. Use the cache key computation from Poetry's own CI config.
  3. Make this step conditioned on the OS and add another one with sha256sum for Windows.

I'm leaning towards solution 2, but solution 1 is less intrusive. Solution 3 adds too much duplicate code for my taste, but I wanted to mention it nevertheless.

I like solution 2 best as well. It's a lot more readable while solution 1 is pretty hard to parse.

@kenibrewer kenibrewer marked this pull request as draft October 29, 2023 13:33
@kenibrewer kenibrewer force-pushed the fix/actions-macos-sha256 branch from 1e671a0 to 1fe34b7 Compare October 29, 2023 13:54
@kenibrewer kenibrewer marked this pull request as ready for review October 29, 2023 13:55
@kenibrewer kenibrewer requested a review from sisp October 29, 2023 13:55
@kenibrewer kenibrewer force-pushed the fix/actions-macos-sha256 branch from 1fe34b7 to 5d0485a Compare October 29, 2023 14:14
@kenibrewer
Copy link
Contributor Author

@sisp Can I get another workflow run?

@kenibrewer kenibrewer marked this pull request as draft October 29, 2023 14:23
@kenibrewer
Copy link
Contributor Author

Looks like that didn't work for the windows install either.

Run echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
  echo version=$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") >> $GITHUB_OUTPUT
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    LANG: en_US.utf-8
    LC_ALL: en_US.utf-8
    PIP_CACHE_DIR: D:\a\copier\copier/.cache/pip
    POETRY_CACHE_DIR: D:\a\copier\copier/.cache/pypoetry
    POETRY_VIRTUALENVS_IN_PROJECT: true
    PRE_COMMIT_HOME: D:\a\copier\copier/.cache/pre-commit
    PYTEST_ADDOPTS: 
    PYTHONIOENCODING: UTF-8
    pythonLocation: C:\hostedtoolcache\windows\Python\3.9.13\x64
    PKG_CONFIG_PATH: C:\hostedtoolcache\windows\Python\3.9.13\x64/lib/pkgconfig
    Python_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.9.13\x64
    Python[2](https://github.com/copier-org/copier/actions/runs/6683900995/job/18160692065?pr=1390#step:5:2)_ROOT_DIR: C:\hostedtoolcache\windows\Python\[3](https://github.com/copier-org/copier/actions/runs/6683900995/job/18160692065?pr=1390#step:5:3).9.13\x6[4](https://github.com/copier-org/copier/actions/runs/6683900995/job/18160692065?pr=1390#step:5:4)
    Python3_ROOT_DIR: C:\hostedtoolcache\windows\Python\3.9.13\x64

Cache restored successfully
Cache restored from key: cache|Windows||212c846ea7c96894e2ee344b3ed706190f898f3da49de7092b13c63149eea81b|c860f4[5]

I set up a test PR into my own fork so I can run the workflows myself. I'll probably test option 1 next and see if I can make it clearer and readable.

@kenibrewer kenibrewer force-pushed the fix/actions-macos-sha256 branch from a00e055 to 1d2b31d Compare November 3, 2023 15:05
Previous approach was broken on macOS due to missing sha256sum command.
This adopts the same cache-key approach as is used in Poetry pipelines.

Closes copier-org#1389
@kenibrewer kenibrewer force-pushed the fix/actions-macos-sha256 branch from 1d2b31d to 6141276 Compare November 3, 2023 15:07
@kenibrewer kenibrewer marked this pull request as ready for review November 3, 2023 19:55
@kenibrewer
Copy link
Contributor Author

@sisp This is now passing all tests and generates cache keys on all platforms.

@yajo yajo enabled auto-merge (squash) November 4, 2023 07:45
Copy link
Member

@sisp sisp left a comment

Choose a reason for hiding this comment

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

Perfect, @kenibrewer, thank you! 🙏

@yajo yajo merged commit 6e8f985 into copier-org:master Nov 4, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Github Actions pipeline fails to generate sha256 sum for caching macOS builds
3 participants