Provision hosted macOS Docker and avoid fixture build engine dependency
This commit is contained in:
1 parent
cc756425e8
commit
a1c4d5d78c
3 files changed
+26
-18
No files matched your search
@@ -11,7 +11,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest]
|
os: [ubuntu-latest, macos-15-intel]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -25,6 +25,12 @@ jobs:
|
|||||||
git status --porcelain > evidence/status.txt
|
git status --porcelain > evidence/status.txt
|
||||||
go version > evidence/toolchain.txt
|
go version > evidence/toolchain.txt
|
||||||
go env -json GOOS GOARCH GOVERSION > evidence/platform.json
|
go env -json GOOS GOARCH GOVERSION > evidence/platform.json
|
||||||
|
- name: Start Docker on hosted macOS
|
||||||
|
if: runner.os == 'macOS'
|
||||||
|
run: |
|
||||||
|
brew install colima docker
|
||||||
|
colima start --runtime docker --cpu 2 --memory 4
|
||||||
|
docker info
|
||||||
- name: Prepare required Docker fixtures
|
- name: Prepare required Docker fixtures
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -2,15 +2,12 @@
|
|||||||
|
|
||||||
Qualification requires a working local Docker daemon with a Unix socket and
|
Qualification requires a working local Docker daemon with a Unix socket and
|
||||||
permission for the runner user to use it. The workflow prepares fixtures before
|
permission for the runner user to use it. The workflow prepares fixtures before
|
||||||
running tests and fails if the daemon is unavailable. It does not start or
|
running tests and fails if the daemon is unavailable. Skipped container tests
|
||||||
provision a daemon, and does not accept skipped container tests.
|
are never accepted. Linux uses the installed Docker service. Hosted macOS uses
|
||||||
|
macos-15-intel with Colima, following Colima's own integration runner choice:
|
||||||
Linux GitHub runners can use their installed Docker service. A macOS runner must
|
https://github.com/abiosoft/colima/blob/main/.github/workflows/macos-integration.yml
|
||||||
have a Docker-capable environment provisioned before this workflow can succeed.
|
The workflow starts an ephemeral daemon on that hosted runner; it does not
|
||||||
Do not assume the standard hosted macOS image provides it. See GitHub's runner
|
register or expose a developer's machine as a self-hosted runner.
|
||||||
limitations: https://docs.github.com/en/actions/reference/runners/larger-runners .
|
|
||||||
Local macOS qualification remains possible using the explicitly authorised local
|
|
||||||
daemon; retain exact commit, raw results and platform identity with that evidence.
|
|
||||||
|
|
||||||
The workflow pulls the named fixture base versions, resolves platform-specific
|
The workflow pulls the named fixture base versions, resolves platform-specific
|
||||||
immutable image IDs and records them in evidence/fixtures.json before tests.
|
immutable image IDs and records them in evidence/fixtures.json before tests.
|
||||||
@@ -20,7 +17,9 @@ those IDs instead of resolving current tags.
|
|||||||
|
|
||||||
prepare_container_fixtures.py accepts only loaded immutable IDs, checks Linux and
|
prepare_container_fixtures.py accepts only loaded immutable IDs, checks Linux and
|
||||||
matching image architectures, then creates a minimal implicit-volume negative
|
matching image architectures, then creates a minimal implicit-volume negative
|
||||||
fixture with build networking disabled. It uses a private Docker configuration
|
fixture by creating (never starting) a network-disabled container and committing
|
||||||
|
its VOLUME metadata. This avoids build-engine differences and registry lookups.
|
||||||
|
The temporary container is removed in a finally block. It uses a private Docker configuration
|
||||||
and explicit socket. The generated fixtures.env is suitable for GITHUB_ENV; it
|
and explicit socket. The generated fixtures.env is suitable for GITHUB_ENV; it
|
||||||
contains image IDs and a local socket path, never provider credentials.
|
contains image IDs and a local socket path, never provider credentials.
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
Images must already be loaded. This script never pulls images or starts a daemon.
|
Images must already be loaded. This script never pulls images or starts a daemon.
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
import hashlib
|
|
||||||
import json
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
@@ -25,7 +24,10 @@ def prepare(docker, socket, image, bash_image, output):
|
|||||||
root=Path(temporary);config=root/'config';config.mkdir()
|
root=Path(temporary);config=root/'config';config.mkdir()
|
||||||
prefix=[docker,'--config',str(config),'--host','unix://'+socket]
|
prefix=[docker,'--config',str(config),'--host','unix://'+socket]
|
||||||
def run(args):
|
def run(args):
|
||||||
|
try:
|
||||||
return subprocess.check_output(prefix+args,stderr=subprocess.PIPE,timeout=120)
|
return subprocess.check_output(prefix+args,stderr=subprocess.PIPE,timeout=120)
|
||||||
|
except subprocess.CalledProcessError as error:
|
||||||
|
raise RuntimeError(error.stderr.decode(errors='replace')) from error
|
||||||
inspected=[]
|
inspected=[]
|
||||||
for identity in (image,bash_image):
|
for identity in (image,bash_image):
|
||||||
info=json.loads(run(['image','inspect',identity]))[0]
|
info=json.loads(run(['image','inspect',identity]))[0]
|
||||||
@@ -34,11 +36,12 @@ def prepare(docker, socket, image, bash_image, output):
|
|||||||
inspected.append(dict(id=identity,architecture=info['Architecture']))
|
inspected.append(dict(id=identity,architecture=info['Architecture']))
|
||||||
if inspected[0]['architecture']!=inspected[1]['architecture']:
|
if inspected[0]['architecture']!=inspected[1]['architecture']:
|
||||||
raise ValueError('fixture image architectures differ')
|
raise ValueError('fixture image architectures differ')
|
||||||
dockerfile=('FROM '+image+'\nVOLUME /implicit-fixture-volume\n').encode()
|
# Create without starting: no process, build engine or registry lookup.
|
||||||
(root/'Dockerfile').write_bytes(dockerfile)
|
container=run(['create','--network=none',image,'/bin/true']).decode().strip()
|
||||||
# Untagged derived image is identified solely by its captured ID.
|
try:
|
||||||
raw=run(['build','--pull=false','--network=none','--quiet',str(root)])
|
volume=run(['commit','--change','VOLUME /implicit-fixture-volume',container]).decode().strip()
|
||||||
volume=raw.decode().strip()
|
finally:
|
||||||
|
run(['rm','--volumes',container])
|
||||||
if not re.fullmatch(r'sha256:[0-9a-f]{64}',volume):
|
if not re.fullmatch(r'sha256:[0-9a-f]{64}',volume):
|
||||||
raise ValueError('derived image ID missing')
|
raise ValueError('derived image ID missing')
|
||||||
info=json.loads(run(['image','inspect',volume]))[0]
|
info=json.loads(run(['image','inspect',volume]))[0]
|
||||||
@@ -47,7 +50,7 @@ def prepare(docker, socket, image, bash_image, output):
|
|||||||
settings=dict(HARNESS_TEST_CONTAINER_IMAGE=image,HARNESS_TEST_BASH_IMAGE=bash_image,
|
settings=dict(HARNESS_TEST_CONTAINER_IMAGE=image,HARNESS_TEST_BASH_IMAGE=bash_image,
|
||||||
HARNESS_TEST_VOLUME_IMAGE=volume,HARNESS_TEST_CONTAINER_SOCKET=socket)
|
HARNESS_TEST_VOLUME_IMAGE=volume,HARNESS_TEST_CONTAINER_SOCKET=socket)
|
||||||
report=dict(status='prepared',environment=settings,images=inspected,
|
report=dict(status='prepared',environment=settings,images=inspected,
|
||||||
volume_dockerfile_sha256=hashlib.sha256(dockerfile).hexdigest(),
|
volume_creation='commit stopped container with VOLUME /implicit-fixture-volume',
|
||||||
note='Loaded images are retained; no tests or publication performed.')
|
note='Loaded images are retained; no tests or publication performed.')
|
||||||
(output/'fixtures.json').write_text(json.dumps(report,indent=2)+'\n')
|
(output/'fixtures.json').write_text(json.dumps(report,indent=2)+'\n')
|
||||||
(output/'fixtures.env').write_text(''.join(k+'='+v+'\n' for k,v in settings.items()))
|
(output/'fixtures.env').write_text(''.join(k+'='+v+'\n' for k,v in settings.items()))
|
||||||
|
|||||||
Reference in new issue
Block a user