Skip to content

Commit a0d1901

Browse files
author
szachovy
committed
In CI always build images locally; outside CI pull then build as fallback
- pull_or_build_image: when GITHUB_ACTIONS=true, always build from the local build context (uploaded source) instead of checking for a pre-loaded or registry image. Outside CI, try pull first, build on failure. - remote.py: forward GITHUB_ACTIONS=true over SSH so nodes see it. - tests.yml: remove the build-and-load step; nodes now build images themselves during deployment, so pre-loading is unnecessary.
1 parent 18090d1 commit a0d1901

3 files changed

Lines changed: 5 additions & 27 deletions

File tree

.github/workflows/tests.yml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,29 +53,6 @@ jobs:
5353
run: "terraform apply --auto-approve"
5454
working-directory: "${{ env.TERRAFORM_WORKING_DIRECTORY }}"
5555

56-
- name: "Build and pre-load service images into test containers"
57-
run: |
58-
set -o pipefail
59-
build_and_load() {
60-
local image_name="$1"
61-
local build_context="$2"
62-
shift 2
63-
local nodes=("$@")
64-
docker build --quiet -t "${image_name}:latest" "$build_context"
65-
for node in "${nodes[@]}"; do
66-
docker save "${image_name}:latest" | docker exec -i "$node" docker load
67-
done
68-
docker rmi "${image_name}:latest" || true
69-
docker image prune --force
70-
}
71-
build_and_load "ghcr.io/szachovy/superset-cluster-mysql-server" \
72-
"services/mysql-server" node-2 node-3 node-4
73-
build_and_load "ghcr.io/szachovy/superset-cluster-mysql-mgmt" \
74-
"services/mysql-mgmt" node-0 node-1
75-
build_and_load "ghcr.io/szachovy/superset-cluster-superset-service" \
76-
"services/superset" node-0 node-1
77-
docker image prune --all --force
78-
7956
- name: "Run Ansible testsuite"
8057
run: |
8158
set -o pipefail

src/container.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ def __init__(self, container: str | None) -> None:
102102

103103
@staticmethod
104104
def pull_or_build_image(client: docker.client.DockerClient, image: str, build_context: str) -> None:
105-
try:
106-
client.images.get(image)
107-
except docker.errors.ImageNotFound:
105+
if os.environ.get("GITHUB_ACTIONS") == "true":
106+
client.images.build(path=build_context, tag=image)
107+
else:
108108
try:
109109
client.images.pull(image)
110110
except (docker.errors.DockerException, requests.exceptions.RequestException):

src/remote.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ def run_python_container_command(self, command: str) -> dict:
125125
) as memfile:
126126
source = memfile.read() + command
127127
self.upload_file(content=source, remote_file_path=f'/opt/{nonce}.py')
128+
github_actions_env = "GITHUB_ACTIONS=true " if os.environ.get("GITHUB_ACTIONS") == "true" else ""
128129
_, stdout, stderr = self.ssh_client.exec_command(
129-
f"PYTHONPATH=/home/superset/.local/lib/python3.10/site-packages python3 /opt/{nonce}.py"
130+
f"{github_actions_env}PYTHONPATH=/home/superset/.local/lib/python3.10/site-packages python3 /opt/{nonce}.py"
130131
)
131132
result = {
132133
"output": stdout.read().decode(),

0 commit comments

Comments
 (0)