mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-20 06:56:17 -05:00
ci(macos): cache validated public native libraries
This commit is contained in:
4 files changed
+185
No files matched your search
@@ -0,0 +1,64 @@
|
|||||||
|
name: Prepare cached macOS native dependencies
|
||||||
|
description: Cache only the completed public native-library prefix, without private source or app outputs.
|
||||||
|
inputs:
|
||||||
|
gpgui-directory:
|
||||||
|
description: Private checkout containing the native dependency builder
|
||||||
|
required: true
|
||||||
|
outputs:
|
||||||
|
prefix:
|
||||||
|
description: Validated native dependency installation prefix
|
||||||
|
value: ${{ steps.identity.outputs.path }}
|
||||||
|
cache-hit:
|
||||||
|
description: Whether the exact dependency cache was restored
|
||||||
|
value: ${{ steps.restore.outputs.cache-hit }}
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Identify native dependency cache
|
||||||
|
id: identity
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
GPGUI_DIRECTORY: ${{ inputs.gpgui-directory }}
|
||||||
|
GPGUI_MACOS_DEPS_CACHE_DIR: ${{ runner.tool_cache }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Native dependency cache identification failed; diagnostics suppressed."; fi' EXIT
|
||||||
|
metadata="$("$GPGUI_DIRECTORY/scripts/build-macos-native-deps.sh" --cache-info 2>/dev/null)"
|
||||||
|
key="$(printf '%s\n' "$metadata" | sed -n 's/^key=//p')"
|
||||||
|
prefix="$(printf '%s\n' "$metadata" | sed -n 's/^path=//p')"
|
||||||
|
# Emit only an opaque identity and one dependency directory outside the checkout.
|
||||||
|
if [[ "$key" =~ ^[0-9a-f]{64}$ ]] &&
|
||||||
|
[[ "$metadata" == "key=$key"$'\n'"path=$prefix" ]] &&
|
||||||
|
[[ "${prefix%/*}" == "$RUNNER_TOOL_CACHE/gpgui-macos-native-deps" ]] &&
|
||||||
|
[[ "${prefix##*/}" == macos-*-"$key" ]]; then
|
||||||
|
printf 'key=macos-native-deps-%s\npath=%s\n' "$key" "$prefix" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Restore public native libraries
|
||||||
|
id: restore
|
||||||
|
uses: actions/cache/restore@v5
|
||||||
|
with:
|
||||||
|
path: ${{ steps.identity.outputs.path }}
|
||||||
|
key: ${{ steps.identity.outputs.key }}
|
||||||
|
|
||||||
|
- name: Build or validate native libraries
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
GPGUI_DIRECTORY: ${{ inputs.gpgui-directory }}
|
||||||
|
GPGUI_MACOS_DEPS_CACHE_DIR: ${{ runner.tool_cache }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
trap 'status=$?; if [ "$status" -ne 0 ]; then echo "::error::Native dependency preparation failed; diagnostics suppressed."; fi' EXIT
|
||||||
|
started=$SECONDS
|
||||||
|
"$GPGUI_DIRECTORY/scripts/build-macos-native-deps.sh" >/dev/null 2>&1
|
||||||
|
echo "Native dependency preparation passed in $((SECONDS - started)) seconds."
|
||||||
|
|
||||||
|
# Save before any private application compilation or signing credential import.
|
||||||
|
- name: Save public native libraries
|
||||||
|
if: steps.restore.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/cache/save@v5
|
||||||
|
with:
|
||||||
|
path: ${{ steps.identity.outputs.path }}
|
||||||
|
key: ${{ steps.identity.outputs.key }}
|
||||||
@@ -708,6 +708,11 @@ jobs:
|
|||||||
rustup toolchain install 1.97.0 --profile minimal
|
rustup toolchain install 1.97.0 --profile minimal
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Prepare cached native dependencies
|
||||||
|
uses: ./.ci/.github/actions/macos-native-deps
|
||||||
|
with:
|
||||||
|
gpgui-directory: source/gpgui
|
||||||
|
|
||||||
- name: Import signing identity
|
- name: Import signing identity
|
||||||
env:
|
env:
|
||||||
MACOS_CERTIFICATE_P12: ${{ secrets.MACOS_CERTIFICATE_P12 }}
|
MACOS_CERTIFICATE_P12: ${{ secrets.MACOS_CERTIFICATE_P12 }}
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
name: Check macOS native dependency cache
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
gpgui_ref:
|
||||||
|
description: Full gpgui commit SHA
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
gpgui_ref:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
secrets:
|
||||||
|
GH_PAT:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
runs-on: ${{ vars.MACOS_RUNNER || 'macos-15' }}
|
||||||
|
timeout-minutes: 30
|
||||||
|
steps:
|
||||||
|
- name: Require immutable source ref
|
||||||
|
env:
|
||||||
|
GPGUI_REF: ${{ inputs.gpgui_ref }}
|
||||||
|
run: test "${#GPGUI_REF}" -eq 40 && [[ "$GPGUI_REF" != *[!0-9a-f]* ]]
|
||||||
|
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
path: .ci
|
||||||
|
persist-credentials: false
|
||||||
|
|
||||||
|
- name: Checkout gpgui quietly
|
||||||
|
uses: ./.ci/.github/actions/checkout-private
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GH_PAT }}
|
||||||
|
ref: ${{ inputs.gpgui_ref }}
|
||||||
|
path: source/gpgui
|
||||||
|
|
||||||
|
- name: Select release toolchain and install native build tools
|
||||||
|
env:
|
||||||
|
DEVELOPER_DIR: /Applications/Xcode_26.3.app/Contents/Developer
|
||||||
|
run: |
|
||||||
|
test "$(uname -m)" = arm64
|
||||||
|
xcodebuild -version
|
||||||
|
echo "DEVELOPER_DIR=$DEVELOPER_DIR" >> "$GITHUB_ENV"
|
||||||
|
brew install autoconf automake gettext libtool meson ninja pkgconf
|
||||||
|
|
||||||
|
- name: Prepare cached native dependencies
|
||||||
|
id: native
|
||||||
|
uses: ./.ci/.github/actions/macos-native-deps
|
||||||
|
with:
|
||||||
|
gpgui-directory: source/gpgui
|
||||||
|
|
||||||
|
- name: Record cache result
|
||||||
|
env:
|
||||||
|
CACHE_HIT: ${{ steps.native.outputs.cache-hit }}
|
||||||
|
run: |
|
||||||
|
if [[ "$CACHE_HIT" == true ]]; then
|
||||||
|
echo "Validated an exact native dependency cache hit." >> "$GITHUB_STEP_SUMMARY"
|
||||||
|
else
|
||||||
|
echo "Built and validated native dependencies after a cache miss." >> "$GITHUB_STEP_SUMMARY"
|
||||||
|
fi
|
||||||
@@ -129,6 +129,55 @@ class PrivateOutputTests(unittest.TestCase):
|
|||||||
self.assertIn('passed' if status == 0 else 'failed', result.stdout)
|
self.assertIn('passed' if status == 0 else 'failed', result.stdout)
|
||||||
|
|
||||||
|
|
||||||
|
class NativeDependencyCacheTests(unittest.TestCase):
|
||||||
|
def run_step(self, step, metadata, status=0):
|
||||||
|
with tempfile.TemporaryDirectory() as temporary:
|
||||||
|
root = Path(temporary)
|
||||||
|
helper = root / 'private/scripts/build-macos-native-deps.sh'
|
||||||
|
helper.parent.mkdir(parents=True)
|
||||||
|
helper.write_text('#!/bin/sh\nprintf "%s\\n" "$TEST_METADATA"\n'
|
||||||
|
'echo PRIVATE_STDERR >&2\nexit "$TEST_STATUS"\n')
|
||||||
|
helper.chmod(0o755)
|
||||||
|
key = 'a' * 64
|
||||||
|
prefix = root / f'tools/gpgui-macos-native-deps/macos-13.0-arm64-{key}'
|
||||||
|
output = root / 'output'
|
||||||
|
env = dict(os.environ, GPGUI_DIRECTORY=str(root / 'private'),
|
||||||
|
RUNNER_TOOL_CACHE=str(root / 'tools'), GITHUB_OUTPUT=str(output),
|
||||||
|
TEST_METADATA=metadata.format(key=key, prefix=prefix, private=root / 'private'),
|
||||||
|
TEST_STATUS=str(status))
|
||||||
|
result = subprocess.run(['bash', '-e', '-o', 'pipefail', '-c', run_block(
|
||||||
|
'.github/actions/macos-native-deps/action.yaml', step)],
|
||||||
|
cwd=root, env=env, text=True, capture_output=True)
|
||||||
|
return result, output.read_text() if output.exists() else ''
|
||||||
|
|
||||||
|
def test_identity_emits_only_an_opaque_key_and_native_dependency_prefix(self):
|
||||||
|
result, output = self.run_step('Identify native dependency cache', 'key={key}\npath={prefix}')
|
||||||
|
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||||
|
self.assertIn('key=macos-native-deps-' + 'a' * 64, output)
|
||||||
|
self.assertNotIn('PRIVATE_', result.stdout + result.stderr)
|
||||||
|
|
||||||
|
def test_private_output_and_checkout_paths_cannot_become_cache_metadata(self):
|
||||||
|
for metadata, status in [('PRIVATE_SOURCE_CODE', 0),
|
||||||
|
('key={key}\npath={private}', 0),
|
||||||
|
('PRIVATE_SOURCE_CODE', 19)]:
|
||||||
|
with self.subTest(metadata=metadata, status=status):
|
||||||
|
result, output = self.run_step('Identify native dependency cache', metadata, status)
|
||||||
|
self.assertNotEqual(result.returncode, 0)
|
||||||
|
self.assertEqual(result.returncode, status or 1)
|
||||||
|
self.assertEqual(output, '')
|
||||||
|
self.assertNotIn('PRIVATE_', result.stdout + result.stderr)
|
||||||
|
self.assertIn('diagnostics suppressed', result.stdout)
|
||||||
|
|
||||||
|
def test_preparation_hides_private_command_output_and_preserves_failure(self):
|
||||||
|
for status in (0, 19):
|
||||||
|
with self.subTest(status=status):
|
||||||
|
result, output = self.run_step('Build or validate native libraries', 'PRIVATE_SOURCE_CODE', status)
|
||||||
|
self.assertEqual(result.returncode, status)
|
||||||
|
self.assertEqual(output, '')
|
||||||
|
self.assertNotIn('PRIVATE_', result.stdout + result.stderr)
|
||||||
|
self.assertIn('passed' if status == 0 else 'failed', result.stdout)
|
||||||
|
|
||||||
|
|
||||||
class PrivateTestStageTests(unittest.TestCase):
|
class PrivateTestStageTests(unittest.TestCase):
|
||||||
def run_stages(self, mode):
|
def run_stages(self, mode):
|
||||||
with tempfile.TemporaryDirectory() as temporary:
|
with tempfile.TemporaryDirectory() as temporary:
|
||||||
|
|||||||
Reference in new issue
Block a user