-
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
Katherine Soohoo
committed
Apr 24, 2024
0 parents
commit 323bd58
Showing
7 changed files
with
186 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,38 @@ | ||
# Name of the workflow | ||
name: DevOps Lab - Java | ||
|
||
# Specifies what triggers the workflow | ||
on: [push] | ||
|
||
# Jobs to run in the workflow | ||
jobs: | ||
# First job to run in the workflow | ||
build: | ||
# Define the type of machine for the job to run on | ||
runs-on: ubuntu-latest | ||
# Sequence of steps to run | ||
steps: | ||
# Checkout the repository | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
# Setup environment | ||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
cache: maven | ||
# Verify tools | ||
- name: Verify Java version | ||
run: java -version | ||
- name: Verify Maven version | ||
run: mvn -version | ||
# TODO: Build application with Maven | ||
- name: Build with Maven | ||
run: echo '🛠️ build me please 🛠️' | ||
# Upload artifacts | ||
- name: Archive | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: JAR | ||
path: target/*.jar |
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 @@ | ||
target/ |
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,20 @@ | ||
# DevOpsLab - Java | ||
|
||
A sample Java project to try out DevOps with GitHub Actions. | ||
|
||
## Prerequisites | ||
|
||
- Java 17+ | ||
- Maven 3+ | ||
|
||
## Build | ||
|
||
``` | ||
mvn clean package | ||
``` | ||
* Removes files from previous builds | ||
* Compiles source code | ||
* Runs tests | ||
* Packages compiled code into a JAR | ||
|
||
For more information about Maven's build lifecycle, see https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html |
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,27 @@ | ||
<?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>edu.sjsu</groupId> | ||
<artifactId>devopslab-java</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>5.10.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</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,9 @@ | ||
package edu.sjsu; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
boolean result = NameChecker.check(args[0]); | ||
|
||
System.out.println("Result: " + result); | ||
} | ||
} |
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,18 @@ | ||
package edu.sjsu; | ||
|
||
public class NameChecker { | ||
/** | ||
* Checks if a given string is a valid name following these rules: | ||
* - Between 2 to 40 characters | ||
* - Contains only alphabetic characters, non-consecutive hyphens, or a single quote | ||
* - Cannot start with a hyphen or single quote | ||
* | ||
* @param input Name to check | ||
* @return True if input is a valid name, else false | ||
*/ | ||
public static boolean check(String input) { | ||
// TODO: implement | ||
|
||
return false; | ||
} | ||
} |
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,73 @@ | ||
package edu.sjsu; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class NameCheckerTest { | ||
|
||
@Test | ||
public void testValidName() { | ||
assertTrue(NameChecker.check("John")); | ||
} | ||
|
||
@Test | ||
public void testInvalidNameWithSpecialCharacter() { | ||
assertFalse(NameChecker.check("John$")); | ||
} | ||
|
||
@Test | ||
public void testInvalidNameWithNumbers() { | ||
assertFalse(NameChecker.check("John123")); | ||
} | ||
|
||
@Test | ||
public void testValidNameWithApostrophe() { | ||
assertTrue(NameChecker.check("O'Brien")); | ||
} | ||
|
||
@Test | ||
public void testValidNameWithHyphen() { | ||
assertTrue(NameChecker.check("Smith-Jones")); | ||
} | ||
|
||
@Test | ||
public void testInvalidNameWithTooManyCharacters() { | ||
assertFalse(NameChecker.check("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); | ||
} | ||
|
||
@Test | ||
public void testInvalidNameWithDoubleHyphen() { | ||
assertFalse(NameChecker.check("John--Doe")); | ||
} | ||
|
||
@Test | ||
public void testInvalidNameWithQuotes() { | ||
assertFalse(NameChecker.check("'John'")); | ||
} | ||
|
||
@Test | ||
public void testValidNameWithQuotesWithinAllowedLength() { | ||
assertTrue(NameChecker.check("O'Neil")); | ||
} | ||
|
||
@Test | ||
public void testInvalidNameWithQuotesBeyondAllowedLength() { | ||
assertFalse(NameChecker.check("O'Connolly'")); | ||
} | ||
|
||
@Test | ||
public void testInvalidNameWithSpaces() { | ||
assertFalse(NameChecker.check("John Smith")); | ||
} | ||
|
||
@Test | ||
public void testInvalidNameWithFirstCharacterHyphen() { | ||
assertFalse(NameChecker.check("-John")); | ||
} | ||
|
||
public void testInvalidNameWithFirstCharacterApostrophe() { | ||
assertFalse(NameChecker.check("'John")); | ||
} | ||
} |