Skip to content

Commit ed6226c

Browse files
authored
Prep release (#12)
- Import Makefile and security scanning dependency/CI step from easypost-java - Make install -> make install-checkstyle -> download latest Java style guide from easypost-java
1 parent 66c96da commit ed6226c

File tree

7 files changed

+123
-19
lines changed

7 files changed

+123
-19
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,33 @@ name: CI
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [ main ]
66
pull_request: ~
77

88
jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
javaversion: ["8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"]
13+
javaversion: [ "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18" ]
1414
steps:
1515
- uses: actions/checkout@v3
16+
- name: Load Maven dependencies cache
17+
uses: actions/cache@v3
18+
with:
19+
path: ~/.m2/repository
20+
key: ${{ runner.os }}-maven-build${{ matrix.javaversion }}-${{ hashFiles('**/pom.xml') }}
21+
restore-keys: |
22+
${{ runner.os }}-maven-
23+
- name: Install dependencies
24+
run: make install
1625
- name: Set up Java ${{ matrix.javaversion }}
1726
uses: actions/setup-java@v3
1827
with:
1928
distribution: "zulu"
2029
java-version: ${{ matrix.javaversion }}
2130
- name: Build and test with Maven
22-
run: mvn --batch-mode install -Dgpg.skip=true -Dcheckstyle.skip=true
31+
run: make test
2332
lint:
2433
runs-on: ubuntu-latest
2534
steps:
@@ -31,3 +40,21 @@ jobs:
3140
fail_on_error: true
3241
checkstyle_config: easypost_java_style.xml
3342
tool_name: "style_enforcer"
43+
security:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v3
47+
- name: Load Maven dependencies and CVE database cache
48+
uses: actions/cache@v3
49+
with:
50+
path: ~/.m2/repository # The CVE database is included in the Maven repository folder
51+
key: ${{ runner.os }}-maven-security-${{ hashFiles('**/pom.xml') }}
52+
restore-keys: |
53+
${{ runner.os }}-maven-
54+
- name: Run security analysis
55+
run: make scan
56+
- name: Upload Test results
57+
uses: actions/upload-artifact@master
58+
with:
59+
name: DependencyCheck report
60+
path: ${{github.workspace}}/target/dependency-check-report.html

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# CHANGELOG
22

3-
## Next Release
3+
## v0.4.0 (2022-10-04)
4+
45
- New feature: Set expiration time for interactions (how long since it was recorded should an interaction be considered valid)
56
- Can determine what to do if a matching interaction is considered invalid:
67
- Warn the user, but proceed with the interaction

Makefile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
## help - Display help about make targets for this Makefile
2+
help:
3+
@cat Makefile | grep '^## ' --color=never | cut -c4- | sed -e "`printf 's/ - /\t- /;'`" | column -s "`printf '\t'`" -t
4+
5+
## build - Builds the project for development
6+
build:
7+
mvn clean install -DskipTests=true -Dgpg.skip=true -Dcheckstyle.skip=true -Dcheckstyle.skip=true -Ddependency-check.skip=true -Djavadoc.skip=true
8+
9+
## clean - Cleans the project
10+
clean:
11+
mvn clean
12+
13+
## coverage - Test the project and generate a coverage report
14+
coverage:
15+
mvn --batch-mode install -Dgpg.skip=true -Dcheckstyle.skip=true -Dcheckstyle.skip=true -Ddependency-check.skip=true -Djavadoc.skip=true jacoco:report
16+
17+
## install-checkstyle - Install CheckStyle
18+
install-checkstyle:
19+
curl -LJs https://github.com/checkstyle/checkstyle/releases/download/checkstyle-10.3.1/checkstyle-10.3.1-all.jar -o checkstyle.jar
20+
curl -LJs https://raw.githubusercontent.com/EasyPost/easypost-java/master/easypost_java_style.xml -o easypost_java_style.xml
21+
22+
## install - Install requirements
23+
install: | install-checkstyle
24+
git submodule init
25+
git submodule update
26+
27+
## lint - Check if project follows CheckStyle rules (must run install-checkstyle first)
28+
lint:
29+
java -jar checkstyle.jar src -c easypost_java_style.xml -d
30+
31+
## publish - Publish a release of the project
32+
# @parameters:
33+
# pass= - The GPG password to sign the release
34+
publish:
35+
mvn clean deploy -Dgpg.passphrase=${pass}
36+
37+
## publish-dry - Build the project as a dry run to publishing
38+
# @parameters:
39+
# pass= - The GPG password to sign the release
40+
publish-dry:
41+
mvn clean install -Dgpg.passphrase=${pass}
42+
43+
## release - Cuts a release for the project on GitHub (requires GitHub CLI)
44+
# tag = The associated tag title of the release
45+
release:
46+
gh release create ${tag} target/*.jar target/*.asc target/*.pom
47+
48+
## scan - Scan the project for serious security issues
49+
scan:
50+
mvn verify -DskipTests=true -Dgpg.skip=true -Dcheckstyle.skip=true -Djavadoc.skip=true -Ddependency-check.failBuildOnCVSS=0 -Ddependency-check.junitFailOnCVSS=0
51+
52+
## test - Test the project
53+
test:
54+
mvn --batch-mode install -Dgpg.skip=true -Dcheckstyle.skip=true -Dcheckstyle.skip=true -Ddependency-check.skip=true -Djavadoc.skip=true
55+
56+
.PHONY: help build clean install-checkstyle install lint publish publish-dry release scan test

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ public class Example {
180180
Cassette cassette = new Cassette("path/to/cassettes", "my_cassette");
181181

182182
AdvancedSettings advancedSettings = new AdvancedSettings();
183-
advancedSettings.timeFrame = new TimeFrame(30, 0, 0,
184-
0); // Any matching request is considered expired if it was recorded more than 30 days ago
183+
advancedSettings.timeFrame =
184+
new TimeFrame(30, 0, 0, 0); // Any matching request is considered expired if it was recorded more than 30 days ago
185185
// or
186186
advancedSettings.timeFrame =
187187
TimeFrame.months12(); // Any matching request is considered expired if it was recorded more than a year ago

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.0
1+
0.4.0

easypost_java_style.xml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161

6262
<!-- Checks that a package-info.java file exists for each package -->
6363
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
64+
<module name="JavadocPackage"/>
6465

6566
<!-- Checks whether files end with a new line -->
6667
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
@@ -88,7 +89,7 @@
8889
<module name="RegexpSingleline">
8990
<property name="format" value="\s+$"/>
9091
<property name="minimum" value="0"/>
91-
<property name="maximum" value="0"/>
92+
<property name="maximum" value="1"/>
9293
<property name="message" value="Line has trailing spaces."/>
9394
</module>
9495

@@ -137,11 +138,12 @@
137138
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
138139
<module name="RedundantImport"/>
139140
<module name="UnusedImports">
140-
<property name="processJavadoc" value="true"/>
141+
<property name="processJavadoc" value="false"/>
141142
</module>
142143

143144
<!-- Checks for name length violations -->
144145
<!-- See https://checkstyle.org/config_sizes.html -->
146+
<module name="MethodLength"/>
145147
<module name="ParameterNumber"/>
146148

147149
<!-- Checks for whitespace -->
@@ -158,7 +160,11 @@
158160
<module name="ParenPad"/>
159161
<module name="TypecastParenPad"/>
160162
<module name="WhitespaceAfter"/>
161-
<module name="WhitespaceAround"/>
163+
<module name="SingleSpaceSeparator"/>
164+
<module name="EmptyLineSeparator">
165+
<property name="allowNoEmptyLineBetweenFields" value="true"/>
166+
<property name="allowMultipleEmptyLines" value="false"/>
167+
</module>
162168

163169
<!-- Modifier Checks -->
164170
<!-- See https://checkstyle.org/config_modifier.html -->
@@ -180,6 +186,7 @@
180186
<!-- <module name="HiddenField"/> -->
181187
<module name="IllegalInstantiation"/>
182188
<module name="InnerAssignment"/>
189+
<module name="MagicNumber"/>
183190
<module name="MissingSwitchDefault"/>
184191
<module name="MultipleVariableDeclarations"/>
185192
<module name="SimplifyBooleanExpression"/>
@@ -189,7 +196,9 @@
189196
<!-- See https://checkstyle.org/config_design.html -->
190197
<module name="DesignForExtension"/>
191198
<module name="FinalClass"/>
199+
<module name="HideUtilityClassConstructor"/>
192200
<module name="InterfaceIsType"/>
201+
<module name="VisibilityModifier"/>
193202

194203
<!-- Miscellaneous other checks -->
195204
<!-- See https://checkstyle.org/config_misc.html -->
@@ -207,12 +216,6 @@
207216
<!-- i.e. @SuppressWarnings("checkstyle:methodname") -->
208217
<module name="SuppressWarningsHolder"/>
209218

210-
<module name="SuppressionCommentFilter">
211-
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
212-
<property name="onCommentFormat" value="CHECKSTYLE.ON\: ([\w\|]+)"/>
213-
<property name="checkFormat" value="$1"/>
214-
</module>
215-
216219
</module>
217220

218221
</module>

pom.xml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
45
<modelVersion>4.0.0</modelVersion>
56

67
<groupId>com.easypost</groupId>
78
<artifactId>easyvcr</artifactId>
89

9-
<version>0.3.0</version>
10+
<version>0.4.0</version>
1011
<packaging>jar</packaging>
1112

1213
<name>com.easypost:easyvcr</name>
@@ -108,7 +109,7 @@
108109
<version>3.0.0-M3</version>
109110
<configuration>
110111
<properties>
111-
<configurationParameters> junit.jupiter.execution.order.random.seed=99
112+
<configurationParameters>junit.jupiter.execution.order.random.seed=99
112113
</configurationParameters>
113114
</properties>
114115
</configuration>
@@ -259,6 +260,22 @@
259260
</execution>
260261
</executions>
261262
</plugin>
263+
<plugin>
264+
<groupId>org.owasp</groupId>
265+
<artifactId>dependency-check-maven</artifactId>
266+
<version>7.2.1</version>
267+
<configuration>
268+
<failBuildOnCVSS>7</failBuildOnCVSS>
269+
<junitFailOnCVSS>7</junitFailOnCVSS>
270+
</configuration>
271+
<executions>
272+
<execution>
273+
<goals>
274+
<goal>check</goal>
275+
</goals>
276+
</execution>
277+
</executions>
278+
</plugin>
262279
</plugins>
263280
</build>
264281

0 commit comments

Comments
 (0)