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

feat(FSADT1-751): code cleanup and external libs #1287

Closed
wants to merge 20 commits into from
Closed
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
12 changes: 12 additions & 0 deletions .github/settings.xml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- settings.xml.template -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<username>${GITHUB_USERNAME}</username>
<password>${GITHUB_TOKEN}</password>
</server>
</servers>
</settings>
13 changes: 13 additions & 0 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ jobs:
strategy:
matrix:
package: [backend, database, frontend, legacy, processor]
include:
- package: backend
maven: true
- package: database
maven: false
- package: frontend
maven: false
- package: legacy
maven: true
- package: processor
maven: true
steps:
- uses: actions/checkout@v4

Expand All @@ -62,6 +73,8 @@ jobs:
triggers: ('${{ matrix.package }}/')
build_args: |
APP_VERSION=${{ needs.vars.outputs.semver }}-${{ github.event.number }}
GITHUB_USERNAME=${{ github.actor }}
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}

build-legacydb:
name: Builds (legacydb)
Expand Down
41 changes: 2 additions & 39 deletions .github/workflows/reusable-tests-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:

jobs:
trivy:
name: Repository Report
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
name: Security Scan
if: ${{ ! github.event.pull_request.draft }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
Expand All @@ -24,40 +24,3 @@ jobs:
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "trivy-results.sarif"

codeql:
name: Semantic Code Analysis
runs-on: ubuntu-24.04
permissions:
actions: read
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- uses: github/codeql-action/init@v3
with:
languages: javascript,java

# Autobuild failed for Java, so building manually
- name: Set up JDK 17 and Caching maven dependencies
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
cache: "maven"

# Java builds
- name: Build Backend
working-directory: backend
run: ./mvnw clean package -DskipTests -Dtests.skip=true -Dskip.unit.tests=true

- name: Build Legacy
working-directory: legacy
run: ./mvnw clean package -DskipTests -Dtests.skip=true -Dskip.unit.tests=true

- name: Build Processor
working-directory: processor
run: ./mvnw clean package -DskipTests -Dtests.skip=true -Dskip.unit.tests=true

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
13 changes: 6 additions & 7 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ RUN microdnf update --nodocs -y && \
ENV MAVEN_HOME=/opt/maven
ENV PATH=$MAVEN_HOME/bin:$PATH

# Receiving app version
ARG APP_VERSION=0.0.1
ARG GITHUB_USERNAME
ARG GITHUB_TOKEN

# Copy
WORKDIR /app
COPY pom.xml ./
COPY src ./src

# Setting app version
RUN mvn versions:set -DnewVersion=${APP_VERSION} -f pom.xml -DskipTests -Dtests.skip=true -Dskip.unit.tests=true && \
mvn versions:commit -f pom.xml -DskipTests -Dtests.skip=true -Dskip.unit.tests=true
COPY settings.xml.template /root/.m2/settings.xml
RUN sed -i "s|\${GITHUB_USERNAME}|${GITHUB_USERNAME}|g" /root/.m2/settings.xml && \
sed -i "s|\${GITHUB_TOKEN}|${GITHUB_TOKEN}|g" /root/.m2/settings.xml

# Build
RUN mvn -Pnative native:compile
Expand All @@ -42,7 +41,7 @@ COPY --from=build /app/target/nr-forest-client-backend ./nr-forest-client-backen
# User, port and health check
USER 1001
EXPOSE ${PORT}
HEALTHCHECK CMD curl -f http://localhost:${PORT}/actuator/health | grep '"status":"UP"'
HEALTHCHECK --interval=30s --timeout=10s --retries=3 CMD curl -f http://localhost:${PORT}/health | grep '"status":"UP"' || exit 1

# Startup
ENTRYPOINT ["/app/nr-forest-client-backend","--spring.profiles.active=container"]
17 changes: 17 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ We recommend **yml** files as they tend to be less repetitive, but it's up to yo
Also, make sure to run the application using your profile, if it's through command line, remember to pass a
**--spring.profiles.active=dev-jsmith** argument, or if using IntelliJ, create a run configuration (more on that later).

We are using the [forest client commons library](https://github.com/bcgov/nr-forest-client-commons) to share DTOs and some other classes.
This is to reduce code duplicity and make it easier to maintain the code and transfer data between the services. For it to work,
you will need to add to your maven settings file (usually located at ~/.m2/settings.xml) the following server configuration:

```xml
<servers>
<server>
<id>github</id>
<username>your_github_username</username>
<password>your_github_personal_access_token</password>
</server>
</servers>
```

You can generate a personal access token by going to your github settings > Developer settings > Personal access tokens > Generate new token.
More on this can be found [here](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token)

## Configuring your yml/properties file

When creating your own configuration file, you can overwrite any of the entries contained on the main
Expand Down
15 changes: 15 additions & 0 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@
<groupId>io.projectreactor.addons</groupId>
<artifactId>reactor-extra</artifactId>
</dependency>
<dependency>
<groupId>ca.bc.gov.nrs-commons</groupId>
<artifactId>forest-client-core</artifactId>
<version>0.3.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -491,10 +496,12 @@
<allowedRepositories>
<id>central</id>
<id>spring-milestones</id>
<id>github</id>
</allowedRepositories>
<allowedPluginRepositories>
<id>central</id>
<id>spring-milestones</id>
<id>github</id>
</allowedPluginRepositories>
</requireNoRepositories>
<requireReleaseDeps>
Expand Down Expand Up @@ -614,5 +621,13 @@
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>github</id>
<name>Github Packages</name>
<url>https://maven.pkg.github.com/bcgov/nr-forest-client-commons</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
12 changes: 12 additions & 0 deletions backend/settings.xml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- settings.xml.template -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>github</id>
<username>${GITHUB_USERNAME}</username>
<password>${GITHUB_TOKEN}</password>
</server>
</servers>
</settings>
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,8 @@
public final class ApplicationConstant {

public static final String POSTGRES_ATTRIBUTE_SCHEMA = "nrfc";

public static final String USERID_HEADER = "x-user-id";
public static final String BUSINESSID_HEADER = "x-user-businessid";
public static final String USERMAIL_HEADER = "x-user-email";
public static final String USERNAME_HEADER = "x-user-name";
public static final String X_TOTAL_COUNT = "x-total-count";

public static final String INDIVIDUAL_CLIENT_TYPE_CODE = "I";
public static final String REG_SOLE_PROPRIETORSHIP_CLIENT_TYPE_CODE = "RSP";
public static final String UNREG_SOLE_PROPRIETORSHIP_CLIENT_TYPE_CODE = "USP";

public static final BcRegistryDocumentRequestBodyDto
BUSINESS_SUMMARY_FILING_HISTORY =
new BcRegistryDocumentRequestBodyDto(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import ca.bc.gov.app.dto.client.ClientBusinessInformationDto;
import ca.bc.gov.app.dto.client.ClientListSubmissionDto;
import ca.bc.gov.app.dto.client.ClientSubmissionDto;
import ca.bc.gov.app.dto.client.SubmissionStatusEnum;
import ca.bc.gov.app.dto.client.ValidationSourceEnum;
import ca.bc.gov.app.dto.submissions.SubmissionApproveRejectDto;
import ca.bc.gov.app.dto.submissions.SubmissionDetailsDto;
import ca.bc.gov.app.exception.InvalidRequestObjectException;
import ca.bc.gov.app.exception.NoClientDataFound;
import ca.bc.gov.app.models.client.SubmissionStatusEnum;
import ca.bc.gov.app.service.client.ClientSubmissionService;
import ca.bc.gov.app.util.JwtPrincipalUtil;
import ca.bc.gov.app.validator.SubmissionValidatorService;
Expand Down
20 changes: 0 additions & 20 deletions backend/src/main/java/ca/bc/gov/app/dto/ValidationError.java

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading