Skip to content

Commit

Permalink
war -> jar
Browse files Browse the repository at this point in the history
  • Loading branch information
oplekal committed Dec 13, 2023
1 parent 76f78fc commit e432429
Show file tree
Hide file tree
Showing 66 changed files with 286 additions and 27,186 deletions.
330 changes: 182 additions & 148 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,168 +10,202 @@ jobs:
build-and-test-eperusteet-service:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# - uses: actions/checkout@v3

- name: workflow number debug
run: echo "${{ github.run_id }} ${{ github.run_number }} ${{ github.run_attempt }}"
# - name: workflow number debug
# run: echo "${{ github.run_id }} ${{ github.run_number }} ${{ github.run_attempt }}"

# - name: Set up JDK 11
# uses: actions/setup-java@v3
# with:
# java-version: '11'
# distribution: 'corretto'

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

# - name: Build with Maven
# run: |
# cd eperusteet/eperusteet-service
# mvn clean verify --batch-mode

# - name: Cache eperusteet-service build results
# uses: actions/cache@v3
# id: restore-service-build
# with:
# path: eperusteet/eperusteet-service/target
# key: ${{ github.run_number }}-${{ github.run_attempt }}-service
- name: Checkout source
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'corretto'

- name: Cache Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-cache-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: |
cd eperusteet/eperusteet-service
mvn clean verify --batch-mode
- name: Cache eperusteet-service build results
uses: actions/cache@v3
id: restore-service-build
with:
path: eperusteet/eperusteet-service/target
key: ${{ github.run_number }}-${{ github.run_attempt }}-service

build-and-test-eperusteet-ui:
runs-on: ubuntu-latest
env:
EPERUSTEET_SPECFILE: https://raw.githubusercontent.com/Opetushallitus/eperusteet/${{ github.ref_name }}/generated/eperusteet.spec.json
steps:
- uses: actions/checkout@v3

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

- name: Set up Node 10
uses: actions/setup-node@v3
with:
node-version: '10'

- name: Cache Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-cache-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Print yarn cache directory path
id: yarn-cache-dir-path
distribution: 'adopt'
cache: 'maven'
- name: Build
run: |
yarn cache dir
echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn
uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- name: Print npm cache directory
id: npm-cache-dir
run: |
npm config get cache
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache npm
uses: actions/cache@v3
cd eperusteet/eperusteet-service
mvn clean verify -B -DskipTests
- name: Upload eperusteet-service-jar
uses: actions/upload-artifact@v3
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache yo npm
uses: actions/cache@v3
with:
path: eperusteet/eperusteet/eperusteet-app/yo/node_modules
key: ${{ runner.os }}-nodeyo-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-nodeyo-
- 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-ui/tree/${{ github.ref_name }})" == "200" ]
then
echo branch found
echo "EPERUSTEET_UI_GIT_BRANCH=-b ${{ github.ref_name }}" >> $GITHUB_ENV
else
echo "EPERUSTEET_UI_GIT_BRANCH=" >> $GITHUB_ENV
echo branch not found
fi
- name: Build with Maven
run: |
git clone ${{ env.EPERUSTEET_UI_GIT_BRANCH }} --recurse-submodules --depth 1 https://github.com/Opetushallitus/eperusteet-ui.git
export EPERUSTEET_SERVICE_DIR=${{ github.workspace }}/eperusteet/eperusteet-service
name: eperusteet-service-jar
path: eperusteet/eperusteet-service/target/eperusteet-service.jar
# build-and-test-eperusteet-ui:
# runs-on: ubuntu-latest
# env:
# EPERUSTEET_SPECFILE: https://raw.githubusercontent.com/Opetushallitus/eperusteet/${{ github.ref_name }}/generated/eperusteet.spec.json
# steps:
# - uses: actions/checkout@v3

# - name: Set up JDK 11
# uses: actions/setup-java@v3
# with:
# java-version: '11'
# distribution: 'corretto'

# - name: Set up Node 10
# uses: actions/setup-node@v3
# with:
# node-version: '10'

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

# - name: Print yarn cache directory path
# id: yarn-cache-dir-path
# run: |
# yarn cache dir
# echo "::set-output name=dir::$(yarn cache dir)"

# - name: Cache yarn
# uses: actions/cache@v3
# with:
# path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

# - name: Print npm cache directory
# id: npm-cache-dir
# run: |
# npm config get cache
# echo "::set-output name=dir::$(npm config get cache)"

# - name: Cache npm
# uses: actions/cache@v3
# with:
# path: ${{ steps.npm-cache-dir.outputs.dir }}
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-

# - name: Cache yo npm
# uses: actions/cache@v3
# with:
# path: eperusteet/eperusteet/eperusteet-app/yo/node_modules
# key: ${{ runner.os }}-nodeyo-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-nodeyo-

# - 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-ui/tree/${{ github.ref_name }})" == "200" ]
# then
# echo branch found
# echo "EPERUSTEET_UI_GIT_BRANCH=-b ${{ github.ref_name }}" >> $GITHUB_ENV
# else
# echo "EPERUSTEET_UI_GIT_BRANCH=" >> $GITHUB_ENV
# echo branch not found
# fi

# - name: Build with Maven
# run: |
# git clone ${{ env.EPERUSTEET_UI_GIT_BRANCH }} --recurse-submodules --depth 1 https://github.com/Opetushallitus/eperusteet-ui.git
# export EPERUSTEET_SERVICE_DIR=${{ github.workspace }}/eperusteet/eperusteet-service

cd eperusteet-ui
yarn install --silent
cd eperusteet-frontend-utils/vue
yarn install --silent
yarn gen:api:eperusteet
rm -rf node_modules
cd ../..
echo "----------eperusteet-ui:n viimeisimman commitin sha----------"
git rev-parse HEAD
yarn run build
cp -R dist/ ../eperusteet/eperusteet-app/dist
cd ..
cd ${ARTIFACT_NAME}/eperusteet-app
mvn clean verify --batch-mode
- name: Cache eperusteet-app build results
uses: actions/cache@v3
id: restore-app-build
with:
path: eperusteet/eperusteet-app/target
key: ${{ github.run_number }}-${{ github.run_attempt }}-app
# cd eperusteet-ui
# yarn install --silent
# cd eperusteet-frontend-utils/vue
# yarn install --silent
# yarn gen:api:eperusteet
# rm -rf node_modules
# cd ../..
# echo "----------eperusteet-ui:n viimeisimman commitin sha----------"
# git rev-parse HEAD
# yarn run build
# cp -R dist/ ../eperusteet/eperusteet-app/dist
# cd ..
# cd ${ARTIFACT_NAME}/eperusteet-app
# mvn clean verify --batch-mode

# - name: Cache eperusteet-app build results
# uses: actions/cache@v3
# id: restore-app-build
# with:
# path: eperusteet/eperusteet-app/target
# key: ${{ github.run_number }}-${{ github.run_attempt }}-app

build-image:
needs: [build-and-test-eperusteet-service, build-and-test-eperusteet-ui]
needs: [build-and-test-eperusteet-service]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Get eperusteet-service build results
uses: actions/cache@v3
id: restore-service-build
- name: Checkout source
uses: actions/checkout@v3
- name: Download eperusteet-service-jar
uses: actions/download-artifact@v3
with:
path: eperusteet/eperusteet-service/target
key: ${{ github.run_number }}-${{ github.run_attempt }}-service

- name: Get eperusteet-app build results
uses: actions/cache@v3
id: restore-app-build
with:
path: eperusteet/eperusteet-app/target
key: ${{ github.run_number }}-${{ github.run_attempt }}-app

- name: Build image
run: |
name: eperusteet-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
cd ${ARTIFACT_NAME}
mv ${ARTIFACT_NAME}-service/target/${ARTIFACT_NAME}-service.war $DOCKER_BUILD_DIR/artifact/${ARTIFACT_NAME}-service.war
mv ${ARTIFACT_NAME}-app/target/${ARTIFACT_NAME}-app.war $DOCKER_BUILD_DIR/artifact/${ARTIFACT_NAME}-app.war
cp -vr src/main/resources/oph-configuration $DOCKER_BUILD_DIR/config/
cp -vr src/main/resources/tomcat $DOCKER_BUILD_DIR/config/
cd ..
export BASE_IMAGE="baseimage-war-tomcat8-openjdk11:master"
export BASE_IMAGE="baseimage-fatjar-openjdk11:master"
cp eperusteet-service.jar $DOCKER_BUILD_DIR/artifact/eperusteet.jar
cp -vr $ARTIFACT_NAME/src/main/resources/oph-configuration $DOCKER_BUILD_DIR/config/
./ci-tools/common/pull-image.sh
./ci-tools/github-build/build-war.sh ${ARTIFACT_NAME}
./ci-tools/github-build/upload-image.sh ${ARTIFACT_NAME}
./ci-tools/github-build/build-fatjar.sh $ARTIFACT_NAME
./ci-tools/github-build/upload-image.sh $ARTIFACT_NAME
# - uses: actions/checkout@v3

# - name: Get eperusteet-service build results
# uses: actions/cache@v3
# id: restore-service-build
# with:
# path: eperusteet/eperusteet-service/target
# key: ${{ github.run_number }}-${{ github.run_attempt }}-service

# - name: Get eperusteet-app build results
# uses: actions/cache@v3
# id: restore-app-build
# with:
# path: eperusteet/eperusteet-app/target
# key: ${{ github.run_number }}-${{ github.run_attempt }}-app

# - name: Build image
# run: |
# git clone https://github.com/Opetushallitus/ci-tools.git
# source ci-tools/common/setup-tools.sh

# cd ${ARTIFACT_NAME}
# mv ${ARTIFACT_NAME}-service/target/${ARTIFACT_NAME}-service.war $DOCKER_BUILD_DIR/artifact/${ARTIFACT_NAME}-service.war
# mv ${ARTIFACT_NAME}-app/target/${ARTIFACT_NAME}-app.war $DOCKER_BUILD_DIR/artifact/${ARTIFACT_NAME}-app.war
# cp -vr src/main/resources/oph-configuration $DOCKER_BUILD_DIR/config/
# cp -vr src/main/resources/tomcat $DOCKER_BUILD_DIR/config/
# cd ..
# export BASE_IMAGE="baseimage-war-tomcat8-openjdk11:master"
# ./ci-tools/common/pull-image.sh
# ./ci-tools/github-build/build-war.sh ${ARTIFACT_NAME}
# ./ci-tools/github-build/upload-image.sh ${ARTIFACT_NAME}
Loading

0 comments on commit e432429

Please sign in to comment.