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

Features/config revisions #63

Merged
merged 5 commits into from
Feb 21, 2023
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
85 changes: 81 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@ name: CI Build
on:
push:
branches:
- develop
- main
- release

jobs:
extract-branch:
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.extract_branch.outputs.branch }}
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: extract_branch

check-folders:
runs-on: ubuntu-latest
outputs:
Expand Down Expand Up @@ -38,7 +49,32 @@ jobs:
done < files.txt
id: check

build:
unit-test:
runs-on: ubuntu-latest
needs:
- check-folders
if: ${{ needs.check-folders.outputs.run_build_job == 'true' }}
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'

- name: Unit Tests
run: mvn -Dtest=com.napier.sem.AppTests test

- name: Upload results to CodeCov
uses: codecov/codecov-action@v2
with:
directory: ./target/site/jacoco
flags: Unit Tests
verbose: true

integration-test:
runs-on: ubuntu-latest
needs:
- check-folders
Expand All @@ -47,14 +83,55 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'

- name: Integration Tests
run: |
# Build and start the database container
docker-compose up -d db

# Run the integration tests
mvn -Dtest=com.napier.sem.AppIntegrationTest test

# Stop and remove the database container, and auto-created network
docker-compose down
# Remove all unused and dangling images
docker image prune -f

- name: Upload results to CodeCov
uses: codecov/codecov-action@v2
with:
directory: ./target/site/jacoco
flags: Integration Tests
verbose: true

build:
runs-on: ubuntu-latest
needs:
- extract-branch
- check-folders
- unit-test
- integration-test

# Only run this job if the src/main/ or src/test/ folders have been modified. Also skip this job if the branch is "develop".
if: ${{ needs.check-folders.outputs.run_build_job == 'true' && needs.extract-branch.outputs.branch != 'develop' }}
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'

# Skip testing in this command, as we already ran the tests in the previous jobs.
- name: Build with Maven
run: mvn package
run: mvn package -Dmaven.test.skip=true

- name: Run docker Compose
run: docker-compose up --abort-on-container-exit
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# SET08103-group-6

Main Build Status ![GitHub Workflow Status (branch)](https://github.com/coolcalcacol/SET08103-group-6/actions/workflows/main.yml/badge.svg?branch=main) <br />
Develop Build Status ![GitHub Workflow Status (branch)](https://github.com/coolcalcacol/SET08103-group-6/actions/workflows/main.yml/badge.svg?branch=develop) <br />

[//]: # (token needed here)
[![CodeCov](https://app.codecov.io/gh/coolcalcacol/SET08103-group-6/branch/main/graph/badge.svg)](https://app.codecov.io/gh/coolcalcacol/SET08103-group-6) <br />
[![Releases](https://img.shields.io/github/release/coolcalcacol/SET08103-group-6/all.svg?style=flat-square)](https://github.com/coolcalcacol/SET08103-group-6/releases) <br />
[![LICENSE](https://img.shields.io/github/license/coolcalcacol/SET08103-group-6.svg?style=flat-square)](https://github.com/coolcalcacol/SET08103-group-6/blob/main/LICENSE) <br />

## Toolchains used
- Java 17
- Maven
Expand Down
88 changes: 87 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.napier.sem</groupId>
<artifactId>seMethods</artifactId>
<version>0.1.0.1</version>
<version>0.1.0.2</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
Expand All @@ -17,5 +17,91 @@
<artifactId>mysql-connector-j</artifactId>
<version>8.0.32</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>default-jar</id>
<!-- skip building the default-jar-->
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<finalName>seMethods</finalName>
<archive>
<manifest>
<mainClass>com.napier.sem.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.0</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
4 changes: 4 additions & 0 deletions seMethods.iml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.mysql:mysql-connector-j:8.0.32" level="project" />
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.21.9" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.9.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.9.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.2" level="project" />
</component>
</module>
1 change: 1 addition & 0 deletions src/main/java/com/napier/sem/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static void main(String[] args) {

// Create a scanner to read user input where required
Scanner userInput = new Scanner(System.in);

try {
// Connect to database
db.connect();
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/napier/sem/database/Cities.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,4 @@ public static HashMap<String, PopulationReport> getPopulationByCountry(DB db) th
}
return countryMap;
}


}
4 changes: 4 additions & 0 deletions src/test/java/com/napier/sem/AppIntegrationTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.napier.sem;

public class AppIntegrationTests {
}
13 changes: 13 additions & 0 deletions src/test/java/com/napier/sem/AppUnitTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.napier.sem;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class AppUnitTests {

@Test
void basicTest() {
assertEquals(1, 1);
}
}