Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling github checks #57

Merged
Show file tree
Hide file tree
Changes from all 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
95 changes: 74 additions & 21 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,90 @@
name: build

on: [push, pull_request, workflow_dispatch]
# workflow_dispatch should make manually triggered ci/cd possible
# workflow file (like this) with `workflow_dispatch` after on should exist on the **master** or default branch,
# or there will be no ui for a manual trigger. https://github.community/t/workflow-dispatch-event-not-working/128856/2
# workflow_dispatch should make manually triggered ci/cd possible
# workflow file (like this) with `workflow_dispatch` after on should exist on the **master** or default branch,
# or there will be no ui for a manual trigger. https://github.community/t/workflow-dispatch-event-not-working/128856/2

env:
REPORTS_LOCATIONS: |
pravega-sensor-collector/build/reports


jobs:
build:
name: Build
runs-on: ubuntu-20.04
steps:
- name: Build Information
run: echo Building a '${{ github.event_name }}' for target '${{ github.ref }}'.
- name: Checkout
uses: actions/checkout@v2

- name: Set up JDK
uses: actions/setup-java@v2
- uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '11' # major or semver Java version will be acceptable, see https://github.com/marketplace/actions/setup-java-jdk#basic

- name: Build
distribution: 'temurin'
java-version: '11'
- name: Test build-installer.sh
run: ./scripts/build-installer.sh
- name: Clean
if: ${{ startsWith(github.ref, 'refs/heads/') }}
run: ./gradlew clean ${{env.GRADLE_OPTS}}
- name: Compile & Checkstyle
run: ./gradlew jar compileTest checkstyleMain checkstyleTest --parallel ${{env.GRADLE_OPTS}}
- name: Spotbugs
run: ./gradlew spotbugsMain spotbugsTest
- name: Tar Reports
run: tar --use-compress-program zstd -cf reports-${{github.job}}.tzst `echo ${{env.REPORTS_LOCATIONS}}`
- name: Upload Reports
uses: actions/upload-artifact@v2
with:
name: ${{github.job}}-reports
retention-days: 4
path: reports-${{github.job}}.tzst
# Uncomment these two lines if you need ssh access to debug a build.
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1


unit_test:
name: PSC Unit Tests
needs: build
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
- name: Unit tests
run: ./gradlew pravega-sensor-collector:test --parallel ${{env.GRADLE_OPTS}}
- name: Tar Reports
run: tar --use-compress-program zstd -cf reports-${{github.job}}.tzst `echo ${{env.REPORTS_LOCATIONS}}`
- name: Upload Reports
if: always()
uses: actions/upload-artifact@v2
with:
name: ${{github.job}}-reports
retention-days: 4
path: reports-${{github.job}}.tzst

- name: Set env
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Release
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# DO NOT RENAME THIS JOB. Mergers to master branch are gated on this completing successfully.
build_and_test_complete:
name: CI Complete
needs: [build, unit_test]
runs-on: ubuntu-20.04
steps:
- name: Check Build Status
run: echo Build, static analysis, unit and integration tests successful.
- name: Checkout
uses: actions/checkout@v2
with:
files: ./pravega-sensor-collector/build/distributions/pravega-sensor-collector-*.tgz
draft: true
name: pravega-sensor-collector ${{ env.RELEASE_VERSION }}
fetch-depth: 2
- name: Download code coverage reports
uses: actions/download-artifact@v2
- name: Untar reports
run: ( ls */reports-*.tzst | xargs -n1 tar --use-compress-program zstd --keep-newer-files -xf )
- name: Upload to Codecov
uses: codecov/codecov-action@v1

4 changes: 2 additions & 2 deletions config/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<!-- header -->
<module name="RegexpHeader">
<property name="header" value="/\*\*\n * Copyright Pravega Authors\."/>
<property name="header" value="/\*\*\n * Copyright \(c\) Dell Inc., or its subsidiaries. All Rights Reserved."/>
</module>
<module name="SuppressionFilter">
<property name="file" value="${suppressionsFile}"/>
Expand Down Expand Up @@ -54,7 +54,7 @@
<module name="LeftCurly"/>
<module name="RightCurly"/>
<module name="ConstantName">
<property name="format" value="(^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$)|(^log$)"/>
<property name="format" value="(^[A-Za-z][A-Za-z0-9]*(_[A-Z0-9]+)*$)|(^log$)"/>
</module>
<module name="LocalVariableName"/>
<module name="LocalFinalVariableName"/>
Expand Down
43 changes: 43 additions & 0 deletions config/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,52 @@
<Match> <!-- does not work from JDK11 onwards https://github.com/spotbugs/spotbugs/issues/756 -->
<Bug pattern="RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" />
</Match>
<Match> <!-- does not work from JDK11 onwards https://github.com/spotbugs/spotbugs/issues/756 -->
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE" />
</Match>

<Match> <!-- Returning a java.lang.Boolean is common with Streams/Lambdas -->
<Bug pattern="NP_BOOLEAN_RETURN_NULL" />
</Match>
<Match>
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" />
</Match>

<Match>
<Class name="io.pravega.sensor.collector.util.TransactionCoordinator" />
<Bug pattern="CT_CONSTRUCTOR_THROW" />
</Match>

<Match>
<Class name="io.pravega.sensor.collector.file.csvfile.CsvFileSequenceProcessor" />
<Bug pattern="UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR" />
</Match>

<Match>
<Class name="io.pravega.sensor.collector.file.parquet.ParquetFileProcessor" />
<Bug pattern="UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR" />
</Match>

<Match>
<Class name="io.pravega.sensor.collector.file.rawfile.RawFileProcessor" />
<Bug pattern="UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR" />
</Match>

<Match>
<Class name="io.pravega.sensor.collector.util.TransactionCoordinatorTests" />
<Bug pattern="ODR_OPEN_DATABASE_RESOURCE" />
</Match>

<Match>
<Class name="io.pravega.sensor.collector.accelerometer.AccelerometerSamples" />
<Bug pattern="PA_PUBLIC_PRIMITIVE_ATTRIBUTE" />
</Match>

<Match>
<Class name="io.pravega.sensor.collector.network.NetworkSamples" />
<Bug pattern="PA_PUBLIC_PRIMITIVE_ATTRIBUTE" />
</Match>

<Match> <!-- This is intended in these and only these classes -->
<Or>
<Bug pattern="EI_EXPOSE_REP" />
Expand Down
8 changes: 4 additions & 4 deletions config/spotbugs-include.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

<!-- A use of untrusted input in a way that could create a remotely exploitable
security vulnerability. -->
<Match>
<!-- <Match>
<Bug category="SECURITY" />
</Match>
</Match> -->

<!-- Violations of recommended and essential coding practice. Examples include
hash code and equals problems, cloneable idiom, dropped exceptions, Serializable
Expand Down Expand Up @@ -39,9 +39,9 @@
</Match>

<!-- code flaws having to do with threads, locks, and volatiles -->
<Match>
<!-- <Match>
<Bug category="MT_CORRECTNESS" />
</Match>
</Match> -->

<!-- Experimental and not fully vetted bug patterns -->
<Match>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World.
2 changes: 1 addition & 1 deletion pravega-sensor-collector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {

spotbugs {
toolVersion = spotbugsVersion
ignoreFailures = true
ignoreFailures = false
showProgress = true
effort = 'max'
reportLevel = 'default'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.List;
import java.util.stream.Collectors;

public class AccelerometerDriver extends SimpleDeviceDriver<AccelerometerRawData, AccelerometerSamples> {
public final class AccelerometerDriver extends SimpleDeviceDriver<AccelerometerRawData, AccelerometerSamples> {
private static final Logger LOGGER = LoggerFactory.getLogger(AccelerometerDriver.class);

private static final String CONFIG_DEVICE_FILE_KEY = "CONFIG_DEVICE_FILE";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void processFile(FileNameWithOffset fileNameWithBeginOffset, long firstSequenceN

try (final InputStream inputStream = new FileInputStream(fileNameWithBeginOffset.fileName)) {
final CountingInputStream countingInputStream = new CountingInputStream(inputStream);
countingInputStream.skip(fileNameWithBeginOffset.offset);
log.info("Offset skipped {}", countingInputStream.skip(fileNameWithBeginOffset.offset));
final Pair<Long, Long> result = eventGenerator.generateEventsFromInputStream(countingInputStream, firstSequenceNumber,
e -> {
log.trace("processFile: event={}", e);
Expand Down Expand Up @@ -287,12 +287,4 @@ void deleteCompletedFiles() throws Exception {
});
}

/**
* Inject a failure before commit for testing.
*/
protected void injectCommitFailure() {
if (Math.random() < 0.3) {
throw new RuntimeException("injectCommitFailure: Commit failure test exception");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class NetworkDriver extends SimpleDeviceDriver<NetworkRawData, NetworkSamples> {
public final class NetworkDriver extends SimpleDeviceDriver<NetworkRawData, NetworkSamples> {
private static final Logger LOGGER = LoggerFactory.getLogger(NetworkDriver.class);

private static final String NETWORK_INTERFACE_KEY = "NETWORK_INTERFACE";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint;
import static org.eclipse.milo.opcua.stack.core.util.ConversionUtil.toList;

public class OpcUaClientDriver extends SimpleMemorylessDriver<OpcUaRawData> {
public final class OpcUaClientDriver extends SimpleMemorylessDriver<OpcUaRawData> {

private static final Logger LOGGER = LoggerFactory.getLogger(OpcUaClientDriver.class);
private static final Gson JSON_PARSER = new Gson();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* A persistent queue that uses a SQLite database on disk.
*/
public class PersistentQueue implements AutoCloseable {
public final class PersistentQueue implements AutoCloseable {
private static final Logger LOGGER = LoggerFactory.getLogger(PersistentQueue.class);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,4 @@ protected void run() throws Exception {
}
}

/**
* Inject a failure before commit for testing.
*/
protected void injectCommitFailure() {
if (Math.random() < 0.1) {
throw new RuntimeException("injectCommitFailure: Commit failure test exception");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Stores and updates last-read timestamp in the persistent state (SQLite database) *
*/
public class ReadingState {
public final class ReadingState {
private static final Logger LOGGER = LoggerFactory.getLogger(ReadingState.class);
public final Connection connection;
public ReadingState(Connection connection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public class FileUtils {
public static final String COMPLETED_FILES = "Completed_Files";

/**
* Gets directory listings.
*
* @param fileSpec
* @param fileExtension
* @param movedFilesDirectory
* @param minTimeInMillisToUpdateFile
* @return list of file name and file size in bytes
* Handle the below cases
* 1. If given file path does not exist then log the message and continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.sql.Statement;
import java.util.UUID;

public class PersistentId {
public final class PersistentId {
private static final Logger LOGGER = LoggerFactory.getLogger(PersistentId.class);

private final UUID persistentId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void test3by2() throws IOException {
}

@Test
public void Test3by3() throws IOException {
public void test3by3() throws IOException {
final EventGenerator eventGenerator = CsvFileEventGenerator.create("routingKey1", 3);
final String csvStr =
"\"Time\",\"X\",\"Y\",\"Z\",\"IN_PROGRESS\"\n"
Expand All @@ -64,7 +64,7 @@ public void Test3by3() throws IOException {
}

@Test
public void Test1by3() throws IOException {
public void test1by3() throws IOException {
final EventGenerator eventGenerator = CsvFileEventGenerator.create("routingKey1", 3);
final String csvStr =
"\"Time\",\"X\",\"Y\",\"Z\",\"IN_PROGRESS\"\n"
Expand All @@ -78,7 +78,7 @@ public void Test1by3() throws IOException {
}

@Test
public void Test0by3() throws IOException {
public void test0by3() throws IOException {
final EventGenerator eventGenerator = CsvFileEventGenerator.create("routingKey1", 3);
final String csvStr =
"\"Time\",\"X\",\"Y\",\"Z\",\"IN_PROGRESS\"\n";
Expand All @@ -91,7 +91,7 @@ public void Test0by3() throws IOException {
}

@Test
public void TestEmptyFile() throws IOException {
public void testEmptyFile() throws IOException {
final EventGenerator eventGenerator = CsvFileEventGenerator.create("routingKey1", 3);
final String csvStr = "";
final CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(csvStr.getBytes(StandardCharsets.UTF_8)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class ParquetEventGeneratorTests {
private static final Logger LOG = LoggerFactory.getLogger(ParquetEventGeneratorTests.class);

@Test
public void TestFile() throws IOException {
public void testFile() throws IOException {
final EventGenerator eventGenerator = ParquetEventGenerator.create("routingKey1",100);
final List<FileNameWithOffset> files = FileUtils.getDirectoryListing("../parquet-file-sample-data","parquet", Paths.get("."), 5000);
File parquetData= new File(files.get(0).fileName);
Expand Down
Loading