Skip to content

Commit

Permalink
Ready for 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
clun committed Jul 28, 2023
1 parent 78abdcb commit 1fb154d
Show file tree
Hide file tree
Showing 10 changed files with 174 additions and 162 deletions.
120 changes: 70 additions & 50 deletions RELEASES.MD
Original file line number Diff line number Diff line change
@@ -1,95 +1,115 @@

### TESTS
## Deployment

- Generate Jacoco report and push to Coverall
### 1. Git

- Start the agent
```bash
mvn clean test jacoco:report coveralls:report
eval "$(ssh-agent -s)"
```

- Generate Sonar report and push to Coverall

- Check key is available
```bash
export SONAR_TOKEN=...
mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=clun_astra-cli
ssh-add -l
```

### PACKAGING

- Build the project

- Add the key (if needed)
```
mvn clean install
cd ~/.ssh
ssh-add githubff4j
```

- Run with Agent:
### 2. Update versions and dependencies

_Make sure you are using a graalVM JDK_
- Check for dependency updates and update the `pom.xml` file when relevant.

```bash
sdk install java 22.3.1.r17-grl
java --version
mvn versions:display-dependency-update
```

```
/Library/Java/JavaVirtualMachines/graalvm-ce-java17-21.3.0/Contents/Home/bin/java -agentlib:native-image-agent=config-output-dir=/tmp/native-image -jar target/astra-cli-0.2-shaded.jar token list
- Update project version
```bash
mvn versions:set -DnewVersion=0.4
```

- Build as a native image

```
mvn clean install -Pnative
- When ok commit
```bash
mvn versions:commit
```

### PUSH

- Start the `ssh-agent`
```
eval "$(ssh-agent -s)"
```
- Add the ssh key to the agent
```
cd ~/.ssh
ssh-add githubff4j
```
- Update sources
- Make sure everything is in sync
```
find . -type f -name *.DS_Store -ls -delete
git pull
git add -A
git commit -m "delivery"
git push
git commit -m "Preparing for deployment"
```
- Release

### 3. Build and Tests

- Generate Jacoco report and push to Coverall and get results at [Coveralls.io](https://coveralls.io/github/datastax/astra-cli)

```bash
mvn clean test jacoco:report coveralls:report
```
mvn clean -DskipTests -Darguments=-DskipTests release:prepare release:perform

- Generate Sonar report and push to sonar cloud and get results at [SonarCloud.io](https://sonarcloud.io/summary/overall?id=clun_astra-cli)

```bash
export SONAR_TOKEN=...
mvn verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=clun_astra-cli
```

### DEPLOY
### 4. Packaging

- Build the project
- Install proper java and graal VM if needed

- Copy `astra-init.sh` on each distribution folder
```bash
sdk install java 22.3.1.r17-grl
java --version
```

- Copy the shaded and put it in Java folder, rename to `astra-cli.jar`
- Build project

- Build in native
```
mvn clean install
```

- Check `reflect-config.json` and `resource-config.json` are updated with all classes and commands

```json
{
"name":"com.dtsx.astra.cli.org.OrgIdCmd",
"allDeclaredFields":true,
"methods":[{"name":"<init>","parameterTypes":[] }]
}
```
- Build project a native image

```
mvn clean install -Pnative
```

- Chmod everything
- Chmod everything execution files

```bash
chmod 755 src/main/dist/astra-init.sh
```

- Copy `dist/astra-init.sh` (_generated by a test)_ on each distribution folder


- Copy the shaded and put it in Java folder, rename to `astra-cli.jar`


- Packaging

```
zip astra-cli-0.2.zip *
zip astra-cli-0.2-linux.zip *
zip astra-cli-0.2-windows.zip *
zip astra-cli-0.2-mac.zip *
tar -czf astra-cli-0.2-brew.tar.gz *
brew create https://github.com/datastax/astra-cli/releases/download/0.2/astra-cli-0.2-homebrew.tar.gz
zip astra-cli-0.4.zip *
zip astra-cli-0.4-linux.zip *
zip astra-cli-0.4-mac.zip *
tar -czf astra-cli-0.4-brew.tar.gz *
brew create https://github.com/datastax/astra-cli/releases/download/0.4/astra-cli-0.4-homebrew.tar.gz
```

- Edit Releases
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<app.main.class>com.dtsx.astra.cli.AstraCli</app.main.class>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<astra-sdk.version>0.6.7-SNAPSHOT</astra-sdk.version>
<astra-sdk.version>0.6.7</astra-sdk.version>
<jansi.version>2.4.0</jansi.version>
<airline.version>2.9.0</airline.version>
<slf4j.version>2.0.7</slf4j.version>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/dtsx/astra/cli/AstraCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
import com.dtsx.astra.sdk.db.exception.ChangeDataCaptureNotFoundException;
import com.dtsx.astra.sdk.db.exception.DatabaseNotFoundException;
import com.dtsx.astra.sdk.db.exception.KeyspaceAlreadyExistException;
import com.dtsx.astra.sdk.db.exception.KeyspaceNotFoundException;
import com.dtsx.astra.sdk.db.exception.RegionAlreadyExistException;
import com.dtsx.astra.sdk.db.exception.RegionNotFoundException;
import com.dtsx.astra.sdk.streaming.exception.TenantAlreadyExistException;
Expand Down Expand Up @@ -315,7 +316,7 @@ public static ExitCode run(Class<?> clazz, String[] args) {
} catch (InvalidArgumentException | IllegalArgumentException dex) {
AstraCliConsole.outputError(ExitCode.INVALID_ARGUMENT, dex.getMessage());
return ExitCode.INVALID_ARGUMENT;
} catch (DatabaseNotFoundException |
} catch (DatabaseNotFoundException | KeyspaceNotFoundException |
TenantNotFoundException |
RoleNotFoundException | ChangeDataCaptureNotFoundException |
UserNotFoundException | RegionNotFoundException ex) {
Expand Down
20 changes: 6 additions & 14 deletions src/main/java/com/dtsx/astra/cli/config/ServiceConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@
import com.dtsx.astra.sdk.utils.ApiLocator;
import com.dtsx.astra.sdk.utils.AstraRc;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;

/**
Expand Down Expand Up @@ -86,17 +83,17 @@ public static void listConfigurations() {
.get(AstraCliConfiguration.ASTRARC_DEFAULT)
.get(AstraRc.ASTRA_DB_APPLICATION_TOKEN));
}
for (String sectionName : sections.keySet()) {
if (!AstraCliConfiguration.ASTRARC_DEFAULT.equalsIgnoreCase(sectionName)) {
for (Map.Entry<String, Map<String, String>> section : sections.entrySet()) {
if (!AstraCliConfiguration.ASTRARC_DEFAULT.equalsIgnoreCase(section.getKey())) {
Map<String, String> rf = new HashMap<>();
String currentToken = sections.get(sectionName).get(AstraRc.ASTRA_DB_APPLICATION_TOKEN);
String currentToken = sections.get(section.getKey()).get(AstraRc.ASTRA_DB_APPLICATION_TOKEN);
if (defaultToken.isPresent() && defaultToken.get().equals(currentToken)) {
rf.put(COLUMN_TITLE, StringBuilderAnsi.colored(sectionName + " (in use)", AstraAnsiColors.PURPLE_300));
rf.put(COLUMN_TITLE, StringBuilderAnsi.colored(section.getKey() + " (in use)", AstraAnsiColors.PURPLE_300));
} else {
rf.put(COLUMN_TITLE, sectionName);
rf.put(COLUMN_TITLE, section.getKey());
}
if (isMultiEnv) {
rf.put(COLUMN_ENV, Optional.ofNullable(sections.get(sectionName)
rf.put(COLUMN_ENV, Optional.ofNullable(sections.get(section.getKey())
.get(AstraCliConfiguration.KEY_ENV))
.orElse(ApiLocator.AstraEnvironment.PROD.name()));
}
Expand All @@ -118,11 +115,6 @@ public static boolean isMultiEnvironment(Map<String, Map<String, String>> sectio
.anyMatch(key -> key.equals(AstraCliConfiguration.KEY_ENV));
}

public static boolean isDefaultSection(Map<String, Map<String, String>> sections, String sectionName) {
return AstraCliConfiguration.ASTRARC_DEFAULT.equalsIgnoreCase(sectionName)
&& sections.containsKey(AstraCliConfiguration.ASTRARC_DEFAULT);
}

/**
* Test existence of section in document.
*
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/dtsx/astra/cli/core/CliContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
*/

import com.dtsx.astra.cli.config.AstraCliConfiguration;
import com.dtsx.astra.cli.core.exception.AstraEnvironmentNotFoundException;
import com.dtsx.astra.cli.core.exception.InvalidTokenException;
import com.dtsx.astra.cli.core.exception.TokenNotFoundException;
import com.dtsx.astra.cli.core.out.AstraCliConsole;
Expand Down Expand Up @@ -205,8 +204,8 @@ public String getToken()
*/
public ApiLocator.AstraEnvironment getAstraEnvironment()
throws TokenNotFoundException {
if (tokenOptions == null || tokenOptions.env() == null) {
throw new AstraEnvironmentNotFoundException();
if (tokenOptions == null) {
return null;
}
return tokenOptions.env();
}
Expand Down

This file was deleted.

Loading

0 comments on commit 1fb154d

Please sign in to comment.