Repository navigation
ci(macos): El CI de macOS instala y desinstala el cask con el paquete recién construido #2062
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #!/usr/bin/env bash | ||
| # Instala el cask del tap con el .dmg recién construido, arranca la app y la desinstala, sin escribir en el tap (TD-139). | ||
| set -euo pipefail | ||
|
|
||
| dmg="${1:?uso: verify-cask.sh <ruta al .dmg>}" | ||
| dmg="$(cd "$(dirname "$dmg")" && pwd)/$(basename "$dmg")" | ||
| source="${CASK_SOURCE:-https://raw.githubusercontent.com/sgomez/homebrew-rfirma/main/Casks/rfirma.rb}" | ||
| applications="${APPLICATIONS_DIR:-/Applications}" | ||
| tap="rfirma-ci/local" | ||
|
|
||
| tmp="$(mktemp -d)" | ||
| cleanup() { | ||
| brew untap "$tap" > /dev/null 2>&1 || true | ||
| rm -rf "$tmp" | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| case "$source" in | ||
| http*) curl -fsSL "$source" -o "$tmp/rfirma.rb" ;; | ||
| *) cp "$source" "$tmp/rfirma.rb" ;; | ||
| esac | ||
|
|
||
| sha="$(shasum -a 256 "$dmg" | cut -d' ' -f1)" | ||
| sed -E \ | ||
| -e "s|^( *)version .*|\\1version \"0.0.0\"|" \ | ||
| -e "s|^( *)sha256 .*|\\1sha256 \"$sha\"|" \ | ||
| -e "s|^( *)url \"[^\"]*\".*|\\1url \"file://$dmg\"|" \ | ||
| "$tmp/rfirma.rb" > "$tmp/cask.rb" | ||
|
|
||
| brew tap-new --no-git "$tap" > /dev/null | ||
| mkdir -p "$(brew --repository "$tap")/Casks" | ||
| cp "$tmp/cask.rb" "$(brew --repository "$tap")/Casks/rfirma.rb" | ||
|
|
||
| brew install --cask "$tap/rfirma" | ||
| app="$applications/rfirma.app" | ||
| [ -d "$app" ] || { echo "$app no existe tras instalar" >&2; exit 1; } | ||
| xattr -c "$app" | ||
| "$app/Contents/MacOS/rfirma" --version | ||
|
|
||
| brew uninstall --cask "$tap/rfirma" | ||
| [ ! -e "$app" ] || { echo "$app sigue ahí tras desinstalar" >&2; exit 1; } | ||
| echo "cask: instala, arranca y desinstala" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/usr/bin/env bash | ||
| # Las pruebas de `verify-cask.sh` con un `brew` de mentira, sin red. | ||
| set -euo pipefail | ||
|
|
||
| root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" | ||
| verify="$root/packaging/macos/verify-cask.sh" | ||
| tmp="$(mktemp -d)" | ||
| trap 'rm -rf "$tmp"' EXIT | ||
|
|
||
| mkdir -p "$tmp/bin" "$tmp/apps" "$tmp/repo" | ||
| printf 'dmg de prueba' > "$tmp/rfirma_1.0.0_aarch64.dmg" | ||
| expected_sha="$(shasum -a 256 "$tmp/rfirma_1.0.0_aarch64.dmg" | cut -d' ' -f1)" | ||
|
|
||
| cat > "$tmp/cask.rb" <<'CASK' | ||
| cask "rfirma" do | ||
| version "0.0.0" | ||
| sha256 "0000000000000000000000000000000000000000000000000000000000000000" | ||
|
|
||
| url "https://github.com/sgomez/rfirma/releases/download/v#{version}/rfirma_#{version}_aarch64.dmg" | ||
| app "rfirma.app" | ||
| end | ||
| CASK | ||
|
|
||
| cat > "$tmp/bin/brew" <<'BREW' | ||
| #!/usr/bin/env bash | ||
| echo "$*" >> "$FAKE_BREW_LOG" | ||
| case "$1" in | ||
| tap-new) mkdir -p "$FAKE_REPO/Casks" ;; | ||
| --repository) echo "$FAKE_REPO" ;; | ||
| install) | ||
| cp "$FAKE_REPO/Casks/rfirma.rb" "$FAKE_INSTALLED_CASK" | ||
| mkdir -p "$APPLICATIONS_DIR/rfirma.app/Contents/MacOS" | ||
| printf '#!/bin/sh\necho "$*" > "$FAKE_LAUNCH_LOG"\n' > "$APPLICATIONS_DIR/rfirma.app/Contents/MacOS/rfirma" | ||
| chmod +x "$APPLICATIONS_DIR/rfirma.app/Contents/MacOS/rfirma" | ||
| ;; | ||
| uninstall) [ -n "${FAKE_KEEP_APP:-}" ] || rm -rf "$APPLICATIONS_DIR/rfirma.app" ;; | ||
| esac | ||
| BREW | ||
| chmod +x "$tmp/bin/brew" | ||
| printf '#!/bin/sh\n' > "$tmp/bin/xattr" | ||
| chmod +x "$tmp/bin/xattr" | ||
|
|
||
| export PATH="$tmp/bin:$PATH" FAKE_REPO="$tmp/repo" FAKE_BREW_LOG="$tmp/brew.log" FAKE_LAUNCH_LOG="$tmp/launch.log" | ||
| export FAKE_INSTALLED_CASK="$tmp/installed.rb" APPLICATIONS_DIR="$tmp/apps" CASK_SOURCE="$tmp/cask.rb" | ||
|
|
||
| fail() { echo "FALLO $*" >&2; exit 1; } | ||
|
|
||
| "$verify" "$tmp/rfirma_1.0.0_aarch64.dmg" > "$tmp/out" 2>&1 || fail "debía pasar: $(cat "$tmp/out")" | ||
| grep -q '^tap-new --no-git' "$tmp/brew.log" || fail "el tap de usar y tirar debe crearse sin git" | ||
| grep -qF "url \"file://$tmp/rfirma_1.0.0_aarch64.dmg\"" "$tmp/installed.rb" || fail "el cask debe apuntar al dmg local" | ||
| grep -q "sha256 \"$expected_sha\"" "$tmp/installed.rb" || fail "el cask debe llevar el sha256 del dmg local" | ||
| grep -q 'app "rfirma.app"' "$tmp/installed.rb" || fail "el resto del cask debe quedar igual" | ||
| [ "$(cat "$tmp/launch.log")" = "--version" ] || fail "debe arrancar la app con --version" | ||
| grep -q '^uninstall --cask' "$tmp/brew.log" || fail "debe desinstalar" | ||
| [ ! -e "$tmp/apps/rfirma.app" ] || fail "la app debe haberse retirado" | ||
|
|
||
| if FAKE_KEEP_APP=1 "$verify" "$tmp/rfirma_1.0.0_aarch64.dmg" > "$tmp/out" 2>&1; then | ||
| fail "si la desinstalación deja la app, tenía que fallar" | ||
| fi | ||
| grep -q 'sigue' "$tmp/out" || fail "esperaba el aviso de que la app sigue: $(cat "$tmp/out")" | ||
|
|
||
| echo "OK verify-cask" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
[fix] Homebrew 7 pone siempre la cuarentena (ID-553) y la app no va firmada por Apple, así que lanzar este binario depende de cómo tenga Gatekeeper el runner. Ejecuta antes
xattr -c "$app", lo mismo que loscaveatsdel cask piden a la persona usuaria.