ipatch / homebrew-us-05

homebrew 🍺 tap serving off beat ales ↑ and lagers ↓
MIT License
7 stars 3 forks source link

scaffold out a github workflow for building a macos app bundle #15

Open ipatch opened 3 months ago

ipatch commented 3 months ago

work for scaffolding the workflow (github action) will be done in the below branch,

https://github.com/ipatch/homebrew-us-05/tree/ci-changes

ipatch commented 3 months ago

as of right now, the current workflow will attempt to download all the freecad deps with each subsequent run. and on the macos 14 arm runner, it takes ~ 4 to 5 minutes to fetch and install the required deps.

ipatch commented 3 months ago

presently working on caching the install of the homebrew freecad deps to allow subsequent runs to restore the homebrew installation without having to redownload and reinstall the deps for freecad.

ipatch commented 3 months ago

it appears using the below step is redundant because the github provided runners have homebrew installed with a default list of homebrew packages already installed.

 - name: Set up Homebrew
        id: set-up-homebrew
        uses: Homebrew/actions/setup-homebrew@master
ipatch commented 3 months ago

using the github action, tecolicom/actions-install-and-cache@v1 to cache the freecad deps on the github provided macos 14 arm64 runner took ~ 9 minutes to complete. the cache size appears to be ~ 867 MB according to the run status.

the caching of the brew prefix dir took ~ 1 minute and 13 seconds on the macos 14 arm64 github provided runner.

Post job cleanup.
Post job cleanup.
/opt/homebrew/bin/gtar --posix -cf cache.tzst --exclude cache.tzst -P -C /Users/runner/work/homebrew-us-05/homebrew-us-05 --files-from manifest.txt --delay-directory-restore --use-compress-program zstdmt
Cache Size: ~867 MB (9090[2](https://github.com/ipatch/homebrew-us-05/actions/runs/9617710467/job/26530052656#step:20:2)3204 B)
Cache saved successfully
Cache saved with key: 22bb85dd26b0ab6965dc2fef8179b25[3](https://github.com/ipatch/homebrew-us-05/actions/runs/9617710467/job/26530052656#step:20:3)

github does have a cache limit size for a repo set at 10GB which applies to all runners defined in a matrix.

ipatch commented 3 months ago

using the cache provided (~900MB) the subsequent job took ~ 56 seconds 👍️

Post job cleanup.
Post job cleanup.
Cache hit occurred on the primary key [2](https://github.com/ipatch/homebrew-us-05/actions/runs/9618023479/job/26531035606#step:20:2)2bb85dd26b0ab6965dc2fef8179b25[3](https://github.com/ipatch/homebrew-us-05/actions/runs/9618023479/job/26531035606#step:20:3), not saving cache.
succeeded 2 minutes ago in 56s
ipatch commented 3 months ago

current issue when attempting to restore cache,

##[debug]Resolved Keys:
##[debug]["homebrew-packages-macOS-9666822461","homebrew-packages-macOS-","homebrew-packages-macOS"]
##[debug]Checking zstd --quiet --version
##[debug]1.5.6
##[debug]zstd version: 1.5.6
##[debug]Resource Url: https://acghubeus2.actions.githubusercontent.com/jfkGTxoFa7rBPZEYL1G2eERIfyhVmeQETS0KGdex9NeckcRfgi/_apis/artifactcache/cache?keys=homebrew-packages-macOS-9666822461%2Chomebrew-packages-macOS-%2Chomebrew-packages-macOS&version=ea01476f1390bd7718ae83[73](https://github.com/ipatch/homebrew-us-05/actions/runs/9666822461/job/26667278695#step:8:74)c3db824986c4550e5df564c95ec7fcaa49e5c878
##[debug]Resource Url: https://acghubeus2.actions.githubusercontent.com/jfkGTxoFa7rBPZEYL1G2eERIfyhVmeQETS0KGdex9NeckcRfgi/_apis/artifactcache/caches?key=homebrew-packages-macOS-9666822461
##[debug]Failed to delete archive: Error: ENOENT: no such file or directory, unlink ''
Cache not found for input keys: homebrew-packages-macOS-9666822461, homebrew-packages-macOS-, homebrew-packages-macOS
##[debug]Node Action run completed with exit code 0
##[debug]Set output cache-primary-key = homebrew-packages-macOS-9666[82](https://github.com/ipatch/homebrew-us-05/actions/runs/9666822461/job/26667278695#step:8:83)2461
##[debug]Finishing: restore cache
ipatch commented 3 months ago

new new issue,

Run gh extension install actions/gh-actions-cache
  gh extension install actions/gh-actions-cache
  gh actions-cache delete "macOS-9668889048-brewdeps" --confirm
  shell: /bin/bash -e {0}
  env:
    HOMEBREW_NO_ANALYTICS: 1
    HOMEBREW_NO_AUTO_UPDATE: 1
    HOMEBREW_NO_INSTALL_CLEANUP: 1
    HOMEBREW_NO_INSTALL_FROM_API: 1
    HOMEBREW_DEVELOPER: 1
    bp: "/opt/homebrew"
    hbc: "/opt/homebrew/cache"
    GH_TOKEN: ***

could not check for binary extension: HTTP [4](https://github.com/ipatch/homebrew-us-05/actions/runs/9668889048/job/26674112556#step:13:4)01: Bad credentials (https://api.github.com/repos/actions/gh-actions-cache/releases/latest)
Try authenticating with:  gh auth login
Error: Process completed with exit code 1.
ipatch commented 3 months ago

for reasons i do not quite understand the below logic will not work when attempting to save a cache 🤷‍♂️

#----
# NO WORK!
# path: ${{ env.bp }} # does not properly save /opt/homebrew on macos arm64
#----
ipatch commented 3 months ago

without removing any of the default homebrew packages preinstalled on the runner,

╰─λ gh cache list

Showing 1 of 1 cache in ipatch/homebrew-us-05

ID  KEY             SIZE      CREATED              ACCESSED
87  macOS-brewdeps  3.47 GiB  about 9 minutes ago  about 9 minutes ago

with removing the excess preinstalled brew pkgs.

╰─λ gh cache list

Showing 1 of 1 cache in ipatch/homebrew-us-05

ID  KEY             SIZE      CREATED              ACCESSED
89  macOS-brewdeps  1.35 GiB  about 4 minutes ago  about 4 minutes ago
ipatch commented 3 months ago

new error,

Received 3735735418 of 3735735418 (100.0%), 64.7 MBs/sec
Warning: The value of "length" is out of range. It must be >= 0 && <= 2147483647. Received 3735735418
ipatch commented 3 months ago

https://github.com/actions/cache/issues/1425


similar question to my issue linked above

https://github.com/orgs/community/discussions/27163

ipatch commented 3 months ago

am able to save a cache for the installed brew packages aka formula for macos and arm64 using conditional logic to check for specific os and specific arch. however i'm running into the below error when attempt to restore the cache with macos-14 arm64 runner,

/opt/homebrew/bin/gtar: Ignoring unknown extended header keyword 'LIBARCHIVE.creationtime'
/opt/homebrew/bin/gtar: Ignoring unknown extended header keyword 'LIBARCHIVE.creationtime'
/opt/homebrew/bin/gtar: Ignoring unknown extended header keyword 'LIBARCHIVE.creationtime'
/opt/homebrew/bin/gtar: Ignoring unknown extended header keyword 'LIBARCHIVE.creationtime'
/opt/homebrew/bin/gtar: Ignoring unknown extended header keyword 'LIBARCHIVE.creationtime'
/opt/homebrew/bin/gtar: Exiting with failure status due to previous errors
Warning: Tar failed with error: The process '/opt/homebrew/bin/gtar' failed with exit code 2
##[debug]Node Action run completed with exit code 0
##[debug]Save intra-action state CACHE_KEY = macOS-brewdeps
##[debug]Set output cache-hit = false
##[debug]Finishing: restore cache
ipatch commented 3 months ago

apparently the cache after installing the necessary deps for freecad using homebrew exceeds the maximum size allowed for a single cache "object" / file

Received 2306867200 of 2783368583 (82.9%), 64.8 MBs/sec
Received 2382364672 of 2783368583 (85.6%), 65.0 MBs/sec
Received 2453667840 of 2783368583 (88.2%), 65.1 MBs/sec
Received 2529165312 of 2783368583 (90.9%), 65.3 MBs/sec
Received 2592079872 of 2783368583 (93.1%), 65.1 MBs/sec
Received 265[49](https://github.com/ipatch/homebrew-us-05/actions/runs/9701561788/job/26776105044#step:9:50)94432 of 2783368583 (95.4%), 65.0 MBs/sec
Received 2734686208 of 2783368583 (98.3%), 65.3 MBs/sec
Received 2783368583 of 2783368583 (100.0%), 65.4 MBs/sec
Warning: The value of "length" is out of range. It must be >= 0 && <= 2147483647. Received 2783368583

the below may resolve the above mentioned issue,

https://github.com/actions/cache/issues/773

ipatch commented 3 months ago

when using actions/cache@v3 to restore a cache i get the below error,

##[debug]No matching cache found for cache key 'macOS-brewdeps', version '4105a4a706ea2446021ae16639c5a1bf489592542060a57f5f7bdba41cff0f85 and scope refs/heads/ci-changes. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key 
##[debug]Other caches with similar key:
##[debug]Cache Key: macOS-brewdeps, Cache Version: 934ef362ad2a6becfb6b3c0a13e7abb7bfb5a431044bce9662b391b2be328ef4, Cache Scope: refs/heads/ci-changes, Cache Created: 2024-06-27T23:44:42.0933333Z
##[debug]Cache Key: macOS-brewdeps, Cache Version: ea01476f1390bd7718ae8373c3db824986c4550e5df564c95ec7fcaa49e5c878, Cache Scope: refs/heads/ci-changes, Cache Created: 2024-06-27T23:41:15.6266667Z
##[debug]Failed to delete archive: Error: ENOENT: no such file or directory, unlink ''
Cache not found for input keys: macOS-brewdeps, macOS-brewdeps, macOS-*-brew, macOS-
##[debug]Node Action run completed with exit code 0
##[debug]Save intra-action state CACHE_KEY = macOS-brewdeps
##[debug]Finishing: restore cache

whereas actions/cache@v2 is able to restore the cache.

ipatch commented 3 months ago

using actions/cache@v4

##[debug]Checking zstd --quiet --version
##[debug]Unable to locate executable file: zstd. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
##[debug]
##[debug]zstd version: null
##[debug]Resource Url: https://acghubeus2.actions.githubusercontent.com/jfkGTxoFa7rBPZEYL1G2eERIfyhVmeQETS0KGdex9NeckcRfgi/_apis/artifactcache/cache?keys=macOS-brewdeps%2CmacOS-brewdeps%2CmacOS-*-brew%2CmacOS-&version=4[105](https://github.com/ipatch/homebrew-us-05/actions/runs/9716706005/job/26820906391#step:9:106)a4a706ea2446021ae16639c5a1bf489592542060a57f5f7bdba41cff0f85
##[debug]Resource Url: https://acghubeus2.actions.githubusercontent.com/jfkGTxoFa7rBPZEYL1G2eERIfyhVmeQETS0KGdex9NeckcRfgi/_apis/artifactcache/caches?key=macOS-brewdeps
##[debug]No matching cache found for cache key 'macOS-brewdeps', version '4105a4a706ea2446021ae16639c5a1bf489592542060a57f5f7bdba41cff0f85 and scope refs/heads/ci-changes. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key 
##[debug]Other caches with similar key:
##[debug]Cache Key: macOS-brewdeps, Cache Version: 934ef362ad2a6becfb6b3c0a13e7abb7bfb5a431044bce9662b391b2be328ef4, Cache Scope: refs/heads/ci-changes, Cache Created: 2024-06-27T23:44:42.0933333Z
##[debug]Cache Key: macOS-brewdeps, Cache Version: ea01476f1390bd7718ae8373c3db824986c4550e5df564c95ec7fcaa49e5c878, Cache Scope: refs/heads/ci-changes, Cache Created: 2024-06-27T23:41:15.6266667Z
##[debug]Failed to delete archive: Error: ENOENT: no such file or directory, unlink ''
Cache not found for input keys: macOS-brewdeps, macOS-brewdeps, macOS-*-brew, macOS-
##[debug]Node Action run completed with exit code 0
##[debug]Save intra-action state CACHE_KEY = macOS-brewdeps
##[debug]Finishing: restore cache
ipatch commented 3 months ago

using actions/cache@master

##[debug]Resolved Keys:
##[debug]["macOS-brewdeps","macOS-brewdeps","macOS-*-brew","macOS-"]
##[debug]Checking zstd --quiet --version
##[debug]Unable to locate executable file: zstd. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
##[debug]
##[debug]zstd version: null
##[debug]Resource Url: https://acghubeus2.actions.githubusercontent.com/jfkGTxoFa7rBPZEYL1G2eERIfyhVmeQETS0KGdex9NeckcRfgi/_apis/artifactcache/cache?keys=macOS-brewdeps%2CmacOS-brewdeps%2CmacOS-*-brew%2CmacOS-&version=4105a4a706ea2446021ae16639c5a1bf489592542060a57f5f7bdba41cff0f85
##[debug]Resource Url: https://acghubeus2.actions.githubusercontent.com/jfkGTxoFa7rBPZEYL1G2eERIfyhVmeQETS0KGdex9NeckcRfgi/_apis/artifactcache/caches?key=macOS-brewdeps
##[debug]No matching cache found for cache key 'macOS-brewdeps', version '4105a4a706ea2446021ae16639c5a1bf489592542060a57f5f7bdba41cff0f85 and scope refs/heads/ci-changes. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key 
##[debug]Other caches with similar key:
##[debug]Cache Key: macOS-brewdeps, Cache Version: 934ef362ad2a6becfb6b3c0a13e7abb7bfb5a43[104](https://github.com/ipatch/homebrew-us-05/actions/runs/9716744710/job/26821030348#step:9:105)4bce9662b391b2be328ef4, Cache Scope: refs/heads/ci-changes, Cache Created: 2024-06-27T23:44:42.0933333Z
##[debug]Cache Key: macOS-brewdeps, Cache Version: ea01476f1390bd7718ae8373c3db824986c4550e5df564c95ec7fcaa49e5c878, Cache Scope: refs/heads/ci-changes, Cache Created: 2024-06-27T23:41:15.6266667Z
##[debug]Failed to delete archive: Error: ENOENT: no such file or directory, unlink ''
Cache not found for input keys: macOS-brewdeps, macOS-brewdeps, macOS-*-brew, macOS-
##[debug]Node Action run completed with exit code 0
##[debug]Save intra-action state CACHE_KEY = macOS-brewdeps
##[debug]Finishing: restore cache