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

Ok 735 ovara build and deploy #7

Merged
merged 21 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e7d05ca
OK-735: Kokeillaan buildia github-actionsissä
heidilm Nov 25, 2024
2fc3532
OK-735: Lisätään artifactory username ja password settingsiin
heidilm Nov 26, 2024
e50e34e
OK-735: Vaihdetaan Java 17 -> 21
heidilm Nov 26, 2024
8b22f82
OK-735: Vaihdetaan Github actions cache v2 -> v4
heidilm Nov 26, 2024
477780a
OK-735: Build and deploy docker container
heidilm Nov 26, 2024
20a48d0
OK-735: Käytetään propertiesissä host_virkailija-muuttujaa
heidilm Nov 27, 2024
9c62dc7
OK-735: Muutetaan /ping-rajapinnan nimi /healthcheckiksi
heidilm Nov 28, 2024
3be4502
OK-735: Muutetaan configin sijaintia, jotta sovellus löytää ne
heidilm Nov 28, 2024
c4816c2
OK-735: Lisätään swagger-config
heidilm Nov 29, 2024
d37968a
OK-735: Testataan github workflowta
heidilm Nov 29, 2024
d06babc
OK-735: Lisätään ssl-proxy configuraatio
heidilm Nov 29, 2024
2870849
OK-735: Korjataan ping-funktionimi healthcheckiksi
heidilm Nov 29, 2024
91fc751
OK-735: Poistetaan autentikointivaatimus /healthcheck-endpointilta
heidilm Dec 2, 2024
248044c
OK-735: Ovara-ui deploy from local
heidilm Dec 3, 2024
9e80972
Merge branch 'main' into OK-735-ovara-build-and-deploy
heidilm Dec 5, 2024
4c7a43a
OK-735: Lisätään uin manuaalinen asennusskripti
heidilm Dec 5, 2024
6ff610f
OK-735: Lisätään build-buckettiin "ovara-ui"-kansio buildatessa
heidilm Jan 3, 2025
2acf41b
OK-735: Uusi deploy
heidilm Jan 9, 2025
fbbbf2f
OK-735: Poistetaan skipTests-vipu CI-buildista
heidilm Jan 14, 2025
1c569fd
OK-735: Lisätään scalatest-maven-plugin testien ajamista varten
heidilm Jan 14, 2025
9388261
OK-735: Poistetaan JBoss-riippuvuus
heidilm Jan 14, 2025
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
148 changes: 148 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Ovara-virkailija build workflow

on:
workflow_dispatch:
push:
paths-ignore:
- '**.md'

jobs:
# BACKEND
build-backend:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/cache@v4
id: restore-build
with:
path: |
ovara-backend/target
key: ${{ github.sha }}

- name: Cache local Maven repository
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'corretto'
cache: 'maven'

- uses: szenius/[email protected]
with:
timezoneLinux: "Europe/Helsinki"

- name: Build with Maven
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
run: |
cd ovara-backend
mvn clean package -B

deploy-backend-container:
needs: build-backend
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/cache@v4
id: restore-build
with:
path: |
ovara-backend/target
key: ${{ github.sha }}

- name: Build and deploy Docker container
shell: bash
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
set -euo pipefail
git clone https://github.com/Opetushallitus/ci-tools.git
source ci-tools/common/setup-tools.sh
export ARTIFACT_NAME="ovara-backend"
export BASE_IMAGE="baseimage-fatjar-openjdk21:master"
source ci-tools/common/setup-tools.sh
mv ovara-backend/target/ovara-backend-*.jar $DOCKER_BUILD_DIR/artifact/${ARTIFACT_NAME}.jar
cp -vr ovara-backend/src/main/resources/oph-configuration $DOCKER_BUILD_DIR/config/oph-configuration/
./ci-tools/common/pull-image.sh
./ci-tools/github-build/build-fatjar.sh $ARTIFACT_NAME
./ci-tools/github-build/upload-image.sh $ARTIFACT_NAME

# UI
lint:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: |
cd ovara-ui
npm ci
- name: Run lint
run: |
cd ovara-ui
# npm run typecheck
npm run lint

test:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: |
cd ovara-ui
npm ci
- name: Run unit tests
run: |
cd ovara-ui
npm test

deploy-ui-zip:
needs: [lint, test]
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: |
cd ovara-ui
npm ci --no-audit --prefer-offline
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4
with:
role-to-assume: ${{ secrets.AWS_OPH_UTILITY_ROLE_ARN }}
role-session-name: ovara-ui-deploy-zip
aws-region: eu-west-1
- name: Deploy zip to s3
env:
bucket: ${{ secrets.BUCKET_NAME }}
run: |
cd ovara-ui
SKIP_TYPECHECK=true npm run build
zip -r ga-${{github.run_number}}.zip .next/*.* .next/BUILD_ID .next/static .next/standalone public
aws s3 cp --no-progress ga-${{github.run_number}}.zip s3://"$bucket"/ovara-ui/ga-${{github.run_number}}.zip
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@ node_modules
.next

.mise.toml

# local env files
.env*.local

# CDK
.cdk.staging
cdk.out
.open-next
cdk/**/*.d.ts
2 changes: 1 addition & 1 deletion ovara-backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ build/

.mise.toml

application-dev.properties
src/main/resources/oph-configuration/application-dev.properties

ovara.dump
64 changes: 64 additions & 0 deletions ovara-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<scala.version>3.5.0</scala.version>
<java.cas.version>1.2.1-SNAPSHOT</java.cas.version>
<scalatest.version>3.2.19</scalatest.version>

</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -152,6 +153,42 @@
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>

<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/opetushallitus/packages</url>
<releases>
<enabled>false</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
<repository>
<id>oph-sade-artifactory-snapshots</id>
<url>https://artifactory.opintopolku.fi/artifactory/oph-sade-snapshot-local</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>oph-sade-artifactory-releases</id>
<url>https://artifactory.opintopolku.fi/artifactory/oph-sade-release-local</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
Expand All @@ -171,6 +208,33 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>WDF TestSuite.txt</filereports>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand Down
11 changes: 11 additions & 0 deletions ovara-backend/settings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- Maven settings -tiedosto CI-buildia varten, tarvitaan jotta voidaan autentikoitua Github Packages -repoon -->

<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
Expand Down Expand Up @@ -29,5 +30,15 @@
<username>private-token</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
<server>
<id>oph-sade-artifactory</id>
<username>${env.ARTIFACTORY_USERNAME}</username>
<password>${env.ARTIFACTORY_PASSWORD}</password>
</server>
<server>
<id>oph-nexus</id>
<username>${env.ARTIFACTORY_USERNAME}</username>
<password>${env.ARTIFACTORY_PASSWORD}</password>
</server>
</servers>
</settings>
20 changes: 0 additions & 20 deletions ovara-backend/src/main/resources/application.properties

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ENVIRONMENT SPECIFIC CONFIG
# DB CONNECTION
spring.datasource.url={{host_postgresql_ovara}}
spring.datasource.username={{ovara_backend_postgresql_username}}
spring.datasource.password={{ovara_backend_postgresql_password}}

# CAS
opintopolku.virkailija.domain={{host_virkailija}}
opintopolku.virkailija.url=https://${opintopolku.virkailija.domain}
ovara.backend.url=${opintopolku.virkailija.url}/ovara-backend
ovara.ui.url=${opintopolku.virkailija.url}/ovara
cas.url=${opintopolku.virkailija.url}/cas
ovara-backend.cas.username={{ovara_backend_cas_username}}
ovara-backend.cas.password={{ovara_backend_cas_password}}

ovara_backend.uses-ssl-proxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spring.application.name=ovara-backend
server.servlet.context-path=/ovara-backend

#swagger-ui config
springdoc.swagger-ui.path=/swagger-ui
springdoc.swagger-ui.operationsSorter=alpha
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class Controller(
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
mapper.configure(SerializationFeature.INDENT_OUTPUT, true)

@GetMapping(path = Array("ping"))
def ping = "Ovara application is running!"
@GetMapping(path = Array("healthcheck"))
def healthcheck = "Ovara application is running!"

@GetMapping(path = Array("user"))
def user(@AuthenticationPrincipal userDetails: UserDetails): String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import org.springframework.security.web.authentication.HttpStatusEntryPoint

@Configuration
@EnableWebSecurity
class CasConfig {
class SecurityConfig {
@Value("${cas.url}")
val cas_url: String = null

@Value("${ovara.backend.url}")
val ovara_backend_url: String = null

@Value("${opintopolku.virkailija.domain}")
@Value("${opintopolku.virkailija.url}")
val opintopolku_virkailija_domain: String = null

@Value("${ovara-backend.cas.username}")
Expand Down Expand Up @@ -116,6 +116,16 @@ class CasConfig {
.build()
}

@Bean
@Order(3)
def healthcheckFilterChain(http: HttpSecurity): SecurityFilterChain = {
http
.securityMatcher("/api/healthcheck")
.authorizeHttpRequests(requests => requests.anyRequest.permitAll)
.csrf(c => c.disable)
.build()
}

@Bean
@Order(1)
def csrfFilterChain(http: HttpSecurity): SecurityFilterChain = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import scala.jdk.javaapi.FutureConverters.asScala
class OnrService {
val LOG: Logger = LoggerFactory.getLogger(classOf[OnrService])

@Value("${opintopolku.virkailija.domain}")
@Value("${opintopolku.virkailija.url}")
val opintopolku_virkailija_domain: String = null

@Autowired
Expand Down
Loading
Loading