Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/pr-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,12 @@ jobs:
spec: ${{ needs.parse-tags.outputs.spec}}
matrix: ${{ needs.parse-tags.outputs.matrix}}
is-pg-build: ${{ github.event.pull_request.base.ref == 'pg' }}

perform-it:
needs: [ parse-tags ]
if: success() && needs.parse-tags.outputs.its == 'true'
uses: ./.github/workflows/server-build.yml
secrets: inherit
with:
its: 'true'
is-pg-build: ${{ github.event.pull_request.base.ref == 'pg' }}
Comment thread
nidhi-nair marked this conversation as resolved.
Outdated
31 changes: 21 additions & 10 deletions .github/workflows/scripts/test-tag-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,29 @@ function parseTags(body) {
const allTags = require(process.env.GITHUB_WORKSPACE + "/app/client/cypress/tags.js").Tag;

// "/ok-to-test" matcher. Takes precedence over the "/test" matcher.
const strictMatch = body.match(/^\/ok-to-test tags="(.+?)"/m)?.[1];
if (strictMatch) {
if (strictMatch === "@tag.All") {
return { tags: strictMatch };
}
const parts = strictMatch.split(/\s*,\s*/);
for (const part of parts) {
if (!allTags.includes(part)) {
throw new Error("Unknown tag: " + part);
const okToTestPattern = body.match(/^(\/ok-to-test) tags="(.+?)"( it=true)?/m);

if (okToTestPattern?.[1]) {
var response = {};
const tagsMatch = okToTestPattern?.[2];
if (tagsMatch) {
if (tagsMatch === "@tag.All") {
response = { tags: tagsMatch };
} else {
const parts = tagsMatch.split(/\s*,\s*/);
for (const part of parts) {
if (!allTags.includes(part)) {
throw new Error("Unknown tag: " + part);
}
}
response = { tags: tagsMatch };
}
}
return { tags: strictMatch };
const itsMatch = okToTestPattern?.[2];
if (itsMatch) {
response = { ...response, its: 'true' };
}
Comment thread
nidhi-nair marked this conversation as resolved.
return response;
}

// "/test" code-fence matcher.
Expand Down
29 changes: 24 additions & 5 deletions .github/workflows/server-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@ on:
workflow_call:
inputs:
pr:
description: "This is the PR number in case the workflow is being called in a pull request"
description: "PR number for the workflow"
required: false
type: number
skip-tests:
description: "This is a boolean value in case the workflow is being called in build deploy-preview"
description: "Skip tests flag"
required: false
type: string
default: "false"
its:
description: "Whether we want to run integration tests"
required: false
type: string
default: "false"
branch:
description: "This is the branch to be used for the build."
description: "Branch for the build"
required: false
type: string
is-pg-build:
description: "This is a boolean value in case the workflow is being called for a PG build"
description: "Flag for PG build"
required: false
type: string
default: "false"
Expand All @@ -34,6 +39,11 @@ on:
required: false
type: string
default: "false"
its:
description: "Whether we want to run integration tests"
required: false
type: string
default: "false"
branch:
description: "Branch for the build"
required: false
Expand Down Expand Up @@ -210,13 +220,22 @@ jobs:
fi

args=()

# Check if this run is requesting for unit tests or integration tests
# As of today, we don't expect both to get triggered in the same workflow
if [[ "${{ inputs.its }}" == "true" ]]; then
args+=("-DskipUTs=true")
else
args+=("-DskipITs=true")
fi

if [[ "${{ steps.run_result.outputs.run_result }}" == "failedtest" ]]; then
failed_tests="${{ steps.failed_tests.outputs.tests }}"
args+=("-DfailIfNoTests=false" "-Dsurefire.failIfNoSpecifiedTests=false" "-Dtest=${failed_tests}")
fi

# Run tests and capture logs
mvn test "${args[@]}" | tee mvn_test.log
mvn verify "${args[@]}" | tee mvn_test.log

# Check for "BUILD FAILURE" in the mvn_test.log
if grep -q "BUILD FAILURE" mvn_test.log; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public GitContext(
ExtensionContext.Store contextStore = extensionContext.getStore(ExtensionContext.Namespace.create(ArtifactBuilderExtension.class));
contextStore.put(ArtifactExchangeJson.class, artifactExchangeJsonType);
contextStore.put("filePath", fileName);
contextStore.put("artifactType", artifactType);
this.fileName = fileName;
this.artifactExchangeJsonType = artifactExchangeJsonType;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.appsmith.server.git;

import com.appsmith.git.configurations.GitServiceConfig;
import com.appsmith.server.applications.base.ApplicationService;
import com.appsmith.server.artifacts.base.ArtifactService;
import com.appsmith.server.constants.ArtifactType;
import com.appsmith.server.constants.FieldName;
import com.appsmith.server.domains.GitAuth;
import com.appsmith.server.dtos.ArtifactExchangeJson;
import com.appsmith.server.git.common.CommonGitService;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
Expand All @@ -19,8 +18,6 @@
import org.springframework.web.reactive.function.client.WebClient;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import reactor.core.publisher.Mono;

import java.nio.file.Path;
Expand All @@ -40,7 +37,7 @@
public class GitServerInitializerExtension implements BeforeAllCallback, BeforeEachCallback, AfterEachCallback, AfterAllCallback {

@Autowired
ApplicationService applicationService;
ArtifactService artifactService;

@Autowired
GitServiceConfig gitServiceConfig;
Expand All @@ -59,16 +56,15 @@ public void beforeAll(ExtensionContext extensionContext) {
@Override
public void beforeEach(ExtensionContext extensionContext) {
ExtensionContext.Store parentContextStore = extensionContext.getParent().get().getStore(ExtensionContext.Namespace.create(ArtifactBuilderExtension.class));
Class<? extends ArtifactExchangeJson> aClass = parentContextStore.get(ArtifactExchangeJson.class, Class.class);
String filePath = parentContextStore.get("filePath", String.class);
ArtifactType artifactType = parentContextStore.get("artifactType", ArtifactType.class);
ExtensionContext.Store contextStore = extensionContext.getStore(ExtensionContext.Namespace.create(ArtifactBuilderExtension.class));

String artifactId = contextStore.get(FieldName.ARTIFACT_ID, String.class);
String repoName = "test" + artifactId;

// TODO : Move this to artifact service to enable packages
// Generate RSA public key for the given artifact
Mono<GitAuth> gitAuthMono = applicationService.createOrUpdateSshKeyPair(artifactId, "RSA");
Mono<GitAuth> gitAuthMono = artifactService.createOrUpdateSshKeyPair(artifactType, artifactId, "RSA");

String tedGitApiPath = "http://" + gitContainer.getHost() + ":" + gitContainer.getMappedPort(4200) + "/api/v1/git/";

Expand Down
62 changes: 62 additions & 0 deletions app/server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<reactor-test.version>3.5.1</reactor-test.version>
<!-- By default skip the dockerization step. Only activate if necessary -->
<skipDockerBuild>true</skipDockerBuild>
<skipITs>${skipTests}</skipITs>
<skipTests>false</skipTests>
<skipUTs>${skipTests}</skipUTs>
<!-- We're forcing this version temporarily to fix CVE-2022-1471-->
<snakeyaml.version>2.0</snakeyaml.version>
<source.disabled>true</source.disabled>
Expand Down Expand Up @@ -74,6 +77,30 @@
<artifactId>maven-dependency-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>add-test-source</id>
<goals>
<goal>add-test-source</goal>
</goals>
<phase>generate-test-sources</phase>
<configuration>
<sources>
<source>src/test/java</source>
<!-- Default test directory -->
<source>src/test/it</source>
<!-- Additional test directory -->
<source>src/test/utils</source>
<!-- Another additional directory -->
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand All @@ -84,6 +111,41 @@
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.time=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED</argLine>
<testSourceDirectory>src/test/java</testSourceDirectory>
<skipTests>${skipUTs}</skipTests>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<exclusions>
<exclusion>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<printSummary>true</printSummary>
<!-- Allow JUnit to access the test classes -->
<argLine>-ea
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.time=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED</argLine>
<systemPropertyVariables>
<pf4j.pluginsDir>../dist/plugins</pf4j.pluginsDir>
<!-- Specify plugin directory -->
</systemPropertyVariables>
<testSourceDirectory>src/test/it</testSourceDirectory>
<skipITs>${skipITs}</skipITs>
<!-- Property for skipping integration tests -->
</configuration>
<dependencies>
<dependency>
Expand Down