diff --git a/.github/workflows/code_sample_checker.yml b/.github/workflows/code_sample_checker.yml index 87249d31f..2852a87d3 100644 --- a/.github/workflows/code_sample_checker.yml +++ b/.github/workflows/code_sample_checker.yml @@ -36,3 +36,12 @@ jobs: - name: Check code samples run: | npm run check-code-samples + + - name: Upload remote controller logs if test run fails + uses: actions/upload-artifact@v4 + if: failure() + with: + name: rc-logs-${{ matrix.os }} + path: | + rc_stderr.log + rc_stdout.log diff --git a/scripts/download-rc.js b/scripts/download-rc.js index 3d5770c0e..1ace79e1c 100644 --- a/scripts/download-rc.js +++ b/scripts/download-rc.js @@ -15,9 +15,6 @@ const downloadRC = () => { const os = require('os'); const {spawnSync} = require('child_process'); - const ON_WINDOWS = os.platform() === 'win32'; - const HAZELCAST_ENTERPRISE_KEY = process.env.HAZELCAST_ENTERPRISE_KEY ? process.env.HAZELCAST_ENTERPRISE_KEY : ''; - let REPO; let ENTERPRISE_REPO; let TEST_REPO; @@ -36,118 +33,41 @@ const downloadRC = () => { TEST_REPO = RELEASE_REPO; } - if (fs.existsSync(`hazelcast-remote-controller-${HAZELCAST_RC_VERSION}.jar`)) { - console.log('remote controller already exists, not downloading from maven.'); - } else { - console.log('Downloading: remote-controller jar com.hazelcast:hazelcast-remote-controller:' - + HAZELCAST_RC_VERSION); - const subprocess = spawnSync('mvn', - [ - '-q', - 'org.apache.maven.plugins:maven-dependency-plugin:2.10:get', - '-Dtransitive=false', - `-DremoteRepositories=${ENTERPRISE_SNAPSHOT_REPO}`, - `-Dartifact=com.hazelcast:hazelcast-remote-controller:${HAZELCAST_RC_VERSION}`, - `-Ddest=hazelcast-remote-controller-${HAZELCAST_RC_VERSION}.jar` - ], { - stdio: 'inherit', - shell: ON_WINDOWS - }); - if (subprocess.status !== 0) { - const subprocessTrace = subprocess.error ? subprocess.error.stack : ''; - throw 'Failed download remote-controller jar ' - + `com.hazelcast:hazelcast-remote-controller:${HAZELCAST_RC_VERSION} ${subprocessTrace}`; - } - } + downloadArtifact(ENTERPRISE_SNAPSHOT_REPO, 'hazelcast-remote-controller', HAZELCAST_RC_VERSION); + downloadArtifact(TEST_REPO, 'hazelcast', HAZELCAST_TEST_VERSION, 'tests'); + downloadArtifact(REPO, 'hazelcast-sql', HAZELCAST_VERSION); - if (fs.existsSync(`hazelcast-${HAZELCAST_TEST_VERSION}-tests.jar`)) { - console.log('hazelcast-test.jar already exists, not downloading from maven.'); + if (process.env.HAZELCAST_ENTERPRISE_KEY) { + downloadArtifact(ENTERPRISE_REPO, 'hazelcast-enterprise', HAZELCAST_ENTERPRISE_VERSION); } else { - console.log(`Downloading: hazelcast test jar com.hazelcast:hazelcast:${HAZELCAST_TEST_VERSION}:jar:tests`); - const subprocess = spawnSync('mvn', - [ - '-q', - 'org.apache.maven.plugins:maven-dependency-plugin:2.10:get', - '-Dtransitive=false', - `-DremoteRepositories=${TEST_REPO}`, - `-Dartifact=com.hazelcast:hazelcast:${HAZELCAST_TEST_VERSION}:jar:tests`, - `-Ddest=hazelcast-${HAZELCAST_TEST_VERSION}-tests.jar` - ], { - stdio: 'inherit', - shell: ON_WINDOWS - }); - if (subprocess.status !== 0) { - const subprocessTrace = subprocess.error ? subprocess.error.stack : ''; - throw 'Failed download hazelcast test jar com.hazelcast:hazelcast:' - + `${HAZELCAST_TEST_VERSION}:jar:tests ${subprocessTrace}`; - } + downloadArtifact(REPO, 'hazelcast', HAZELCAST_VERSION); } - if (fs.existsSync(`hazelcast-sql-${HAZELCAST_VERSION}.jar`)) { - console.log('hazelcast-sql.jar already exists, not downloading from maven.'); - } else { - console.log(`Downloading: hazelcast sql jar com.hazelcast:hazelcast-sql:${HAZELCAST_VERSION}`); - const subprocess = spawnSync('mvn', [ - '-q', - 'org.apache.maven.plugins:maven-dependency-plugin:2.10:get', - '-Dtransitive=false', - `-DremoteRepositories=${REPO}`, - `-Dartifact=com.hazelcast:hazelcast-sql:${HAZELCAST_VERSION}`, - `-Ddest=hazelcast-sql-${HAZELCAST_VERSION}.jar` - ], { - stdio: 'inherit', - shell: ON_WINDOWS - }); - if (subprocess.status !== 0) { - const subprocessTrace = subprocess.error ? subprocess.error.stack : ''; - throw 'Failed download hazelcast sql jar' - + `com.hazelcast:hazelcast-sql:${HAZELCAST_VERSION} ${subprocessTrace}`; + function downloadArtifact(repo, artifactId, version, classifier = '') { + const filename = classifier ? `${artifactId}-${version}-${classifier}.jar` : `${artifactId}-${version}.jar`; + let artifact = `com.hazelcast:${artifactId}:${version}:jar`; + if (classifier) { + artifact += `:${classifier}`; } - } - if (HAZELCAST_ENTERPRISE_KEY) { - if (fs.existsSync(`hazelcast-enterprise-${HAZELCAST_ENTERPRISE_VERSION}.jar`)) { - console.log('hazelcast-enterprise.jar already exists, not downloading from maven.'); - } else { - console.log('Downloading: hazelcast enterprise jar ' - + `com.hazelcast:hazelcast-enterprise:${HAZELCAST_ENTERPRISE_VERSION}`); - const subprocess = spawnSync('mvn', [ - '-q', - 'org.apache.maven.plugins:maven-dependency-plugin:2.10:get', - '-Dtransitive=false', - `-DremoteRepositories=${ENTERPRISE_REPO}`, - `-Dartifact=com.hazelcast:hazelcast-enterprise:${HAZELCAST_ENTERPRISE_VERSION}`, - `-Ddest=hazelcast-enterprise-${HAZELCAST_ENTERPRISE_VERSION}.jar` - ], { - stdio: 'inherit', - shell: ON_WINDOWS - }); - if (subprocess.status !== 0) { - const subprocessTrace = subprocess.error ? subprocess.error.stack : ''; - throw 'Failed download hazelcast enterprise jar ' - + `com.hazelcast:hazelcast-enterprise:${HAZELCAST_ENTERPRISE_VERSION} ${subprocessTrace}`; - } - } - console.log('Starting Remote Controller ... enterprise ...'); - } else { - if (fs.existsSync(`hazelcast-${HAZELCAST_VERSION}.jar`)) { - console.log('hazelcast.jar already exists, not downloading from maven.'); + if (fs.existsSync(filename)) { + console.log('${filename} already exists, download not required'); } else { - console.log(`Downloading: hazelcast jar com.hazelcast:hazelcast:${HAZELCAST_VERSION}`); + console.log(`Downloading: ${artifact} to ${filename}`); const subprocess = spawnSync('mvn', [ '-q', 'org.apache.maven.plugins:maven-dependency-plugin:2.10:get', '-Dtransitive=false', - `-DremoteRepositories=${REPO}`, - `-Dartifact=com.hazelcast:hazelcast:${HAZELCAST_VERSION}`, - `-Ddest=hazelcast-${HAZELCAST_VERSION}.jar` + `-DremoteRepositories=${repo}`, + `-Dartifact=${artifact}`, + `-Ddest=${filename}` ], { stdio: 'inherit', - shell: ON_WINDOWS + shell: os.platform() === 'win32' }); if (subprocess.status !== 0) { const subprocessTrace = subprocess.error ? subprocess.error.stack : ''; - throw `Failed download hazelcast jar com.hazelcast:hazelcast:${HAZELCAST_VERSION} ${subprocessTrace}`; + throw `Failed to download ${artifact} to ${filename} - ${subprocessTrace}`; } } } diff --git a/scripts/test-runner.js b/scripts/test-runner.js index b78ab10ed..8a30c0032 100644 --- a/scripts/test-runner.js +++ b/scripts/test-runner.js @@ -68,7 +68,7 @@ const getRC = () => { }; const startRC = async () => { - console.log('Starting Hazelcast Remote Controller ... oss ...'); + console.log('Starting Hazelcast Remote Controller ...'); if (ON_WINDOWS) { const outFD = fs.openSync('rc_stdout.log', 'w'); const errFD = fs.openSync('rc_stderr.log', 'w');