diff --git a/.github/workflows/deploy-feature-branch-gcp.yml b/.github/workflows/deploy-feature-branch-gcp.yml index 61d217da..e71dd8a9 100644 --- a/.github/workflows/deploy-feature-branch-gcp.yml +++ b/.github/workflows/deploy-feature-branch-gcp.yml @@ -3,13 +3,7 @@ run-name: Deploy feature branch ${{ github.ref_name }} by @${{ github.actor }} on: workflow_dispatch: -permissions: - contents: read - packages: write - env: - IMAGE_TAG: ${{ github.sha }} - IMAGE: ghcr.io/${{ github.repository }}/veilarbdialog PRINT_PAYLOAD: true concurrency: @@ -17,9 +11,12 @@ concurrency: cancel-in-progress: true jobs: - veilarbdialog: - name: Veilarbdialog - Test, build, push, deploy + build: + name: Veilarbdialog - Test, build, push runs-on: ubuntu-latest + permissions: + contents: write + id-token: write steps: - name: Checkout uses: actions/checkout@v4 @@ -31,22 +28,29 @@ jobs: cache: 'maven' - name: Veilarbdialog - Build maven artifacts run: mvn -B package - - uses: docker/login-action@v2 - name: Veilarbdialog - Docker login - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/build-push-action@v3 - name: Veilarbdialog - Push image + - name: Push docker image to GAR + uses: nais/docker-build-push@v0 + id: docker-build-push with: - context: . - push: true - tags: ${{ env.IMAGE }}:${{ env.IMAGE_TAG }} - - name: Veilarbdialog - Deploy application - uses: nais/deploy/actions/deploy@v1 + team: dab + identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} # Provided as Organization Secret + project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} # Provided as Organization Variable + outputs: + image: ${{ steps.docker-build-push.outputs.image }} + telemetry: ${{ steps.docker-build-push.outputs.telemetry }} + deploy: + name: Veilarbdialog - deploy to dev + needs: build + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Veilarbdialog - Deploy application to dev + uses: nais/deploy/actions/deploy@v2 env: - APIKEY: ${{ secrets.DAB_NAIS_DEPLOY_APIKEY }} CLUSTER: dev-gcp RESOURCE: nais/nais-dev-gcp.yaml - VAR: version=${{ env.IMAGE_TAG }} + VAR: image=${{ needs.build.outputs.image }} + TELEMETRY: ${{ needs.build.outputs.telemetry }} diff --git a/.github/workflows/deploy-gcp.yml b/.github/workflows/deploy-gcp.yml index 93dae424..560cc30c 100644 --- a/.github/workflows/deploy-gcp.yml +++ b/.github/workflows/deploy-gcp.yml @@ -5,13 +5,7 @@ on: branches: - main -permissions: - contents: read - packages: write - env: - IMAGE_TAG: ${{ github.sha }} - IMAGE: ghcr.io/${{ github.repository }}/veilarbdialog PRINT_PAYLOAD: true concurrency: @@ -33,18 +27,26 @@ jobs: cache: 'maven' - name: Build maven artifacts run: mvn -B package - - uses: docker/login-action@v2 - name: Docker login - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/build-push-action@v3 - name: Push image + - name: Slack Notification (test failure) + if: failure() + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_COLOR: danger + SLACK_USERNAME: Github Actions + SLACK_ICON: https://github.com/github.png?size=48 + SLACK_TITLE: 'Veilarbdialog: bygg feilet under deploy til prod' + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_MESSAGE: 'Commit-message til feilende deploy: ${{ github.event.head_commit.message }}' + - name: Push docker image to GAR + uses: nais/docker-build-push@v0 + id: docker-build-push with: - context: . - push: true - tags: ${{ env.IMAGE }}:${{ env.IMAGE_TAG }} + team: dab + identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} # Provided as Organization Secret + project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} # Provided as Organization Variable + outputs: + image: ${{ steps.docker-build-push.outputs.image }} + telemetry: ${{ steps.docker-build-push.outputs.telemetry }} deploy-to-dev: name: Deploy to dev @@ -54,24 +56,43 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Deploy application to dev - uses: nais/deploy/actions/deploy@v1 + uses: nais/deploy/actions/deploy@v2 env: - APIKEY: ${{ secrets.DAB_NAIS_DEPLOY_APIKEY }} CLUSTER: dev-gcp RESOURCE: nais/nais-dev-gcp.yaml - VAR: version=${{ env.IMAGE_TAG }} - + VAR: image=${{ needs.test-build-push.outputs.image }} + TELEMETRY: ${{ needs.test-build-push.outputs.telemetry }} + - name: Slack Notification (deploy failure) + if: failure() + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_COLOR: danger + SLACK_USERNAME: Github Actions + SLACK_ICON: https://github.com/github.png?size=48 + SLACK_TITLE: 'Veilarbdialog: deploy til dev feilet - deploy til prod ble ikke kjørt!' + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_MESSAGE: 'Commit-message til feilende deploy: ${{ github.event.head_commit.message }}' deploy-to-prod: name: Deploy to prod runs-on: ubuntu-latest - needs: [ deploy-to-dev ] + needs: [ test-build-push, deploy-to-dev ] steps: - name: Checkout uses: actions/checkout@v4 - name: Deploy application to prod - uses: nais/deploy/actions/deploy@v1 + uses: nais/deploy/actions/deploy@v2 env: - APIKEY: ${{ secrets.DAB_NAIS_DEPLOY_APIKEY }} CLUSTER: prod-gcp RESOURCE: nais/nais-prod-gcp.yaml - VAR: version=${{ env.IMAGE_TAG }} + VAR: image=${{ needs.test-build-push.outputs.image }} + TELEMETRY: ${{ needs.test-build-push.outputs.telemetry }} + - name: Slack Notification (deploy failure) + if: failure() + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_COLOR: danger + SLACK_USERNAME: Github Actions + SLACK_ICON: https://github.com/github.png?size=48 + SLACK_TITLE: 'Veilarbdialog: deploy til prod feilet' + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_MESSAGE: 'Commit-message til feilende deploy: ${{ github.event.head_commit.message }}' diff --git a/nais/nais-dev-gcp.yaml b/nais/nais-dev-gcp.yaml index 02414a55..8b2e95ca 100644 --- a/nais/nais-dev-gcp.yaml +++ b/nais/nais-dev-gcp.yaml @@ -7,7 +7,7 @@ metadata: labels: team: dab spec: - image: ghcr.io/navikt/veilarbdialog/veilarbdialog:{{version}} + image: {{image}} ingresses: - https://veilarbdialog.dev.nav.cloud.nais.io - https://veilarbdialog.intern.dev.nav.no diff --git a/nais/nais-prod-gcp.yaml b/nais/nais-prod-gcp.yaml index 0c53be38..37c618ce 100644 --- a/nais/nais-prod-gcp.yaml +++ b/nais/nais-prod-gcp.yaml @@ -7,7 +7,7 @@ metadata: labels: team: dab spec: - image: ghcr.io/navikt/veilarbdialog/veilarbdialog:{{version}} + image: {{image}} ingresses: - https://veilarbdialog.intern.nav.no port: 8080 diff --git a/pom.xml b/pom.xml index 820e4de5..79b955f6 100644 --- a/pom.xml +++ b/pom.xml @@ -389,7 +389,7 @@ - ${project.basedir}/src/main/java + ${project.basedir}/src/main/kotlin @@ -400,7 +400,7 @@ - ${project.basedir}/src/test/java + ${project.basedir}/src/test/kotlin diff --git a/src/main/java/no/nav/fo/veilarbdialog/veilarbdbutil/VeilarbDialogResultSet.kt b/src/main/kotlin/no/nav/veilarbdialog/veilarbdbutil/VeilarbDialogResultSet.kt similarity index 100% rename from src/main/java/no/nav/fo/veilarbdialog/veilarbdbutil/VeilarbDialogResultSet.kt rename to src/main/kotlin/no/nav/veilarbdialog/veilarbdbutil/VeilarbDialogResultSet.kt diff --git a/src/main/java/no/nav/fo/veilarbdialog/veilarbdbutil/VeilarbDialogSqlParameterSource.kt b/src/main/kotlin/no/nav/veilarbdialog/veilarbdbutil/VeilarbDialogSqlParameterSource.kt similarity index 100% rename from src/main/java/no/nav/fo/veilarbdialog/veilarbdbutil/VeilarbDialogSqlParameterSource.kt rename to src/main/kotlin/no/nav/veilarbdialog/veilarbdbutil/VeilarbDialogSqlParameterSource.kt diff --git a/src/test/java/no/nav/fo/veilarbdialog/TestApplication.java b/src/test/java/no/nav/fo/veilarbdialog/TestApplication.java deleted file mode 100644 index d6932d4a..00000000 --- a/src/test/java/no/nav/fo/veilarbdialog/TestApplication.java +++ /dev/null @@ -1,43 +0,0 @@ -package no.nav.fo.veilarbdialog; - -import lombok.extern.slf4j.Slf4j; -import no.nav.fo.veilarbdialog.mock_nav_modell.MockBruker; -import no.nav.fo.veilarbdialog.mock_nav_modell.MockNavService; -import no.nav.fo.veilarbdialog.mock_nav_modell.MockVeileder; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; -import org.springframework.kafka.test.context.EmbeddedKafka; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.jdbc.Sql; - -@Disabled("Comment out @Ignore to run the application locally.") -@SpringBootTest -@ActiveProfiles("local") -@EnableAutoConfiguration -@EmbeddedKafka -@AutoConfigureWireMock -@Slf4j -class TestApplication { - - @Test - @Sql("/db/testdata/slett_alle_dialoger.sql") - @java.lang.SuppressWarnings("squid:S2925") - void main() - throws InterruptedException { - - System.setProperty("VEILARB_KASSERING_IDENTER", "NAVIDENT"); // See KasserRessurs. - System.setProperty("spring.profiles.active", "local"); - Assertions.assertThatCode(Application::main).doesNotThrowAnyException(); - MockBruker happyBruker = MockNavService.createHappyBruker(); - MockVeileder veileder = MockNavService.createVeileder(happyBruker); - log.info("Wiremock og mock tokens satt opp for bruker {} og veileder {}", happyBruker, veileder); - log.info("Application ready"); - Thread.sleep(Long.MAX_VALUE); - - } - -}