This is an automated email from the ASF dual-hosted git repository.
tiagobento pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git
The following commit(s) were added to refs/heads/main by this push:
new 0dcd652c5a5 NO-ISSUE: Fix macOS build GitHub Action when running
docker builds and tests (#2184)
0dcd652c5a5 is described below
commit 0dcd652c5a502b5f236519e93422f2f25a995470
Author: Thiago Lugli <[email protected]>
AuthorDate: Wed Feb 28 11:56:44 2024 -0300
NO-ISSUE: Fix macOS build GitHub Action when running docker builds and
tests (#2184)
---
.github/actions/setup-env/action.yml | 49 +++++++++++++---------
.../dev/Containerfile.ddus-buildtime-install | 3 +-
.../dev/Containerfile.ddus-runtime-install | 3 +-
.../dev-deployment-upload-service/env/index.js | 21 +++++++++-
.../dev-deployment-upload-service/package.json | 2 +-
.../scripts/generateInstallScript.js | 5 +--
.../scripts/runTestServers.js | 29 ++++++++++---
.../tests/integrationTest.test.js | 18 ++++++--
8 files changed, 94 insertions(+), 36 deletions(-)
diff --git a/.github/actions/setup-env/action.yml
b/.github/actions/setup-env/action.yml
index e1c1d0dde23..bdbc9172d95 100644
--- a/.github/actions/setup-env/action.yml
+++ b/.github/actions/setup-env/action.yml
@@ -74,29 +74,38 @@ runs:
env:
HOMEBREW_NO_INSTALL_FROM_API:
run: |
- brew untap homebrew/core homebrew/cask
- brew update
- brew install docker docker-compose
- cat >entitlements.xml <<EOF
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
- <plist version="1.0">
- <dict>
- <key>com.apple.security.hypervisor</key>
- <true/>
- </dict>
- </plist>
- EOF
-
- codesign --sign - --entitlements entitlements.xml --force
/usr/local/bin/qemu-system-$(uname -m | sed -e s/arm64/aarch64/)
+ echo "STEP: Setup docker (macOS only)"
+ brew update --preinstall
+ LIMA_VERSION=v0.20.1
+ curl -fsSL
"https://github.com/lima-vm/lima/releases/download/${LIMA_VERSION}/lima-${LIMA_VERSION:1}-$(uname
-s)-$(uname -m).tar.gz" | tar Cxzvm /usr/local
+ COLIMA_VERSION=v0.6.8
+ curl -LO
https://github.com/abiosoft/colima/releases/download/${COLIMA_VERSION}/colima-$(uname)-$(uname
-m)
+ install colima-$(uname)-$(uname -m) /usr/local/bin/colima
+ brew install docker docker-compose docker-Buildx qemu 2>&1 | tee
install.log
mkdir -p ~/.docker/cli-plugins
- ln -sfn $(brew --prefix)/opt/docker-compose/bin/docker-compose
~/.docker/cli-plugins/docker-compose
- brew install docker-Buildx
+ ln -sfn "$(brew --prefix)/opt/docker-compose/bin/docker-compose"
~/.docker/cli-plugins/docker-compose
ln -sfn $(brew --prefix)/opt/docker-buildx/bin/docker-buildx
~/.docker/cli-plugins/docker-buildx
- colima stop
- colima delete
+ if grep -q "qemu 8.1.0 is already installed" install.log
+ then
+ echo "Detected broken QEMU bottle installed by brew, removing and
reinstalling."
+ brew reinstall qemu
+ fi
colima start --memory 4 --network-address --verbose
- # QEMU is reinstalled due to this bug:
https://github.com/lima-vm/lima/issues/1742
+
+ EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
+ echo "version<<$EOF" >> "$GITHUB_OUTPUT"
+ docker version >> "$GITHUB_OUTPUT"
+ echo "$EOF" >> "$GITHUB_OUTPUT"
+
+ EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
+ echo "version<<$EOF" >> "$GITHUB_OUTPUT"
+ docker compose version >> "$GITHUB_OUTPUT"
+ echo "$EOF" >> "$GITHUB_OUTPUT"
+
+ EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
+ echo "version<<$EOF" >> "$GITHUB_OUTPUT"
+ colima version >> "$GITHUB_OUTPUT"
+ echo "$EOF" >> "$GITHUB_OUTPUT"
- name: "Setup Helm (Ubuntu)"
if: runner.os == 'Linux'
diff --git
a/packages/dev-deployment-upload-service/dev/Containerfile.ddus-buildtime-install
b/packages/dev-deployment-upload-service/dev/Containerfile.ddus-buildtime-install
index 79523968e4d..8597df5f4b8 100644
---
a/packages/dev-deployment-upload-service/dev/Containerfile.ddus-buildtime-install
+++
b/packages/dev-deployment-upload-service/dev/Containerfile.ddus-buildtime-install
@@ -19,6 +19,7 @@ FROM registry.access.redhat.com/ubi9/ubi-minimal:9.3
ARG DDUS_FILESERVER_IP=""
ARG DDUS_VERSION="0.0.0"
+ARG DDUS_FILESERVER_PORT=8090
EXPOSE 8091
@@ -29,7 +30,7 @@ ENV DEV_DEPLOYMENT__UPLOAD_SERVICE_ROOT_PATH="/"
RUN microdnf install -y tar gzip findutils
-RUN curl
${DDUS_FILESERVER_IP}:8090/apache/incubator-kie-tools/releases/download/${DDUS_VERSION}/getDevDeploymentUploadService.sh
| sed 's/localhost:8090/${DDUS_FILESERVER_IP}:8090/;
s/https:\/\/github.com/http:\/\/${DDUS_FILESERVER_IP}:8090/' | bash
+RUN curl
${DDUS_FILESERVER_IP}:${DDUS_FILESERVER_PORT}/apache/incubator-kie-tools/releases/download/${DDUS_VERSION}/getDevDeploymentUploadService.sh
| sed
's/localhost:${DDUS_FILESERVER_PORT}/${DDUS_FILESERVER_IP}:${DDUS_FILESERVER_PORT}/;
s/https:\/\/github.com/http:\/\/${DDUS_FILESERVER_IP}:${DDUS_FILESERVER_PORT}/'
| bash
CMD dev-deployment-upload-service \
&& find /tmp/unzip-at | sort -k1 | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^
]\)/|-\1/" \
diff --git
a/packages/dev-deployment-upload-service/dev/Containerfile.ddus-runtime-install
b/packages/dev-deployment-upload-service/dev/Containerfile.ddus-runtime-install
index c134a4a3e3a..7731d1a359a 100644
---
a/packages/dev-deployment-upload-service/dev/Containerfile.ddus-runtime-install
+++
b/packages/dev-deployment-upload-service/dev/Containerfile.ddus-runtime-install
@@ -19,6 +19,7 @@ FROM registry.access.redhat.com/ubi9/ubi-minimal:9.3
ENV DDUS_FILESERVER_IP=""
ENV DDUS_VERSION="0.0.0"
+ENV DDUS_FILESERVER_PORT=8090
EXPOSE 8092
@@ -29,7 +30,7 @@ ENV DEV_DEPLOYMENT__UPLOAD_SERVICE_ROOT_PATH="/"
RUN microdnf install -y tar gzip findutils
-CMD curl
$DDUS_FILESERVER_IP:8090/apache/incubator-kie-tools/releases/download/$DDUS_VERSION/getDevDeploymentUploadService.sh
| sed 's/localhost:8090/$DDUS_FILESERVER_IP:8090/;
s/https:\/\/github.com/http:\/\/$DDUS_FILESERVER_IP:8090/' | bash \
+CMD curl
$DDUS_FILESERVER_IP:${DDUS_FILESERVER_PORT}/apache/incubator-kie-tools/releases/download/$DDUS_VERSION/getDevDeploymentUploadService.sh
| sed
's/localhost:${DDUS_FILESERVER_PORT}/$DDUS_FILESERVER_IP:${DDUS_FILESERVER_PORT}/;
s/https:\/\/github.com/http:\/\/$DDUS_FILESERVER_IP:${DDUS_FILESERVER_PORT}/'
| bash \
&& dev-deployment-upload-service \
&& find /tmp/unzip-at | sort -k1 | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^
]\)/|-\1/" \
&& echo 'Done!'
\ No newline at end of file
diff --git a/packages/dev-deployment-upload-service/env/index.js
b/packages/dev-deployment-upload-service/env/index.js
index aaed9d2bbd8..be73994502f 100644
--- a/packages/dev-deployment-upload-service/env/index.js
+++ b/packages/dev-deployment-upload-service/env/index.js
@@ -21,16 +21,30 @@ const { varsWithName, composeEnv, getOrDefault } =
require("@kie-tools-scripts/b
const buildEnv = require("@kie-tools/root-env/env");
+const version = require("../package.json").version;
+
module.exports = composeEnv([buildEnv], {
vars: varsWithName({
DEV_DEPLOYMENT_UPLOAD_SERVICE__downloadPath: {
- default:
`apache/incubator-kie-tools/releases/download/${buildEnv.env.root.version}`,
+ default: `apache/incubator-kie-tools/releases/download/${version}`,
description: "Download path for the Dev Deployment Upload Service binary
package.",
},
DEV_DEPLOYMENT_UPLOAD_SERVICE__downloadHost: {
default: `https://github.com`,
description: "Download host for the Dev Deployment Upload Service binary
package.",
},
+ DEV_DEPLOYMENT_UPLOAD_SERVICE__devFileServerPort: {
+ default: 2340,
+ description: "",
+ },
+ DEV_DEPLOYMENT_UPLOAD_SERVICE__devBuildTimeInstallPort: {
+ default: 2341,
+ description: "",
+ },
+ DEV_DEPLOYMENT_UPLOAD_SERVICE__devRunTimeInstallPort: {
+ default: 2342,
+ description: "",
+ },
}),
get env() {
return {
@@ -39,6 +53,11 @@ module.exports = composeEnv([buildEnv], {
path:
getOrDefault(this.vars.DEV_DEPLOYMENT_UPLOAD_SERVICE__downloadPath),
host:
getOrDefault(this.vars.DEV_DEPLOYMENT_UPLOAD_SERVICE__downloadHost),
},
+ dev: {
+ fileServerPort:
getOrDefault(this.vars.DEV_DEPLOYMENT_UPLOAD_SERVICE__devFileServerPort),
+ buildTimePort:
getOrDefault(this.vars.DEV_DEPLOYMENT_UPLOAD_SERVICE__devBuildTimeInstallPort),
+ runtTimePort:
getOrDefault(this.vars.DEV_DEPLOYMENT_UPLOAD_SERVICE__devRunTimeInstallPort),
+ },
},
};
},
diff --git a/packages/dev-deployment-upload-service/package.json
b/packages/dev-deployment-upload-service/package.json
index a1123b4ff43..e353539ea45 100644
--- a/packages/dev-deployment-upload-service/package.json
+++ b/packages/dev-deployment-upload-service/package.json
@@ -29,7 +29,7 @@
"start": "make start",
"start-test-servers": "run-script-if --bool \"$(build-env
containerImages.build)\" --then \"node scripts/runTestServers.js\"",
"stop-test-servers": "run-script-if --bool \"$(build-env
containerImages.build)\" --then \"node scripts/runTestServers.js --cleanup\"",
- "test": "run-script-if --bool \"$(build-env containerImages.build)\"
--bool \"$(build-env tests.run)\" --ignore-errors \"$(build-env
tests.ignoreFailures)\" --then \"jest --verbose\""
+ "test": "run-script-if --bool \"$(build-env containerImages.build)\"
--bool \"$(build-env tests.run)\" --ignore-errors \"$(build-env
tests.ignoreFailures)\" --then \"jest --verbose --silent=false\""
},
"devDependencies": {
"@kie-tools/root-env": "workspace:*",
diff --git
a/packages/dev-deployment-upload-service/scripts/generateInstallScript.js
b/packages/dev-deployment-upload-service/scripts/generateInstallScript.js
index 459a465321c..bff272cd83c 100644
--- a/packages/dev-deployment-upload-service/scripts/generateInstallScript.js
+++ b/packages/dev-deployment-upload-service/scripts/generateInstallScript.js
@@ -18,15 +18,14 @@
*/
const fs = require("fs");
-const buildEnv = require("@kie-tools/root-env/env");
-const devDeploymentUploadServiceEnv = require("../env/index");
+const version = require("../package.json").version;
+const devDeploymentUploadServiceEnv = require("../env");
const { argv } = require("process");
const baseInstallScriptFile =
fs.readFileSync("getDevDeploymentUploadService.sh");
const contents = baseInstallScriptFile.toString();
-const version = buildEnv.env.root.version;
const downloadPath =
devDeploymentUploadServiceEnv.env.devDeploymentUploadService.url.path;
const downloadHost =
devDeploymentUploadServiceEnv.env.devDeploymentUploadService.url.host;
diff --git a/packages/dev-deployment-upload-service/scripts/runTestServers.js
b/packages/dev-deployment-upload-service/scripts/runTestServers.js
index c56ffd096f8..43422ec7afa 100644
--- a/packages/dev-deployment-upload-service/scripts/runTestServers.js
+++ b/packages/dev-deployment-upload-service/scripts/runTestServers.js
@@ -19,8 +19,8 @@
const { execSync } = require("child_process");
const { argv } = require("process");
-const buildEnv = require("@kie-tools/root-env/env");
-const version = buildEnv.env.root.version;
+const version = require("../package.json").version;
+const buildEnv = require("../env");
const network = "ddus-network";
const builder = "ddus-builder";
@@ -31,6 +31,12 @@ const containersNames = {
runTimeInstall: "ddus-runtime-install",
};
+const containersPorts = {
+ fileserver: buildEnv.env.devDeploymentUploadService.dev.fileServerPort,
+ buildtimeInstall: buildEnv.env.devDeploymentUploadService.dev.buildTimePort,
+ runTimeInstall: buildEnv.env.devDeploymentUploadService.dev.runtTimePort,
+};
+
function cleanup() {
try {
execSync(`docker stop ${containersNames.fileserver} && docker rm
${containersNames.fileserver}`);
@@ -77,7 +83,7 @@ let fileServerIp;
try {
console.info(`Starting File Server container:
${containersNames.fileserver}`);
execSync(
- `docker run -d --name ${containersNames.fileserver} --network ${network}
-p 8090:8090 $(docker buildx build -q --build-arg DDUS_VERSION=${version} . -f
./dev/Containerfile.${containersNames.fileserver} --load)`,
+ `docker run -d --name ${containersNames.fileserver} --network ${network}
-p ${containersPorts.fileserver}:8090 $(docker buildx build -q --build-arg
DDUS_VERSION=${version} --build-arg
DDUS_FILESERVER_PORT=${containersPorts.fileserver} . -f
./dev/Containerfile.${containersNames.fileserver} --load)`,
{ stdio: "inherit" }
);
fileServerIp = execSync(`docker exec ${containersNames.fileserver} awk
'END{print $1}' /etc/hosts`).toString().trim();
@@ -91,6 +97,7 @@ try {
execSync(`docker buildx create --name ${builder} --driver docker-container
--driver-opt network=${network}`, {
stdio: "inherit",
});
+ execSync("docker buildx ls", { stdio: "inherit" });
} catch (e) {
cleanup();
throw new Error(`Failed to create builder ${builder}. Exiting!`);
@@ -99,7 +106,7 @@ try {
try {
console.info(`Starting BuildTime Install container:
${containersNames.buildtimeInstall}`);
execSync(
- `docker run -d --name ${containersNames.buildtimeInstall} --network
${network} -p 8091:8091 $(docker buildx --builder ${builder} build -q
--build-arg DDUS_VERSION=${version} --build-arg
DDUS_FILESERVER_IP=${fileServerIp} . -f
./dev/Containerfile.${containersNames.buildtimeInstall} --load)`,
+ `docker run -d --name ${containersNames.buildtimeInstall} --network
${network} -p ${containersPorts.buildtimeInstall}:8091 $(docker buildx
--builder ${builder} build -q --build-arg DDUS_VERSION=${version} --build-arg
DDUS_FILESERVER_PORT=8090 --build-arg DDUS_FILESERVER_IP=${fileServerIp} . -f
./dev/Containerfile.${containersNames.buildtimeInstall} --load)`,
{ stdio: "inherit" }
);
} catch (e) {
@@ -110,10 +117,22 @@ try {
try {
console.info(`Starting RunTime Install container:
${containersNames.runTimeInstall}`);
execSync(
- `docker run -d --name ${containersNames.runTimeInstall} --network
${network} -p 8092:8092 -e DDUS_FILESERVER_IP=${fileServerIp} -e
DDUS_VERSION=${version} $(docker buildx --builder ${builder} build -q . -f
./dev/Containerfile.${containersNames.runTimeInstall} --load)`,
+ `docker run -d --name ${containersNames.runTimeInstall} --network
${network} -p ${containersPorts.runTimeInstall}:8092 -e
DDUS_FILESERVER_IP=${fileServerIp} -e DDUS_VERSION=${version} -e
DDUS_FILESERVER_PORT=8090 $(docker buildx --builder ${builder} build -q . -f
./dev/Containerfile.${containersNames.runTimeInstall} --load)`,
{ stdio: "inherit" }
);
} catch (e) {
cleanup();
throw new Error(`Failed to build and start
${containersNames.runTimeInstall}. Exiting!`);
}
+
+execSync("docker ps -f name=ddus", { stdio: "inherit" });
+
+execSync("sleep 10");
+
+Object.values(containersNames).forEach((name) => {
+ const logs = execSync(`docker logs ${name}`).toString();
+ console.info(`Checking logs for ${name}:`);
+ console.info("--------------------------");
+ console.info(logs);
+ console.info("--------------------------");
+});
diff --git
a/packages/dev-deployment-upload-service/tests/integrationTest.test.js
b/packages/dev-deployment-upload-service/tests/integrationTest.test.js
index 4ec91ed4745..b4308286770 100644
--- a/packages/dev-deployment-upload-service/tests/integrationTest.test.js
+++ b/packages/dev-deployment-upload-service/tests/integrationTest.test.js
@@ -19,12 +19,22 @@
const { execSync, execFileSync } = require("child_process");
const path = require("path");
+const buildEnv = require("../env");
const filePath = path.join(process.cwd(), "tests/test.zip");
+const containersPorts = {
+ fileserver: buildEnv.env.devDeploymentUploadService.dev.fileServerPort,
+ buildtimeInstall: buildEnv.env.devDeploymentUploadService.dev.buildTimePort,
+ runTimeInstall: buildEnv.env.devDeploymentUploadService.dev.runtTimePort,
+};
+
describe("Test built images individually", () => {
beforeAll(() => {
- execSync("pnpm start-test-servers && wait-on -t 20m
http://localhost:8092/upload-status");
+ execSync(
+ `pnpm start-test-servers && wait-on -t 20m
http://localhost:${containersPorts.runTimeInstall}/upload-status`,
+ { stdio: "inherit" }
+ );
});
it("buildtime install", async () => {
const response = execFileSync("curl", [
@@ -34,7 +44,7 @@ describe("Test built images individually", () => {
"Content-Type: multipart/form-data",
"-F",
`myFile=@${filePath}`,
- "http://localhost:8091/upload?apiKey=dev",
+ `http://localhost:${containersPorts.buildtimeInstall}/upload?apiKey=dev`,
]).toString();
const dockerLogs = execSync(`docker logs ddus-buildtime-install`)
.toString()
@@ -50,7 +60,7 @@ describe("Test built images individually", () => {
"Content-Type: multipart/form-data",
"-F",
`myFile=@${filePath}`,
- "http://localhost:8092/upload?apiKey=dev",
+ `http://localhost:${containersPorts.runTimeInstall}/upload?apiKey=dev`,
]).toString();
const dockerLogs = execSync(`docker logs ddus-runtime-install`)
.toString()
@@ -59,6 +69,6 @@ describe("Test built images individually", () => {
expect(dockerLogs).toMatchSnapshot();
});
afterAll(() => {
- execSync("pnpm stop-test-servers");
+ execSync("pnpm stop-test-servers", { stdio: "inherit" });
});
});
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]