Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
team-nuwe authored Feb 18, 2024
0 parents commit 660a65c
Show file tree
Hide file tree
Showing 41 changed files with 3,307 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
30 changes: 30 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/.github/** @team-nuwe
/.mvn/** @team-nuwe
/src/main/java/com/example/demo/JacksonConfiguration.java @team-nuwe
/src/main/java/com/example/demo/ServletInitializer.java @team-nuwe
/src/main/java/com/example/demo/TechhubApplication.java @team-nuwe
/src/main/java/com/example/demo/controllers/DoctorController.java @team-nuwe
/src/main/java/com/example/demo/controllers/PatientController.java @team-nuwe
/src/main/java/com/example/demo/controllers/RoomController.java @team-nuwe
/src/main/java/com/example/demo/entities/Appointment.java @team-nuwe
/src/main/java/com/example/demo/entities/Doctor.java @team-nuwe
/src/main/java/com/example/demo/entities/Patient.java @team-nuwe
/src/main/java/com/example/demo/entities/Person.java @team-nuwe
/src/main/java/com/example/demo/entities/Room.java @team-nuwe
/src/main/java/com/example/demo/repositories/AppointmentRepository.java @team-nuwe
/src/main/java/com/example/demo/repositories/DoctorRepository.java @team-nuwe
/src/main/java/com/example/demo/repositories/PatientRepository.java @team-nuwe
/src/main/java/com/example/demo/repositories/RoomRepository.java @team-nuwe
/src/main/resources/application-integrationtest.properties @team-nuwe
/src/main/resources/application.properties @team-nuwe
/src/test/java/com/example/demo/AppointmentControllerUnitTest.java @team-nuwe
/src/test/java/com/example/demo/AppointmentJpaUnitTest.java @team-nuwe
/src/test/java/com/example/demo/DemoApplicationTests.java @team-nuwe
/src/test/java/com/example/demo/DoctorJpaUnitTest.java @team-nuwe
/src/test/java/com/example/demo/PatientJpaUnitTest.java @team-nuwe
/src/test/java/com/example/demo/RoomJpaUnitTest.java @team-nuwe
/src/test/resources/application.properties @team-nuwe
mvnw @team-nuwe
mvnw.cmd @team-nuwe
pom.xml @team-nuwe
sonar-project.properties @team-nuwe
160 changes: 160 additions & 0 deletions .github/workflows/scoring.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
on:
push:
branches:
- main

jobs:
sonarqube:
environment: SCORING
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
PROJECT_ID: ${{ github.event.repository.name }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'

- name: Maven pre-config
if: always()
run: chmod +x mvnw

- name: Build with Maven. No tests run
if: always()
run: ./mvnw clean verify -l phase0.out -fn

- name: Phase 1. Test AppointmentControllerUnitTest POST /appointment.
if: always()
run: ./mvnw test -Dtest="AppointmentControllerUnitTest" -l phase1.out -fn

- name: Phase 2. Test Entity and Controllers.
if: always()
run: ./mvnw test -Dtest="EntityUnitTest, DoctorControllerUnitTest, PatientControllerUnitTest, RoomControllerUnitTest" -l phase2.out -fn

- name: Phase 4-1 . Build Dockerfile.mysql image.
if: always()
run: docker build . --file Dockerfile.mysql --tag accwe-hospital:$(date +%s) 2>/dev/null; last=$?;res="FAILURE"; if [[ $last -eq 0 ]]; then res="SUCCESS";fi; echo $res > phase4-1.out

- name: Phase 4-2. Build Dockerfile.maven image.
if: always()
run: docker build . --file Dockerfile.maven --tag accwe-api:$(date +%s) 2>/dev/null; last=$?;res="FAILURE"; if [[ $last -eq 0 ]]; then res="SUCCESS";fi; echo $res > phase4-2.out

- uses: actions/setup-node@v3
if: always()
with:
node-version: 16

- name: Install xml-js
if: always()
run : npm install xml-js

- name: Update solution
if: always()
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const fs = require("fs");
const xmlParser = require("xml-js");

// Array Results
const assertionResults = [];

// Phase 1 file
try {
const file_p1 = fs.readFileSync("./phase1.out");
if (file_p1.toString().indexOf("[INFO] BUILD SUCCESS") > -1)
assertionResults.push(0); // Phase 1 == [0]
} catch (e) {
console.log("Error during Phase 1 loading");
}

// Phase 2 file
try {
const file_p2 = fs.readFileSync("./phase2.out");
if (file_p2.toString().indexOf("[INFO] BUILD SUCCESS") > -1)
assertionResults.push(1); // Phase 2 == [1]
} catch (e) {
console.log("Error during Phase 2 loading");
}

// Phase 3 Coverage >= 85 (Sonarqube)
let file_p3;

try {
file_p3 = fs.readFileSync("./target/site/jacoco/jacoco.xml");

const options = {
compact: true,
spaces: 2,
ignoreDeclaration: true,
ignoreComment: true,
ignoreCData: true,
ignoreDoctype: true,
ignoreText: true,
ignoreInstruction: true,
};

const asString = xmlParser.xml2json(file_p3, options);
const json = JSON.parse(asString);
const counters = json["report"]["counter"];
const missed = [];
const covered = [];

for (const attributename in counters) {
var attrs = counters[attributename]["_attributes"];
missed.push(Number(attrs["missed"]));
covered.push(Number(attrs["covered"]));
}

const totalMissed = missed.reduce((partialSum, a) => partialSum + a, 0);
const totalCovered = covered.reduce((partialSum, a) => partialSum + a, 0);
const percent = ((totalCovered - totalMissed) / totalCovered) * 100;

if (percent >= 90) assertionResults.push(2); // Phase 3 == [2]
} catch (e) {
console.log("Error during Phase 3 loading");
}

// Phase 4 file (Dockerfile.mysql)
try {
const file_p4_1 = fs.readFileSync("./phase4-1.out");
const file_p4_2 = fs.readFileSync("./phase4-2.out");

if (
file_p4_1.toString().indexOf("SUCCESS") > -1 &&
file_p4_2.toString().indexOf("SUCCESS") > -1
)
assertionResults.push(3); // Phase 4 == [3]
} catch (e) {
console.log("Error during Phase 4 loading");
}

console.log("Updating score...");

try {
await github.request(
`PATCH https://api.nuwe.io/projects/${process.env.PROJECT_ID}/objectives`,
{
bearerToken: process.env.PERSONAL_TOKEN,
assertionResults,
}
);

console.log("Done");
} catch (e) {
core.error("API connection error");
core.setFailed(e);
}

- name: SonarQube Scan 🚨 (Coverage Phase 3)
if: always()
run: ./mvnw clean verify test sonar:sonar -Dsonar.projectKey=${{github.event.repository.name}} -Dsonar.projectName=$PROJECT_ID -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.token=$SONAR_TOKEN
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target/*
target/
.vscode/*
.vscode/
Binary file added .mvn/.DS_Store
Binary file not shown.
99 changes: 99 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import java.io.IOException;
import java.io.InputStream;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

public final class MavenWrapperDownloader
{
private static final String WRAPPER_VERSION = "@@project.version@@";

private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) );

public static void main( String[] args )
{
log( "Apache Maven Wrapper Downloader " + WRAPPER_VERSION );

if ( args.length != 2 )
{
System.err.println( " - ERROR wrapperUrl or wrapperJarPath parameter missing" );
System.exit( 1 );
}

try
{
log( " - Downloader started" );
final URL wrapperUrl = new URL( args[0] );
final String jarPath = args[1].replace( "..", "" ); // Sanitize path
final Path wrapperJarPath = Paths.get( jarPath ).toAbsolutePath().normalize();
downloadFileFromURL( wrapperUrl, wrapperJarPath );
log( "Done" );
}
catch ( IOException e )
{
System.err.println( "- Error downloading: " + e.getMessage() );
if ( VERBOSE )
{
e.printStackTrace();
}
System.exit( 1 );
}
}

private static void downloadFileFromURL( URL wrapperUrl, Path wrapperJarPath )
throws IOException
{
log( " - Downloading to: " + wrapperJarPath );
if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null )
{
final String username = System.getenv( "MVNW_USERNAME" );
final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray();
Authenticator.setDefault( new Authenticator()
{
@Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication( username, password );
}
} );
}
try ( InputStream inStream = wrapperUrl.openStream() )
{
Files.copy( inStream, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING );
}
log( " - Downloader complete" );
}

private static void log( String msg )
{
if ( VERBOSE )
{
System.out.println( msg );
}
}

}

Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
19 changes: 19 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar

Loading

0 comments on commit 660a65c

Please sign in to comment.