Skip to content

Commit

Permalink
Oppdater pipeline og legg til metrikker (#244)
Browse files Browse the repository at this point in the history
* Oppdater pipeline og legg til metrikker

* Oppdater pipeline og legg til metrikker

* Oppdater pipeline og legg til metrikker
  • Loading branch information
ugur93 authored Oct 6, 2023
1 parent 1baf754 commit ab5590a
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 41 deletions.
14 changes: 0 additions & 14 deletions .github/.m2/maven-settings.xml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "[dependency] "
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "[docker] "
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "[github-actions] "
16 changes: 8 additions & 8 deletions .github/workflows/deploy_feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ on:
branches:
- '**'
- '!main'

- '!dependabot/**'
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
Expand All @@ -17,7 +16,7 @@ jobs:
name: Build with maven and docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '17'
Expand All @@ -28,7 +27,7 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- run: mvn -Dmaven.test.skip=true -B -e --settings .github/.m2/maven-settings.xml clean install
- run: mvn -Dmaven.test.skip=true -DskipOwasp=true -B -e clean install
- uses: nais/docker-build-push@v0
id: docker-push
with:
Expand All @@ -44,26 +43,26 @@ jobs:
name: Run tests
needs: build
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- uses: actions/cache@v3
with:
path: ~/.m2
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- run: mvn -B -e --settings .github/.m2/maven-settings.xml clean install
- run: mvn test

deploy-feature:
runs-on: ubuntu-latest
name: Deploy feature
needs: build

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: deploy
- name: Deploy to dev-gcp for feature.yaml
Expand All @@ -74,6 +73,7 @@ jobs:
RESOURCE: deploy/.nais/nais.yaml
VARS: deploy/.nais/feature.yaml
IMAGE: ${{ needs.build.outputs.image }}

run_cucumber_tests:
runs-on: ubuntu-latest
name: Run cucumber tests
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ on:
types: [ ready_for_review, opened, synchronize ]

env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
if: github.event.pull_request.draft == false
permissions:
contents: "read"
id-token: "write"
name: Build with maven and docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '17'
Expand All @@ -26,7 +26,7 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- run: mvn -Dmaven.test.skip=true -B -e --settings .github/.m2/maven-settings.xml clean install
- run: mvn -Dmaven.test.skip=true -DskipOwasp=true -B -e clean install
- uses: nais/docker-build-push@v0
id: docker-push
with:
Expand All @@ -40,27 +40,27 @@ jobs:
run-tests:
runs-on: ubuntu-latest
name: Run tests
needs: build
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- uses: actions/cache@v3
with:
path: ~/.m2
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- run: mvn -B -e --settings .github/.m2/maven-settings.xml clean install
- run: mvn test

deploy-main:
runs-on: ubuntu-latest
name: Deploy main
needs: build
if: github.actor != 'dependabot[bot]'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: deploy
- name: Deploy main branch to dev-gcp
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
branches:
- 'main'
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
Expand All @@ -15,7 +14,7 @@ jobs:
name: Build with maven and docker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '17'
Expand All @@ -26,7 +25,7 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- run: mvn -Dmaven.test.skip=true -B -e --settings .github/.m2/maven-settings.xml clean install
- run: mvn -Dmaven.test.skip=true -DskipOwasp=true -B -e clean install
- uses: nais/docker-build-push@v0
id: docker-push
with:
Expand All @@ -43,7 +42,7 @@ jobs:
needs: build

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: deploy
- uses: nais/deploy/actions/deploy@v1
Expand All @@ -64,7 +63,7 @@ jobs:
contents: write
needs: deploy
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Push latest image tag as github tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rollback_prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
name: Find tag to deploy

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: NAIS login
uses: nais/login@v0
id: login
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
needs: prepare_deploy

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<build-helper-maven.version>3.2.0</build-helper-maven.version>
<token-support.version>3.1.2</token-support.version>
<!-- dependencies -->
<bidrag-commons.version>20230510130746_8b93e85</bidrag-commons.version>
<bidrag-commons.version>20231002151454_eab4a7b</bidrag-commons.version>
<bidrag-commons-test.version>1.20230511093912_dc35d81</bidrag-commons-test.version>
<bidrag-transport.version>20230929134005_dfcb25d</bidrag-transport.version>
<bidrag-tilgangskontroll.version>1.10.4</bidrag-tilgangskontroll.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package no.nav.bidrag.grunnlag.service

import io.micrometer.core.instrument.Counter
import io.micrometer.core.instrument.MeterRegistry
import no.nav.bidrag.commons.security.utils.TokenUtils
import no.nav.bidrag.domain.enums.Formaal
import no.nav.bidrag.domain.enums.GrunnlagsRequestStatus
import no.nav.bidrag.transport.behandling.grunnlag.request.OppdaterGrunnlagspakkeRequestDto
import no.nav.bidrag.transport.behandling.grunnlag.request.OpprettGrunnlagspakkeRequestDto
Expand All @@ -15,12 +19,19 @@ import java.time.LocalDateTime
@Transactional
class GrunnlagspakkeService(
private val persistenceService: PersistenceService,
private val oppdaterGrunnlagspakkeService: OppdaterGrunnlagspakkeService
private val oppdaterGrunnlagspakkeService: OppdaterGrunnlagspakkeService,
private val meterRegistry: MeterRegistry
) {

fun opprettGrunnlagspakkeCounter(formaal: Formaal) = Counter.builder("opprett_grunnlagspakke")
.tag("formaal", formaal.name)
.tag("opprettetAvApp", TokenUtils.hentApplikasjonsnavn() ?: "UKJENT")
.register(meterRegistry)

fun opprettGrunnlagspakke(opprettGrunnlagspakkeRequestDto: OpprettGrunnlagspakkeRequestDto): Int {
val opprettetGrunnlagspakke =
persistenceService.opprettNyGrunnlagspakke(opprettGrunnlagspakkeRequestDto)
opprettGrunnlagspakkeCounter(opprettGrunnlagspakkeRequestDto.formaal).increment()
return opprettetGrunnlagspakke.grunnlagspakkeId
}

Expand Down Expand Up @@ -74,6 +85,8 @@ class GrunnlagspakkeService(
persistenceService.validerGrunnlagspakke(grunnlagspakkeId)
return persistenceService.lukkGrunnlagspakke(grunnlagspakkeId)
}


}

data class PersonIdOgPeriodeRequest(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.bidrag.grunnlag.controller

import io.micrometer.core.instrument.MeterRegistry
import no.nav.bidrag.commons.ExceptionLogger
import no.nav.bidrag.commons.web.HttpHeaderRestTemplate
import no.nav.bidrag.domain.enums.Formaal
Expand Down Expand Up @@ -81,7 +82,8 @@ import java.time.LocalDate
class GrunnlagControllerTest(
@Autowired val grunnlagspakkeRepository: GrunnlagspakkeRepository,
@Autowired val persistenceService: PersistenceService,
@Autowired val exceptionLogger: ExceptionLogger
@Autowired val exceptionLogger: ExceptionLogger,
@Autowired val meterRegistry: MeterRegistry
) {

private val restTemplate: HttpHeaderRestTemplate = Mockito.mock(HttpHeaderRestTemplate::class.java)
Expand All @@ -106,7 +108,7 @@ class GrunnlagControllerTest(
familieEfSakConsumer
)
private val grunnlagspakkeService: GrunnlagspakkeService =
GrunnlagspakkeService(persistenceService, oppdaterGrunnlagspakkeService)
GrunnlagspakkeService(persistenceService, oppdaterGrunnlagspakkeService, meterRegistry)
private val hentGrunnlagService: HentGrunnlagService = HentGrunnlagService(arbeidsforholdConsumer, enhetsregisterConsumer)
private val grunnlagController: GrunnlagController = GrunnlagController(grunnlagspakkeService, hentGrunnlagService)
private val mockMvc: MockMvc = MockMvcBuilders.standaloneSetup(grunnlagController)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package no.nav.bidrag.grunnlag.service

import io.micrometer.core.instrument.Counter
import io.micrometer.core.instrument.MeterRegistry
import io.micrometer.core.instrument.simple.SimpleMeterRegistry
import no.nav.bidrag.domain.enums.BarnType
import no.nav.bidrag.domain.enums.Formaal
import no.nav.bidrag.domain.enums.Sivilstandstype
Expand Down Expand Up @@ -49,7 +52,9 @@ import org.mockito.Captor
import org.mockito.InjectMocks
import org.mockito.Mock
import org.mockito.Mockito
import org.mockito.Spy
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.kotlin.any
import java.math.BigDecimal
import java.time.LocalDate

Expand All @@ -63,6 +68,9 @@ class GrunnlagspakkeServiceMockTest {
@Mock
private lateinit var persistenceServiceMock: PersistenceService

@Spy
private var meterRegistry: MeterRegistry = SimpleMeterRegistry()

@Mock
private lateinit var oppdaterGrunnlagspakkeService: OppdaterGrunnlagspakkeService

Expand Down

0 comments on commit ab5590a

Please sign in to comment.