-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (157 loc) · 6.31 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Build
on:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
ktlint:
name: Ktlint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'maven'
- name: Kjør ktlint
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mvn -B --no-transfer-progress antrun:run@ktlint --settings .m2/maven-settings.xml
build-jar-docker:
if: github.event.pull_request.draft == false
name: Bygg app/image, push til github
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
cache: 'maven'
- name: Bygg med maven u/test
env:
SONAR_PROJECTKEY: ${{ secrets.SONAR_PROJECTKEY }}
SONAR_LOGIN: ${{ secrets.SONAR_LOGIN }}
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B --no-transfer-progress package verify -Dmaven.test.skip=true --settings .m2/maven-settings.xml -DtrimStackTrace=false --file pom.xml -Dchangelist= -Dsha1=-$TIMESTAMP-$(echo $GITHUB_SHA | cut -c1-7)
- uses: nais/docker-build-push@v0
id: docker-push
if: github.event.pull_request.user.login != 'dependabot[bot]'
with:
team: teamfamilie
push_image: true
tag: ${{ github.sha }}
dockerfile: Dockerfile
docker_context: .
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
outputs:
image: ${{ steps.docker-push.outputs.image }}
run-junit:
if: github.event.pull_request.draft == false
name: Kjøre junit tester
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
- name: Bygg med maven
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn --version && mvn -B --no-transfer-progress verify --settings .m2/maven-settings.xml --file pom.xml
run-e2e:
if: github.event.pull_request.draft == false && github.event.pull_request.user.login != 'dependabot[bot]'
name: Kjør e2e tester
runs-on: ubuntu-latest
needs: build-jar-docker
permissions:
contents: "read"
id-token: "write"
steps:
- name: Login GAR
uses: nais/login@v0
with:
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
team: teamfamilie
- name: Checkout e2e tests
if: "!contains(github.event.head_commit.message, 'e2e skip')"
uses: actions/checkout@v4
with:
ref: "main"
repository: navikt/familie-tilbake-e2e
token: ${{ secrets.READER_TOKEN }}
path: tilbake-e2e
- name: Setter riktig familie-tilbake versjon i e2e tester hvis e2e bruker ghcr.io(deprecated)
if: "!contains(github.event.head_commit.message, 'e2e skip')"
run: sed -i 's/ghcr.io\/navikt\/familie-tilbake:latest/europe-north1-docker.pkg.dev\/nais-management-233d\/teamfamilie\/familie-tilbake:${{ github.sha }}/g' tilbake-e2e/e2e/docker-compose.yml
- name: Setter riktig familie-tilbake versjon i e2e tester
if: "!contains(github.event.head_commit.message, 'e2e skip')"
run: sed -i 's/europe-north1-docker.pkg.dev\/nais-management-233d\/teamfamilie\/familie-tilbake:latest/europe-north1-docker.pkg.dev\/nais-management-233d\/teamfamilie\/familie-tilbake:${{ github.sha }}/g' tilbake-e2e/e2e/docker-compose.yml
- name: Set up Java 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
cache: 'maven'
- name: Start alle apper (e2e)
env:
INTEGRASJONER_CLIENT_ID: ${{ secrets.INTEGRASJONER_CLIENT_ID }}
INTEGRASJONER_CLIENT_SECRET: ${{ secrets.INTEGRASJONER_CLIENT_SECRET }}
INTEGRASJONER_INFOTRYGD_KS_SCOPE: ${{ secrets.INTEGRASJONER_INFOTRYGD_KS_SCOPE }}
INTEGRASJONER_AAD_GRAPH_SCOPE: ${{ secrets.INTEGRASJONER_AAD_GRAPH_SCOPE }}
TILBAKE_CLIENT_ID: ${{ secrets.TILBAKE_CLIENT_ID }}
TILBAKE_CLIENT_SECRET: ${{ secrets.TILBAKE_CLIENT_SECRET }}
TILBAKE_FRONTEND_CLIENT_ID: ${{ secrets.TILBAKE_FRONTEND_CLIENT_ID }}
INTEGRASJONER_SCOPE: ${{ secrets.INTEGRASJONER_SCOPE }}
HISTORIKK_CLIENT_ID: ${{ secrets.HISTORIKK_CLIENT_ID }}
HISTORIKK_CLIENT_SECRET: ${{ secrets.HISTORIKK_CLIENT_SECRET }}
if: "!contains(github.event.head_commit.message, 'e2e skip')"
run: cd tilbake-e2e/e2e; ./e2e.sh
- name: Kjør tester (e2e)
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TILBAKE_CLIENT_ID: ${{ secrets.TILBAKE_CLIENT_ID }}
TILBAKE_CLIENT_SECRET: ${{ secrets.TILBAKE_CLIENT_SECRET }}
HISTORIKK_CLIENT_ID: ${{ secrets.HISTORIKK_CLIENT_ID }}
HISTORIKK_CLIENT_SECRET: ${{ secrets.HISTORIKK_CLIENT_SECRET }}
if: "!contains(github.event.head_commit.message, 'e2e skip')"
run: cd tilbake-e2e/autotest; mvn -B --no-transfer-progress --settings .m2/maven-settings.xml -Dtest="**" test
- name: Samle Docker-logs ved feil
if: failure()
uses: jwalton/gh-docker-logs@v2
with:
dest: './logs'
- name: Tar logs
if: failure()
run: tar cvzf ./logs.tgz ./logs
- name: Laste opp logs til GitHub
uses: actions/upload-artifact@master
if: failure()
with:
name: docker-logs-${{ github.run_number }}.tgz
path: ./logs.tgz
retention-days: 2