Skip to content

Commit

Permalink
Merge pull request #41 from Luap99/macos
Browse files Browse the repository at this point in the history
add macos cirrus testing
  • Loading branch information
openshift-merge-bot[bot] authored Nov 19, 2024
2 parents 194f4ca + ef40493 commit 7e2c9a3
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 6 deletions.
63 changes: 58 additions & 5 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ env:
# directory where the images will be placed
OUTDIR: "outdir"

HOME: /root
CIRRUS_WORKING_DIR: /var/tmp/podman-machine-os

# Vars used for the macos and windows testing
MACHINE_IMAGE_URL: "https://api.cirrus-ci.com/v1/artifact/build/${CIRRUS_BUILD_ID}/Image Build ${ARCH}/image/${MACHINE_IMAGE}"
PODMAN_VERSION: 5.3.0

gcp_credentials: ENCRYPTED[b06ef3490b73469d9da1402568d6f3e46a852955a4ab0807689d50352ecf2852cb5903e8d3b7603eaab9d1c7c7d851a5]

aws_credentials: ENCRYPTED[b01991b35fe3f81eed974cf47b5541ed518eacfee4e430e9fb50fba31090f557ea86b0b79b5f5b4a712218206e0f3f58]

# Default timeout
Expand All @@ -37,6 +42,8 @@ image_build_task:
image: "${VM_IMAGE}"
type: "${EC2_INST_TYPE}"
region: us-east-1
env:
HOME: /root
matrix:
- env:
ARCH: "x86_64"
Expand All @@ -58,7 +65,7 @@ image_build_task:
type: application/octet-stream

verify_windows_task:
name: "Verify HyperV"
name: "Verify hyperv"
alias: "verify_windows"
depends_on:
- image_build
Expand All @@ -73,23 +80,69 @@ verify_windows_task:
CIRRUS_SHELL: powershell
PATH: "${PATH};C:\\Program Files\\RedHat\\Podman"
MACHINE_IMAGE: "podman-machine.${ARCH}.hyperv.vhdx.zst"
MACHINE_IMAGE_URL: "https://api.cirrus-ci.com/v1/artifact/build/${CIRRUS_BUILD_ID}/Image Build ${ARCH}/image/${MACHINE_IMAGE}"
PODMAN_VERSION: 5.3.0
setup_script: .\contrib\cirrus\windows_setup.ps1
main_script: |
$Env:CONTAINERS_MACHINE_PROVIDER = "hyperv"
$Env:MACHINE_IMAGE_PATH="..\${ENV:MACHINE_IMAGE}"
.\bin\ginkgo .\verify
.\bin\ginkgo -v .\verify
if ( ($LASTEXITCODE -ne $null) -and ($LASTEXITCODE -ne 0) ) {
throw "Exit code = '$LASTEXITCODE' running ginkgo"
}
verify_macos_task:
name: "Verify $CONTAINERS_MACHINE_PROVIDER"
alias: "verify_macos"
depends_on:
- image_build
persistent_worker: &mac_pw
labels:
os: darwin
arch: arm64
purpose: prod
env: &mac_env
ARCH: "aarch64"
CIRRUS_SHELL: "/bin/bash" # sh is the default
CIRRUS_WORKING_DIR: "$HOME/ci/task-${CIRRUS_TASK_ID}" # Isolation: $HOME will be set to "ci" dir.
# Prevent cache-pollution fron one task to the next.
GOPATH: "$CIRRUS_WORKING_DIR/.go"
GOCACHE: "$CIRRUS_WORKING_DIR/.go/cache"
GOENV: "$CIRRUS_WORKING_DIR/.go/support"
GOSRC: "$HOME/ci/task-${CIRRUS_TASK_ID}"
MACHINE_IMAGE: "podman-machine.${ARCH}.applehv.raw.zst"
matrix:
- env:
CONTAINERS_MACHINE_PROVIDER: applehv
- env:
CONTAINERS_MACHINE_PROVIDER: libkrun

prep_script: &mac_cleanup "contrib/cirrus/mac_cleanup.sh"
setup_script: |
# curl does not accept URL with spaces, we need to URL encode (string replace with %20)
MACHINE_IMAGE_URL="${MACHINE_IMAGE_URL// /%20}"
curl --retry 5 --retry-delay 8 --fail --location -O --url "${MACHINE_IMAGE_URL}"
git clone --depth 1 --branch v${PODMAN_VERSION} https://github.com/containers/podman.git
make -C podman podman-remote
./podman/bin/darwin/podman --version
mkdir bin
cd verify
go build -o ../bin/ginkgo ./vendor/github.com/onsi/ginkgo/v2/ginkgo
main_script: |
export MACHINE_IMAGE_PATH="../${MACHINE_IMAGE}"
export PODMAN_BINARY=../podman/bin/darwin/podman
./bin/ginkgo -v ./verify
# This host is/was shared with potentially many other CI tasks.
# Ensure nothing is left running while waiting for the next task.
always:
task_cleanup_script: *mac_cleanup

test_task:
name: "Total Success"
alias: success
depends_on:
- image_build
- verify_windows
- verify_macos
container:
image: "${FEDORA_CONTAINER_FQIN}"
cpu: 1
Expand Down
40 changes: 40 additions & 0 deletions contrib/cirrus/mac_cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# Note this was duplicated from the podman repo.

# This script is intended to be called by Cirrus-CI on a Mac M1 persistent worker.
# It performs a best-effort attempt at cleaning up from one task execution to the next.
# Since it run both before and after tasks, it must exit cleanly if there was a cleanup
# failure (i.e. file or directory not found).

# Help anybody debugging side-effects, since failures are ignored (by necessity).
set +e -x

# These are the main processes which could leak out of testing.
killall podman vfkit gvproxy make go ginkgo

# Golang will leave behind lots of read-only bits, ref:
# https://go.dev/ref/mod#module-cache
# However other tools/scripts could also set things read-only.
# At this point in CI, we really want all this stuff gone-gone,
# so there's actually zero-chance it can interfere.
chmod -R u+w /private/tmp/ci/* /private/tmp/ci/.??*

# This is defined as $TMPDIR during setup. Name must be kept
# "short" as sockets may reside here. Darwin suffers from
# the same limited socket-pathname character-length restriction
# as Linux.
rm -rf /private/tmp/ci/* /private/tmp/ci/.??*

# Don't change or clobber anything under $CIRRUS_WORKING_DIR for
# the currently running task. But make sure we have write permission
# (go get sets dependencies ro) for everything else, before removing it.
# First make everything writeable - see the "Golang will..." comment above.
# shellcheck disable=SC2154
find "${ORIGINAL_HOME:-$HOME}/ci" -mindepth 1 -maxdepth 1 \
-not -name "*task-${CIRRUS_TASK_ID}*" -prune -exec chmod -R u+w '{}' +
find "${ORIGINAL_HOME:-$HOME}/ci" -mindepth 1 -maxdepth 1 \
-not -name "*task-${CIRRUS_TASK_ID}*" -prune -exec rm -rf '{}' +

# Bash scripts exit with the status of the last command.
true
5 changes: 4 additions & 1 deletion verify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ To run these tests, a few things need to be in order prior.
Podman binary names will differ based on operating system. For Linux, use
the `podman-remote` binary. For all other platforms, use the `podman` binary.

Set the `PODMAN_BINARY` environment variable to specify the path of the binary
to use.

### How to run the image verification tests

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

To run the suite, use the Powershell script.

`> .\win_run_test.ps1 c:\Path\To\Disk\Image`
`> .\win_run_test.ps1 c:\Path\To\Disk\Image`
3 changes: 3 additions & 0 deletions verify/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ func runSystemCommand(binary string, cmdArgs []string, timeout time.Duration, wa
// Note: this will need to be moved Linux and everything else
// to distinguish between podman and podman-remote
func getPodmanBinary() (string, error) {
if env := os.Getenv("PODMAN_BINARY"); env != "" {
return env, nil
}
podmanBinary := getPodmanBinaryName()
return exec.LookPath(podmanBinary)
}

0 comments on commit 7e2c9a3

Please sign in to comment.