-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5b62d77
Showing
16 changed files
with
386 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "maven" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
time: "02:00" | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
time: "02:00" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# This workflow will build a Java project with Maven | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | ||
|
||
name: build | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
java: ['17'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'zulu' | ||
java-version: ${{ matrix.java }} | ||
- name: Build with Maven | ||
run: mvn -B verify --file pom.xml | ||
auto-merge: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v4 | ||
- name: auto-merge | ||
if: | | ||
github.actor == 'dependabot[bot]' && | ||
github.event_name == 'pull_request' | ||
run: | | ||
./merge_dependabot.sh | ||
env: | ||
PR_URL: ${{github.event.pull_request.html_url}} | ||
# this secret needs to be in the settings.secrets.dependabot | ||
GITHUB_TOKEN: ${{secrets.GH_ACTION_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: on-push-do-doco | ||
on: | ||
push: | ||
jobs: | ||
release: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run MarkdownSnippets | ||
run: | | ||
dotnet tool install --global MarkdownSnippets.Tool | ||
mdsnippets ${GITHUB_WORKSPACE} | ||
shell: bash | ||
- name: Push changes | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git commit -m "Doco changes" -a || echo "nothing to commit" | ||
remote="https://${GITHUB_ACTOR}:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git" | ||
branch="${GITHUB_REF:11}" | ||
git push "${remote}" ${branch} || echo "nothing to push" | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*.class | ||
.settings | ||
.preferences | ||
.classpath | ||
.project | ||
target | ||
.idea | ||
*.iml | ||
|
||
*.received.* | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[Launch Me](https://us-east-2.console.aws.amazon.com/cloudformation/home?region=us-east-2#/stacks/create/review?templateURL=https://raw.githubusercontent.com/approvals/ApprovalTests.java.StarterProject/master/launch.ec2.yml&stackName=approvaltests-java-starterproject) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# ApprovalTests.java.StarterProject | ||
|
||
[![Build Status](../../workflows/build/badge.svg?branch=main)](../../actions?query=build%3Amain) | ||
|
||
|
||
This is a starter project for: | ||
|
||
* ApprovalTests in java - see [ApprovalTests.java](https://github.com/approvals/ApprovalTests.java) | ||
* Junit | ||
* Maven | ||
|
||
Works on Mac, Linux and Windows. | ||
|
||
Feel free to copy and go... | ||
|
||
## Starting Point | ||
|
||
The tests in [SampleTests](https://github.com/approvals/ApprovalTests.java.StarterProject/blob/master/src/test/java/org/samples/SampleTests.java) should pass, and then you should delete/modify as needed to get started. | ||
|
||
|
||
Notes: | ||
|
||
* For more information, see the [ApprovalTests.java User Guide](https://github.com/approvals/ApprovalTests.Java/blob/master/approvaltests/docs/README.md#top) | ||
* You will need a Diff tool. | ||
* Suggestions: | ||
* Mac: [DiffMerge](https://sourcegear.com/diffmerge/) | ||
* Windows: [WinMerge](winmerge.org/) | ||
* Linux: [meld](http://meldmerge.org/) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# To run this script directly, run this in an elevated admin PowerShell prompt: | ||
# Invoke-WebRequest -UseBasicParsing https://raw.githubusercontent.com/approvals/ApprovalTests.java.StarterProject/master/install.windows.ps1 | Invoke-Expression | ||
|
||
# This script is intended to setup a dev machine from scratch. Very useful for setting up a EC2 instance for mobbing. | ||
# | ||
|
||
|
||
iwr -useb https://raw.githubusercontent.com/JayBazuzi/machine-setup/main/windows.ps1 | iex | ||
iwr -useb https://raw.githubusercontent.com/JayBazuzi/machine-setup/main/java-intellij.ps1 | iex | ||
|
||
|
||
# Clone repo | ||
& "C:\Program Files\Git\cmd\git.exe" clone https://github.com/approvals/ApprovalTests.java.StarterProject.git C:\Code\ApprovalTests.java.StarterProject | ||
|
||
# Done | ||
cls | ||
echo "Done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/sample-templates-services-us-west-2.html#w1ab2c21c45c15c15 | ||
# Amazon EC2 instance in a security group Creates an Amazon EC2 instance in an Amazon EC2 security group. | ||
--- | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Description: 'AWS CloudFormation Sample Template EC2InstanceWithSecurityGroupSample: | ||
Create an Amazon EC2 instance running the Amazon Linux AMI. The AMI is chosen based | ||
on the region in which the stack is run. This example creates an EC2 security group | ||
for the instance to give you SSH access. **WARNING** This template creates an Amazon | ||
EC2 instance. You will be billed for the AWS resources used if you create a stack | ||
from this template.' | ||
Parameters: | ||
KeyName: | ||
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance | ||
Type: AWS::EC2::KeyPair::KeyName | ||
ConstraintDescription: must be the name of an existing EC2 KeyPair. | ||
InstanceType: | ||
Description: WebServer EC2 instance type | ||
Type: String | ||
Default: t2.xlarge | ||
AllowedValues: | ||
- t2.large | ||
- t2.xlarge | ||
ConstraintDescription: must be a valid EC2 instance type. | ||
SSHLocation: | ||
Description: The IP address range that can be used to SSH to the EC2 instances | ||
Type: String | ||
MinLength: '9' | ||
MaxLength: '18' | ||
Default: 0.0.0.0/0 | ||
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})" | ||
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x. | ||
Mappings: | ||
AWSInstanceType2Arch: | ||
t2.large: | ||
Arch: HVM64 | ||
t2.xlarge: | ||
Arch: HVM64 | ||
Resources: | ||
EC2Instance: | ||
Type: AWS::EC2::Instance | ||
Properties: | ||
InstanceType: | ||
Ref: InstanceType | ||
SecurityGroups: | ||
- Ref: InstanceSecurityGroup | ||
KeyName: | ||
Ref: KeyName | ||
ImageId: ami-0db6a09e9ade44bb3 | ||
Tags: | ||
- Key: Name | ||
Value: ApprovalTests.java.StarterProject | ||
UserData: | ||
Fn::Base64: <powershell>Invoke-WebRequest -UseBasicParsing https://raw.githubusercontent.com/approvals/ApprovalTests.java/master/install.windows.ps1 | Invoke-Expression</powershell> | ||
InstanceSecurityGroup: | ||
Type: AWS::EC2::SecurityGroup | ||
Properties: | ||
GroupDescription: Enable RDP access via port 3389 | ||
SecurityGroupIngress: | ||
- IpProtocol: tcp | ||
FromPort: '3389' | ||
ToPort: '3389' | ||
CidrIp: | ||
Ref: SSHLocation | ||
Outputs: | ||
InstanceId: | ||
Description: InstanceId of the newly created EC2 instance | ||
Value: | ||
Ref: EC2Instance | ||
AZ: | ||
Description: Availability Zone of the newly created EC2 instance | ||
Value: | ||
Fn::GetAtt: | ||
- EC2Instance | ||
- AvailabilityZone | ||
PublicDNS: | ||
Description: Public DNSName of the newly created EC2 instance | ||
Value: | ||
Fn::GetAtt: | ||
- EC2Instance | ||
- PublicDnsName | ||
|
||
PublicIP: | ||
Description: Public IP address of the newly created EC2 instance | ||
Value: | ||
Fn::GetAtt: | ||
- EC2Instance | ||
- PublicIp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"ExcludeDirectories": [ "target" ], | ||
"Convention": "InPlaceOverwrite", | ||
"TocLevel": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
gh pr merge --auto --rebase "$PR_URL" | ||
|
||
if [ $? -ne 0 ] | ||
then | ||
echo 'if you want github to automatically merge pull requests from dependabot, you need to create a' | ||
echo 'personal access token (public_repo) and assign it to settings -> secrets -> dependabot -> GH_ACTION_TOKEN' | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" 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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>starterproject</groupId> | ||
<artifactId>EarlyReturnKata</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>17</source> | ||
<target>17</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>3.1.2</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.approvaltests</groupId> | ||
<artifactId>approvaltests</artifactId> | ||
<version>19.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>2.10.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<version>5.10.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<profile> | ||
<id>download-sources</id> | ||
<properties> | ||
<downloadSources>true</downloadSources> | ||
<downloadJavadocs>true</downloadJavadocs> | ||
</properties> | ||
<activation> | ||
<activeByDefault>true</activeByDefault> | ||
</activation> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.samples; | ||
|
||
public class Person | ||
{ | ||
private final String firstName; | ||
private final String lastName; | ||
private final boolean isMale; | ||
private final int age; | ||
public Person(String firstName, String lastName, boolean isMale, int age) | ||
{ | ||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
this.isMale = isMale; | ||
this.age = age; | ||
} | ||
public String getFirstName() | ||
{ | ||
return firstName; | ||
} | ||
public String getLastName() | ||
{ | ||
return lastName; | ||
} | ||
public boolean isMale() | ||
{ | ||
return isMale; | ||
} | ||
public int getAge() | ||
{ | ||
return age; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.samples; | ||
|
||
import org.approvaltests.core.ApprovalFailureReporter; | ||
import org.approvaltests.reporters.DiffReporter; | ||
|
||
/** | ||
* Here you can set the default reporter used for everything | ||
* starting with org.samples.* including sub-packages | ||
**/ | ||
public class PackageSettings | ||
{ | ||
public ApprovalFailureReporter UseReporter = DiffReporter.INSTANCE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.samples; | ||
|
||
|
||
import org.approvaltests.Approvals; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class SampleTests | ||
{ | ||
@Test | ||
public void testNormalJunit() | ||
{ | ||
assertEquals(5, 5); | ||
} | ||
@Test | ||
public void testWithApprovalTests() | ||
{ | ||
Approvals.verify("Hello World"); | ||
} | ||
/** | ||
* note: this requires GSON which is currently added in the pom.xml file. | ||
* This is only required if you want to use the VerifyAsJson. | ||
**/ | ||
@Test | ||
public void testJson() | ||
{ | ||
Person hero = new Person("jayne", "cobb", true, 38); | ||
Approvals.verifyAsJson(hero); | ||
} | ||
} |
Oops, something went wrong.