Skip to content

Commit 7e2c9a3

Browse files
Merge pull request #41 from Luap99/macos
add macos cirrus testing
2 parents 194f4ca + ef40493 commit 7e2c9a3

File tree

4 files changed

+105
-6
lines changed

4 files changed

+105
-6
lines changed

.cirrus.yml

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ env:
2222
# directory where the images will be placed
2323
OUTDIR: "outdir"
2424

25-
HOME: /root
2625
CIRRUS_WORKING_DIR: /var/tmp/podman-machine-os
2726

27+
# Vars used for the macos and windows testing
28+
MACHINE_IMAGE_URL: "https://api.cirrus-ci.com/v1/artifact/build/${CIRRUS_BUILD_ID}/Image Build ${ARCH}/image/${MACHINE_IMAGE}"
29+
PODMAN_VERSION: 5.3.0
30+
31+
gcp_credentials: ENCRYPTED[b06ef3490b73469d9da1402568d6f3e46a852955a4ab0807689d50352ecf2852cb5903e8d3b7603eaab9d1c7c7d851a5]
32+
2833
aws_credentials: ENCRYPTED[b01991b35fe3f81eed974cf47b5541ed518eacfee4e430e9fb50fba31090f557ea86b0b79b5f5b4a712218206e0f3f58]
2934

3035
# Default timeout
@@ -37,6 +42,8 @@ image_build_task:
3742
image: "${VM_IMAGE}"
3843
type: "${EC2_INST_TYPE}"
3944
region: us-east-1
45+
env:
46+
HOME: /root
4047
matrix:
4148
- env:
4249
ARCH: "x86_64"
@@ -58,7 +65,7 @@ image_build_task:
5865
type: application/octet-stream
5966

6067
verify_windows_task:
61-
name: "Verify HyperV"
68+
name: "Verify hyperv"
6269
alias: "verify_windows"
6370
depends_on:
6471
- image_build
@@ -73,23 +80,69 @@ verify_windows_task:
7380
CIRRUS_SHELL: powershell
7481
PATH: "${PATH};C:\\Program Files\\RedHat\\Podman"
7582
MACHINE_IMAGE: "podman-machine.${ARCH}.hyperv.vhdx.zst"
76-
MACHINE_IMAGE_URL: "https://api.cirrus-ci.com/v1/artifact/build/${CIRRUS_BUILD_ID}/Image Build ${ARCH}/image/${MACHINE_IMAGE}"
77-
PODMAN_VERSION: 5.3.0
7883
setup_script: .\contrib\cirrus\windows_setup.ps1
7984
main_script: |
8085
$Env:CONTAINERS_MACHINE_PROVIDER = "hyperv"
8186
$Env:MACHINE_IMAGE_PATH="..\${ENV:MACHINE_IMAGE}"
82-
.\bin\ginkgo .\verify
87+
.\bin\ginkgo -v .\verify
8388
if ( ($LASTEXITCODE -ne $null) -and ($LASTEXITCODE -ne 0) ) {
8489
throw "Exit code = '$LASTEXITCODE' running ginkgo"
8590
}
8691
92+
verify_macos_task:
93+
name: "Verify $CONTAINERS_MACHINE_PROVIDER"
94+
alias: "verify_macos"
95+
depends_on:
96+
- image_build
97+
persistent_worker: &mac_pw
98+
labels:
99+
os: darwin
100+
arch: arm64
101+
purpose: prod
102+
env: &mac_env
103+
ARCH: "aarch64"
104+
CIRRUS_SHELL: "/bin/bash" # sh is the default
105+
CIRRUS_WORKING_DIR: "$HOME/ci/task-${CIRRUS_TASK_ID}" # Isolation: $HOME will be set to "ci" dir.
106+
# Prevent cache-pollution fron one task to the next.
107+
GOPATH: "$CIRRUS_WORKING_DIR/.go"
108+
GOCACHE: "$CIRRUS_WORKING_DIR/.go/cache"
109+
GOENV: "$CIRRUS_WORKING_DIR/.go/support"
110+
GOSRC: "$HOME/ci/task-${CIRRUS_TASK_ID}"
111+
MACHINE_IMAGE: "podman-machine.${ARCH}.applehv.raw.zst"
112+
matrix:
113+
- env:
114+
CONTAINERS_MACHINE_PROVIDER: applehv
115+
- env:
116+
CONTAINERS_MACHINE_PROVIDER: libkrun
117+
118+
prep_script: &mac_cleanup "contrib/cirrus/mac_cleanup.sh"
119+
setup_script: |
120+
# curl does not accept URL with spaces, we need to URL encode (string replace with %20)
121+
MACHINE_IMAGE_URL="${MACHINE_IMAGE_URL// /%20}"
122+
curl --retry 5 --retry-delay 8 --fail --location -O --url "${MACHINE_IMAGE_URL}"
123+
git clone --depth 1 --branch v${PODMAN_VERSION} https://github.com/containers/podman.git
124+
make -C podman podman-remote
125+
./podman/bin/darwin/podman --version
126+
mkdir bin
127+
cd verify
128+
go build -o ../bin/ginkgo ./vendor/github.com/onsi/ginkgo/v2/ginkgo
129+
main_script: |
130+
export MACHINE_IMAGE_PATH="../${MACHINE_IMAGE}"
131+
export PODMAN_BINARY=../podman/bin/darwin/podman
132+
./bin/ginkgo -v ./verify
133+
134+
# This host is/was shared with potentially many other CI tasks.
135+
# Ensure nothing is left running while waiting for the next task.
136+
always:
137+
task_cleanup_script: *mac_cleanup
138+
87139
test_task:
88140
name: "Total Success"
89141
alias: success
90142
depends_on:
91143
- image_build
92144
- verify_windows
145+
- verify_macos
93146
container:
94147
image: "${FEDORA_CONTAINER_FQIN}"
95148
cpu: 1

contrib/cirrus/mac_cleanup.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# Note this was duplicated from the podman repo.
4+
5+
# This script is intended to be called by Cirrus-CI on a Mac M1 persistent worker.
6+
# It performs a best-effort attempt at cleaning up from one task execution to the next.
7+
# Since it run both before and after tasks, it must exit cleanly if there was a cleanup
8+
# failure (i.e. file or directory not found).
9+
10+
# Help anybody debugging side-effects, since failures are ignored (by necessity).
11+
set +e -x
12+
13+
# These are the main processes which could leak out of testing.
14+
killall podman vfkit gvproxy make go ginkgo
15+
16+
# Golang will leave behind lots of read-only bits, ref:
17+
# https://go.dev/ref/mod#module-cache
18+
# However other tools/scripts could also set things read-only.
19+
# At this point in CI, we really want all this stuff gone-gone,
20+
# so there's actually zero-chance it can interfere.
21+
chmod -R u+w /private/tmp/ci/* /private/tmp/ci/.??*
22+
23+
# This is defined as $TMPDIR during setup. Name must be kept
24+
# "short" as sockets may reside here. Darwin suffers from
25+
# the same limited socket-pathname character-length restriction
26+
# as Linux.
27+
rm -rf /private/tmp/ci/* /private/tmp/ci/.??*
28+
29+
# Don't change or clobber anything under $CIRRUS_WORKING_DIR for
30+
# the currently running task. But make sure we have write permission
31+
# (go get sets dependencies ro) for everything else, before removing it.
32+
# First make everything writeable - see the "Golang will..." comment above.
33+
# shellcheck disable=SC2154
34+
find "${ORIGINAL_HOME:-$HOME}/ci" -mindepth 1 -maxdepth 1 \
35+
-not -name "*task-${CIRRUS_TASK_ID}*" -prune -exec chmod -R u+w '{}' +
36+
find "${ORIGINAL_HOME:-$HOME}/ci" -mindepth 1 -maxdepth 1 \
37+
-not -name "*task-${CIRRUS_TASK_ID}*" -prune -exec rm -rf '{}' +
38+
39+
# Bash scripts exit with the status of the last command.
40+
true

verify/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ To run these tests, a few things need to be in order prior.
1818
Podman binary names will differ based on operating system. For Linux, use
1919
the `podman-remote` binary. For all other platforms, use the `podman` binary.
2020

21+
Set the `PODMAN_BINARY` environment variable to specify the path of the binary
22+
to use.
23+
2124
### How to run the image verification tests
2225

2326
The tests need to be run from the `podman-machine-os/verify` directory. The syntax
@@ -52,4 +55,4 @@ environment variable.
5255

5356
To run the suite, use the Powershell script.
5457

55-
`> .\win_run_test.ps1 c:\Path\To\Disk\Image`
58+
`> .\win_run_test.ps1 c:\Path\To\Disk\Image`

verify/config_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ func runSystemCommand(binary string, cmdArgs []string, timeout time.Duration, wa
251251
// Note: this will need to be moved Linux and everything else
252252
// to distinguish between podman and podman-remote
253253
func getPodmanBinary() (string, error) {
254+
if env := os.Getenv("PODMAN_BINARY"); env != "" {
255+
return env, nil
256+
}
254257
podmanBinary := getPodmanBinaryName()
255258
return exec.LookPath(podmanBinary)
256259
}

0 commit comments

Comments
 (0)