Skip to content

Commit

Permalink
Merge pull request #10 from embold/development
Browse files Browse the repository at this point in the history
Development merge
  • Loading branch information
bhidesacl authored Apr 12, 2024
2 parents b1d4425 + c749656 commit 8d11110
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
#run: mvn --batch-mode clean deploy io.embold.scan:embold-maven-plugin:embold -Dembold.host.url=https://oss.emboldci.dev -Dembold.user.token=${{ secrets.EMBOLD_TOKEN }} --file pom.xml
run: mvn --batch-mode clean deploy -Dembold.host.url=https://oss.emboldci.dev -Dembold.user.token=${{ secrets.EMBOLD_TOKEN }} --file pom.xml
#run: mvn --batch-mode clean deploy io.embold.scan:embold-maven-plugin:embold -Dembold.host.url=https://tester.emboldci.dev -Dembold.user.token=${{ secrets.EMBOLD_TOKEN }} --file pom.xml
run: mvn --batch-mode clean deploy -Dembold.host.url=https://tester.emboldci.dev -Dembold.user.token=${{ secrets.EMBOLD_TOKEN }} --file pom.xml

release:
runs-on: ubuntu-latest
Expand Down
21 changes: 18 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>io.embold.scan</groupId>
<artifactId>scanner-sync</artifactId>
<version>1.0.6-SNAPSHOT</version>
<version>1.0.8</version>
<name>scanner-sync</name>
<description>Embold scanner update library for remote scan execution workflows</description>
<url>https://github.com/embold/scanner-sync</url>
Expand Down Expand Up @@ -71,6 +71,21 @@
</repository>
</distributionManagement>

<!--
<distributionManagement>
<repository>
<id>acl.central</id>
<name>Internal Release Repository</name>
<url>http://artefacts.embold.io/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>acl.snapshots</id>
<name>Internal Snapshot Repository</name>
<url>http://artefacts.embold.io/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
-->

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down Expand Up @@ -190,7 +205,7 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<!-- <plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
Expand All @@ -200,7 +215,7 @@
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/io/embold/scan/ModularSyncSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ private void syncPackage(Package pack) throws SyncException {
logger.info("Checksum is calculated, " + checksum);

OsCheck.OSType os = OsCheck.getOperatingSystemType();
if (os.equals(OsCheck.OSType.MacOS)) {
// Currently if OS is Mac, default to Linux (TODO until we have Mac build)
os = OsCheck.OSType.Linux;
}
// if (os.equals(OsCheck.OSType.MacOS)) {
// // Currently if OS is Mac, default to Linux (TODO until we have Mac build)
// os = OsCheck.OSType.Linux;
// }

logger.info("os:" + os.toString());

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/embold/scan/Package.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package io.embold.scan;

public enum Package {
CORE, JAVA, CPP, C_SHARP, PYTHON, JAVASCRIPT, TYPESCRIPT, GO, SCALA, OBJECTIVE_C, KOTLIN, WEB, PHP, RUST, SOLIDITY, MULTI, SQL, SWIFT, RUBY, HTML, APEX, CSS
CORE, JAVA, CPP, C_SHARP, PYTHON, JAVASCRIPT, TYPESCRIPT, GO, SCALA, OBJECTIVE_C, KOTLIN, WEB, PHP, RUST, SOLIDITY, MULTI, SQL, SWIFT, RUBY, HTML, APEX, CSS, INFRASTRUCTURE, YAML, LUA
}
6 changes: 3 additions & 3 deletions src/main/java/io/embold/scan/SyncOpts.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public class SyncOpts {

public SyncOpts(String emboldUrl, String emboldToken, String coronaLocation) {
this.emboldUrl = emboldUrl;
if(StringUtils.endsWith(emboldUrl, "/")) {
this.emboldUrl = StringUtils.substringBeforeLast(emboldUrl, "/");
}
// if(StringUtils.endsWith(emboldUrl, "/")) {
// this.emboldUrl = StringUtils.substringBeforeLast(emboldUrl, "/");
// }

this.emboldToken = emboldToken;
this.coronaLocation = coronaLocation;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/io/embold/scan/exec/Downloader.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.embold.scan.exec;

import com.sun.java.swing.plaf.windows.resources.windows;
import io.embold.scan.SyncException;
import io.embold.scan.SyncOpts;
import kong.unirest.GetRequest;
Expand Down Expand Up @@ -34,7 +33,7 @@ public static boolean getCoronaPackage(SyncOpts opts, OsCheck.OSType os, String
return downloadPackageFromUrl(opts, opts.getEmboldUrl() + "/packagedownload/", os, "corona", checksum, destFile) != null;
}
public static File getShardedPackage(SyncOpts opts, OsCheck.OSType os, String packageName, String checksum, String destFile) throws SyncException {
return downloadPackageFromUrl(opts, opts.getEmboldUrl() + "/sharedpackagedownload/", os, packageName, checksum, destFile);
return downloadPackageFromUrl(opts, opts.getEmboldUrl(), os, packageName, checksum, destFile);
}

private static File downloadPackageFromUrl(SyncOpts opts, String url, OsCheck.OSType os, String packageName, String checksum, String destFile) throws SyncException {
Expand All @@ -43,7 +42,7 @@ private static File downloadPackageFromUrl(SyncOpts opts, String url, OsCheck.OS
if (StringUtils.isNotEmpty(checksum)) {
targetUrl += "&checksum=" + checksum;
}

logger.info("targetUrl : " + targetUrl);
GetRequest request = Unirest.get(targetUrl);
request.getHeaders().add("Authorization", "Bearer " + opts.getEmboldToken());

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/io/embold/scan/DownloadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DownloadTest extends PreReqBase {

@Test
void shouldSyncClean() {
SyncOpts opts = new SyncOpts(TestConstants.EMB_URL, TestConstants.EMB_TOKEN, tmpCoronaLocation.getAbsolutePath());
SyncOpts opts = new SyncOpts(TestConstants.EMB_URL + "/shardedpackagedownload", TestConstants.EMB_TOKEN, tmpCoronaLocation.getAbsolutePath());
try {
String coronaArchive = tmpCoronaLocation.getAbsolutePath() + File.separator + Constants.CORONA_ARCHIVE;
Downloader.getCoronaPackage(opts, OsCheck.OSType.Linux, null, coronaArchive);
Expand All @@ -35,7 +35,7 @@ void shouldSyncClean() {

@Test
void shouldDownloadTwice() {
SyncOpts opts = new SyncOpts(TestConstants.EMB_URL, TestConstants.EMB_TOKEN, tmpCoronaLocation.getAbsolutePath());
SyncOpts opts = new SyncOpts(TestConstants.EMB_URL + "/shardedpackagedownload", TestConstants.EMB_TOKEN, tmpCoronaLocation.getAbsolutePath());
try {
String coronaArchive = tmpCoronaLocation.getAbsolutePath() + File.separator + Constants.CORONA_ARCHIVE;
boolean downloaded = Downloader.getCoronaPackage(opts, OsCheck.OSType.Linux, null, coronaArchive);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/io/embold/scan/ModularSyncSessionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void shouldSyncClean() {
Set<Package> packs = new LinkedHashSet<>();
packs.add(Package.JAVA);
try {
ModularSyncOpts opts = new ModularSyncOpts(TestConstants.EMB_URL, TestConstants.EMB_TOKEN, tmpCoronaLocation.getAbsolutePath(), packs);
ModularSyncOpts opts = new ModularSyncOpts(TestConstants.EMB_URL + "/shardedpackagedownload/", TestConstants.EMB_TOKEN, tmpCoronaLocation.getAbsolutePath(), packs);
new ModularSyncSession(opts).run();
} catch (SyncException e) {
fail(e.getMessage());
Expand All @@ -30,7 +30,7 @@ void shouldSyncCleanAndCached() {
Set<Package> packs = new LinkedHashSet<>();
packs.add(Package.JAVA);
try {
ModularSyncOpts opts = new ModularSyncOpts(TestConstants.EMB_URL, TestConstants.EMB_TOKEN, tmpCoronaLocation.getAbsolutePath(), packs);
ModularSyncOpts opts = new ModularSyncOpts(TestConstants.EMB_URL + "/shardedpackagedownload/", TestConstants.EMB_TOKEN, tmpCoronaLocation.getAbsolutePath(), packs);
ModularSyncSession session = new ModularSyncSession(opts);
session.run();
session.run();
Expand Down

0 comments on commit 8d11110

Please sign in to comment.