Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kgough committed Jun 1, 2017
2 parents dd54196 + e19be07 commit 987f882
Show file tree
Hide file tree
Showing 244 changed files with 3,748 additions and 2,635 deletions.
60 changes: 47 additions & 13 deletions Jenkinsfile
Expand Up @@ -53,14 +53,19 @@ node {
$class: 'ParametersDefinitionProperty',
parameterDefinitions: [
[
$class: 'LabelParameterDefinition',
/* Specify the default node in Jenkins environment DEFAULT_NODE
* (eg kvm) or default to build on any node
*/
defaultValue: defaultNodeLabel,
description: 'Jenkins node label to use for build',
name: 'LABEL'
]
$class: 'LabelParameterDefinition',
// Specify the default node in Jenkins env var DEFAULT_NODE
// (eg kvm), or leave blank to build on any node.
defaultValue: defaultNodeLabel,
description: 'Jenkins node label to use for build',
name: 'LABEL'
],
[
$class: 'BooleanParameterDefinition',
defaultValue: false,
description: 'Run all functional tests?',
name: 'allFuncTests'
],
]
],
]
Expand Down Expand Up @@ -92,6 +97,32 @@ String getLabel() {
return result
}

// NB: don't call this getAllFuncTests() or isAllFuncTests(), because it would
// shadow the global parameter allFuncTests.
boolean resolveAllFuncTests() {
def paramVal = null
try {
paramVal = params.allFuncTests
} catch (e1) {
// workaround for https://issues.jenkins-ci.org/browse/JENKINS-38813
echo '[WARNING] unable to access `params`'
echo getStackTrace(e1)
try {
paramVal = allFuncTests
} catch (e2) {
echo '[WARNING] unable to access `allFuncTests`'
echo getStackTrace(e2)
}
}

if (paramVal == null) {
echo "allFuncTests param is null; using default value."
}
def result = paramVal ?: false
echo "allFuncTests: $result"
return result
}

@Field
def mainlineBranches = ['master', 'release', 'legacy']
@Field
Expand All @@ -105,10 +136,13 @@ String getLockName() {
// Each mainline branch pipeline will have its own lock.
return jobName
} else if (env.BRANCH_NAME.startsWith('PR-')) {
// All pull requests (in any repo) will share the same lock/locks.
// It probably makes sense to define 2 or 3 locks with the name
// PullRequest for more concurrency.
return 'GitHubPullRequest'
// Pull requests 1, 101, 201, xx01 will all share the same lock name.
// Barring collisions, this means each PR gets its own lock, with a
// maximum of 100 lock names. This is a workaround for
// https://issues.jenkins-ci.org/browse/JENKINS-38906
String digits = '00' + env.BRANCH_NAME.substring('PR-'.length())
String last2Digits = digits.substring(digits.length() - 2)
return 'zanata-platform-PR-x' + last2Digits
} else {
// All miscellaneous branches (across all repos) will share the same lock.
return 'GitHubMiscBranch'
Expand Down Expand Up @@ -356,7 +390,7 @@ void integrationTests(String appserver) {
def ftOpts = '-Dcargo.debug.jvm.args= '

// run *all* functional tests in these branches only:
if (env.BRANCH_NAME in mainlineBranches) {
if (env.BRANCH_NAME in mainlineBranches || resolveAllFuncTests()) {
ftOpts += '-DallFuncTests '
}

Expand Down
7 changes: 0 additions & 7 deletions api/pom.xml
Expand Up @@ -40,13 +40,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<failOnError>true</failOnError>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Expand Up @@ -31,6 +31,7 @@
*/
@ParametersAreNonnullByDefault
public class FileTypeName implements Comparable<FileTypeName>, Serializable {
private static final long serialVersionUID = 703862390590961467L;
/** Name of the FileType/DocumentType. NS: This may not correspond to a
* FileType/DocumentType recognised by the client (eg if server is newer).
* @see DocumentType
Expand Down
Expand Up @@ -58,7 +58,6 @@ public class TranslationStatistics implements Serializable {
private StatUnit unit;
private BaseTranslationCount translationCount;
private String locale;
private double remainingHours;
private String lastTranslated;

private @Nullable
Expand Down Expand Up @@ -91,20 +90,21 @@ public TranslationStatistics(TransUnitWords wordCount, String locale) {
translationCount = wordCount;
this.unit = StatUnit.WORD;
this.locale = locale;

countRemainingHours();
}

/**
* Calculate remaining hours if StatUnit equals to 'WORD'.
*/
private void countRemainingHours() {
@XmlTransient
@JsonIgnore
public @Nullable Double getRemainingHours() {
if (unit.equals(StatUnit.WORD)) {
double untransHours = translationCount.getUntranslated() / 250.0;
double fuzzyHours = translationCount.getNeedReview() / 500.0;

remainingHours = untransHours + fuzzyHours;
return untransHours + fuzzyHours;
}
return null;
}

/**
Expand Down Expand Up @@ -316,32 +316,16 @@ public double getPercentUntranslated() {
}
}

public void setRemainingHours(double remainingHours) {
this.remainingHours = remainingHours;
}

// TODO Should consolidate with countRemainingHours() as it might return 0
// or null for StatUnit.MESSAGE
@XmlTransient
@JsonIgnore
@Deprecated
public double getRemainingHours() {
return remainingHours;
}

public void add(TranslationStatistics other) {
translationCount.add(other.translationCount);
countRemainingHours();
}

public void increment(ContentState state, long count) {
translationCount.increment(state, (int) count);
countRemainingHours();
}

public void decrement(ContentState state, long count) {
translationCount.decrement(state, (int) count);
countRemainingHours();
}

@Override
Expand All @@ -350,7 +334,6 @@ public String toString() {
sb.append("unit=").append(unit);
sb.append(", translationCount=").append(translationCount);
sb.append(", locale='").append(locale).append('\'');
sb.append(", remainingHours=").append(remainingHours);
sb.append(", lastTranslated='").append(lastTranslated).append('\'');
sb.append(", lastTranslatedDate=").append(lastTranslatedDate);
sb.append(", lastTranslatedBy='").append(lastTranslatedBy).append('\'');
Expand Down
@@ -1,6 +1,8 @@
<FindBugsFilter>
<Match>
<Class name="~.*\.HelpMojo" />
</Match>
<Match>
<Source name="~.*\.kt"/>
</Match>
</FindBugsFilter>
7 changes: 0 additions & 7 deletions client/pom.xml
Expand Up @@ -44,13 +44,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<failOnError>true</failOnError>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Expand Up @@ -40,6 +40,8 @@ public class MockAsynchronousProcessResource implements
private static final long serialVersionUID = 8841332691985560066L;

@Override
@SuppressWarnings("deprecation")
// TODO: remove this test when parent method is removed
public ProcessStatus startSourceDocCreation(String idNoSlash,
String projectSlug, String iterationSlug, Resource resource,
Set<String> extensions, @DefaultValue("true") boolean copytrans) {
Expand Down
Expand Up @@ -65,7 +65,7 @@ private static void startServerIfRequired() {
try {
server.start();
} catch (Exception e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
}
}

Expand Down
37 changes: 18 additions & 19 deletions client/zanata-cli/pom.xml
Expand Up @@ -52,24 +52,6 @@
</configuration>
</plugin>

<!-- package in zip and tar.gz -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptor>src/main/assembly/bin.xml</descriptor>
</configuration>
</plugin>

</plugins>
</build>

Expand Down Expand Up @@ -187,13 +169,30 @@
<programs>
<program>
<mainClass>org.zanata.client.ZanataClient</mainClass>
<name>zanata-cli</name>
<id>zanata-cli</id>
</program>
</programs>
<repositoryName>lib</repositoryName>
<repositoryLayout>flat</repositoryLayout>
</configuration>
</plugin>
<!-- package in zip and tar.gz -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptor>src/main/assembly/bin.xml</descriptor>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Expand Down
Expand Up @@ -47,7 +47,7 @@ public void evaluate() {
parameters.get(parameterIndex));
base.evaluate();
} catch (Throwable throwable) {
throw Throwables.propagate(throwable);
throw new RuntimeException(throwable);
}
}
}
Expand Down
Expand Up @@ -120,7 +120,7 @@ private ProjectType getProjectType() {
return ProjectType.getValueOf(
opts.getProjectType());
} catch (Exception e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
}
}

Expand Down
Expand Up @@ -151,7 +151,7 @@ private static Properties loadFileToProperties(File updateMarker) {
props.load(reader);
}
catch (IOException e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
}
return props;
}
Expand Down
Expand Up @@ -71,7 +71,9 @@ public class InitCommand extends ConfigurableCommand<InitOptions> {

public InitCommand(InitOptions opts) {
// we don't have all mandatory information yet (server URL etc)
super(opts, new RestClientFactory() {});
super(opts, new RestClientFactory() {
private static final long serialVersionUID = 1L;
});
console = new ConsoleInteractorImpl(opts);
projectConfigHandler =
new ProjectConfigHandler(console, getOpts());
Expand All @@ -80,7 +82,9 @@ public InitCommand(InitOptions opts) {

@VisibleForTesting
protected InitCommand(InitOptions opts, ConsoleInteractor console) {
this(opts, console, new RestClientFactory() {});
this(opts, console, new RestClientFactory() {
private static final long serialVersionUID = 1L;
});
}

@VisibleForTesting
Expand Down
Expand Up @@ -298,7 +298,7 @@ public Set<String> findSrcDocNames() {
opts.getCaseSensitive(),
opts.getExcludeLocaleFilenames());
} catch (IOException e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
}
}
}
Expand Down
Expand Up @@ -94,7 +94,7 @@ protected Set<String> getSrcDocNames() {
getOpts().getCaseSensitive(),
getOpts().getExcludeLocaleFilenames());
} catch (IOException e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
}
}

Expand Down
Expand Up @@ -154,7 +154,7 @@ private static URI setUrl(ConfigurableProjectOptions opts) {
opts.setUrl(uri.toURL());
return uri;
} catch (Exception e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -272,6 +272,7 @@ public PullCommand createPullCommand(List<ResourceMeta> remoteDocList,
eq(getPullOpts().getCreateSkeletons()), anyString()))
.thenReturn(transResourceResponse);
when(transResourceResponse.getStatus()).thenReturn(200);

when(transResourceResponse.getStringHeaders()).thenReturn(
new MultivaluedMapImpl());
when(transResourceResponse.readEntity(TranslationsResource.class))
Expand Down Expand Up @@ -365,7 +366,7 @@ public RawPullCommand createRawPullCommand(
eq(pullOpts.getProjectVersion()), anyString(), anyString(),
anyString())).thenReturn(downloadTransResponse);
when(downloadTransResponse.getStatus()).thenReturn(200);
when(downloadTransResponse.getHeaders()).thenReturn(new MultivaluedMapImpl());
when(downloadTransResponse.getHeaders()).thenReturn(new MultivaluedMapImpl<>());
when(downloadTransResponse.getStatusInfo()).thenReturn(
Response.Status.OK);
when(downloadTransResponse.readEntity(InputStream.class))
Expand Down
Expand Up @@ -162,7 +162,7 @@ public URL getURL() {
try {
return new URI(url).toURL();
} catch (MalformedURLException | URISyntaxException e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
}
}

Expand Down

0 comments on commit 987f882

Please sign in to comment.