-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (114 loc) · 4.76 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
name: Eperusteet-ylops build
on: [workflow_dispatch, push]
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
EPERUSTEET_SERVICE_DIR: ${{ github.workspace }}/eperusteet/eperusteet/eperusteet-service
AMOSAA_SERVICE_DIR: ${{ github.workspace }}/eperusteet-amosaa/eperusteet-amosaa-service
ARTIFACT_NAME: eperusteet-ylops
jobs:
build-and-test-eperusteet-ylops-ui:
runs-on: ubuntu-latest
env:
EPERUSTEET_YLOPS_SPECFILE: https://raw.githubusercontent.com/Opetushallitus/eperusteet-ylops/${{ github.ref_name }}/generated/ylops.spec.json
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Node 21
uses: actions/setup-node@v4
with:
node-version: '21.7.3'
- name: Enable corepack for nodejs
run: corepack enable
- name: Check if UI has same branch
id: ui_branch_status
run: |
if [ "$(curl -s -o /dev/null -I -w '%{http_code}' https://github.com/Opetushallitus/eperusteet-ylops-ui/tree/${{ github.ref_name }})" == "200" ]
then
echo branch found
echo "EPERUSTEET_YLOPS_UI_GIT_BRANCH=-b ${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "EPERUSTEET_YLOPS_UI_GIT_BRANCH=" >> $GITHUB_ENV
echo branch not found
fi
- name: Build with Maven
run: |
git clone ${{ env.EPERUSTEET_YLOPS_UI_GIT_BRANCH }} --recurse-submodules --depth 1 https://github.com/Opetushallitus/eperusteet-ylops-ui.git
git clone --depth=1 https://github.com/Opetushallitus/eperusteet
git clone --depth=1 https://github.com/Opetushallitus/eperusteet-amosaa
cd eperusteet-ylops-ui
yarn install --silent
cd eperusteet-frontend-utils/vue
yarn install --silent
yarn gen:api
rm -rf node_modules
cd ../..
echo "----------ui:n viimeisimman commitin sha----------"
git rev-parse HEAD
yarn build
- name: Upload eperusteet-ylops-ui
uses: actions/upload-artifact@v4
with:
name: eperusteet-ylops-ui
path: eperusteet-ylops-ui/dist/
build-and-test-eperusteet-ylops-service:
needs: [build-and-test-eperusteet-ylops-ui]
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Download ui
uses: actions/download-artifact@v4
with:
name: eperusteet-ylops-ui
path: eperusteet-ylops-service/src/main/resources/static/ui
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Build with Maven
env:
GITHUB_USERNAME: ${{ secrets.GITHUB_USERNAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd eperusteet-ylops-service
mvn clean verify --batch-mode -Pit
- name: Upload Coverage to Code Climate
if: ${{ github.ref_name == 'master' }}
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
cd eperusteet-ylops-service/src/main/java
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
./cc-test-reporter format-coverage -t jacoco --add-prefix src/main/java/ ../../../target/jacoco/jacoco.xml
./cc-test-reporter upload-coverage
- name: Upload eperusteet-ylops-service-jar
uses: actions/upload-artifact@v4
with:
name: eperusteet-ylops-service-jar
path: eperusteet-ylops-service/target/eperusteet-ylops-service.jar
build-image:
needs: [build-and-test-eperusteet-ylops-service]
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Download service-jar
uses: actions/download-artifact@v4
with:
name: eperusteet-ylops-service-jar
- name: Build Docker Conainer
shell: bash
run: |
git clone https://github.com/Opetushallitus/ci-tools.git
source ci-tools/common/setup-tools.sh
export BASE_IMAGE="baseimage-fatjar-openjdk17:master"
cp ${ARTIFACT_NAME}-service.jar $DOCKER_BUILD_DIR/artifact/${ARTIFACT_NAME}.jar
cp -vr src/main/resources/oph-configuration $DOCKER_BUILD_DIR/config/
./ci-tools/common/pull-image.sh
./ci-tools/github-build/build-fatjar.sh $ARTIFACT_NAME
./ci-tools/github-build/upload-image.sh $ARTIFACT_NAME