Skip to content

Commit

Permalink
Merge pull request #7 from itsallcode/skip-sonar-for-external-pr
Browse files Browse the repository at this point in the history
Run sonar only when token is available
  • Loading branch information
kaklakariada authored Apr 17, 2021
2 parents 5b37ba4 + c1e562c commit 53bdaea
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn --errors --batch-mode "-Dsonar.host.url=https://sonarcloud.io" -Dsonar.organization=itsallcode -Dsonar.login=$SONAR_TOKEN clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar
run: mvn --errors --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install
env:
MAVEN_OPTS: "-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
- name: Sonar
if: ${{ env.SONAR_TOKEN != null }}
run: mvn --errors --batch-mode "-Dsonar.host.url=https://sonarcloud.io" -Dsonar.organization=itsallcode -Dsonar.login=$SONAR_TOKEN sonar:sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [develop, master]
pull_request:
branches: [develop]
branches: [develop, master]
schedule:
- cron: '0 4 * * 3'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.not;

public class ITestMultilineTextMatcher
class ITestMultilineTextMatcher
{
private static final String LINE_SEPARATOR = System.lineSeparator();

@Test
public void testMatchesAllLines()
void testMatchesAllLines()
{
assertThat("foo" + LINE_SEPARATOR + "bar", MultilineTextMatcher.matchesAllLines("foo", "bar"));
}

@Test
public void testDoesNotMatchAllLines()
void testDoesNotMatchAllLines()
{
assertThat("bar" + LINE_SEPARATOR + "foo", not(MultilineTextMatcher.matchesAllLines("foo", "bar")));
}

@Test
public void testDoesNotMatchDifferentLineCount()
void testDoesNotMatchDifferentLineCount()
{
assertThat("foo", not(MultilineTextMatcher.matchesAllLines("foo", "bar")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@
import org.hamcrest.StringDescription;
import org.junit.jupiter.api.Test;

public class TestMultilineTextMatcher
class TestMultilineTextMatcher
{
private static final String LINE_SEPARATOR = System.lineSeparator();
private static final String STANDARD_TWO_LINE_TEXT = "Line 1\nLine 2";

@Test
public void testMatchesSafely()
void testMatchesSafely()
{
assertThat(new MultilineTextMatcher(STANDARD_TWO_LINE_TEXT).matchesSafely(STANDARD_TWO_LINE_TEXT), equalTo(true));
}

@Test
public void testDoesNotMatchSafely()
void testDoesNotMatchSafely()
{
assertThat(new MultilineTextMatcher(STANDARD_TWO_LINE_TEXT).matchesSafely("blah"), equalTo(false));
}

@Test
public void testDescribeMismatchSafelyLine1Different()
void testDescribeMismatchSafelyLine1Different()
{
final Description description = new StringDescription();
final MultilineTextMatcher matcher = new MultilineTextMatcher(STANDARD_TWO_LINE_TEXT);
Expand All @@ -59,7 +59,7 @@ public void testDescribeMismatchSafelyLine1Different()
}

@Test
public void testDescribeMismatchSafelyDifferentLineCount()
void testDescribeMismatchSafelyDifferentLineCount()
{
final Description description = new StringDescription();
final MultilineTextMatcher matcher = new MultilineTextMatcher(STANDARD_TWO_LINE_TEXT);
Expand All @@ -69,7 +69,7 @@ public void testDescribeMismatchSafelyDifferentLineCount()
}

@Test
public void testDescribeTo()
void testDescribeTo()
{
final Description description = new StringDescription();
final MultilineTextMatcher matcher = new MultilineTextMatcher(STANDARD_TWO_LINE_TEXT);
Expand Down

0 comments on commit 53bdaea

Please sign in to comment.