Skip to content

Commit

Permalink
Merge pull request #127 from abes-esr/test
Browse files Browse the repository at this point in the history
merge test to main
  • Loading branch information
SamuelQuetin authored Dec 2, 2024
2 parents beab2c4 + 040fb6c commit 6709669
Show file tree
Hide file tree
Showing 13 changed files with 260 additions and 23 deletions.
3 changes: 0 additions & 3 deletions .env.local

This file was deleted.

3 changes: 1 addition & 2 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
VUE_APP_PERISCOPE_V1_API_URL=
VUE_APP_PERISCOPE_V2_API_URL=
VUE_APP_TIMELINE_PERISCOPE_V1=
VUE_APP_WS_APICOM=
VUE_APP_WS_APICOM=
3 changes: 1 addition & 2 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
VUE_APP_PERISCOPE_V1_API_URL=
VUE_APP_PERISCOPE_V2_API_URL=
VUE_APP_TIMELINE_PERISCOPE_V1=
VUE_APP_WS_APICOM=
VUE_APP_WS_APICOM=
47 changes: 47 additions & 0 deletions .github/workflows/build-test-pubtodockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "build-test-pubtodockerhub"

# IMPORTANT : personnalisez cette variable pour que les images
# de votre application soient pousées sur dockerhub
# dans le repository ayant ce nom
# exemple, si vous indiquez : abesesr/periscope-front
# alors l'image sera poussée sur https://hub.docker.com/r/abesesr/periscope-front
env:
DOCKERHUB_IMAGE_PREFIX: abesesr/periscope

on:
push:
paths-ignore:
- '**.md'
- '.github/**'
workflow_dispatch:

jobs:
build-test-pubtodockerhub:
runs-on: ubuntu-latest
steps:


- name: "Build: checkout source code"
uses: actions/checkout@v2
- name: "Build: build docker image"
run: |
docker build . -t localimage:latest
- name: "Push: prepare version from git tags/branchs"
id: docker_tag_meta
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKERHUB_IMAGE_PREFIX }}
- name: "Push: login to DockerHub"
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/'))
run: |
echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
- name: "Push: push docker image"
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/'))
run: |
DOCKER_TAGS="${{ steps.docker_tag_meta.outputs.tags }}"
for DOCKER_TAG in $DOCKER_TAGS
do
# publication de l'image pour le front
docker build . --target front-image -t ${DOCKER_TAG}-front
docker push ${DOCKER_TAG}-front
done
92 changes: 92 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: 'Create release'

on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'Version de la release (semver)'
required: true
default: 'x.x.x'

jobs:
create-release:
runs-on: ubuntu-latest

steps:
- name: "Calculate versions"
id: calculate-version
run: |
releaseVersion=${{ inputs.releaseVersion }}
# Séparer les parties de la version
major=$(echo "${releaseVersion}" | cut -d. -f1)
minor=$(echo "${releaseVersion}" | cut -d. -f2)
patch=$(echo "${releaseVersion}" | cut -d. -f3)
# Incrémenter la partie patch
patch=$((patch + 1))
# Reconstituer la version snapshot
snapshotVersion="${major}.${minor}.${patch}-SNAPSHOT"
echo "${snapshotVersion}"
echo "snapshotVersion=${snapshotVersion}" >> $GITHUB_OUTPUT
echo "content :"
cat "$GITHUB_OUTPUT"
- name: 'Checkout source code'
uses: 'actions/checkout@v3'
with:
fetch-depth: '0' # to get all the tags locally
# https://stackoverflow.com/questions/67550727/push-event-doesnt-trigger-workflow-on-push-paths-github-actions
token: ${{ secrets.TOKEN_GITHUB_FOR_GITHUB_ACTION }}


- name: 'Verify release is created only on "main" or "master" git branch'
run: |
CURRENT_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo $CURRENT_GIT_BRANCH
[[ "$CURRENT_GIT_BRANCH" == "main" || "$CURRENT_GIT_BRANCH" == "master" ]] && exit 0 || exit 1
- name: 'Verify version is semver formatted (X.X.X)'
env:
NEW_TAG: ${{ github.event.inputs.releaseVersion }}
NEW_SNAPSHOT_TAG: ${{ steps.calculate-version.outputs.snapshotVersion }}
run: |
echo $NEW_TAG | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$'
echo $NEW_SNAPSHOT_TAG | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT$'
- name: 'Verify version is not already used as a git tag'
env:
NEW_TAG: ${{ github.event.inputs.releaseVersion }}
run: |
[[ "$(git tag --list | grep $NEW_TAG)" == "" ]] && exit 0 || exit 1
- name: 'Generate the new version (patch few files + git tag)'
env:
NEW_TAG: ${{ github.event.inputs.releaseVersion }}
NEW_SNAPSHOT_TAG: ${{ steps.calculate-version.outputs.snapshotVersion }}
run: |
# préparation de la release qui va :
# - modifier le numéro de version dans le package.json du projet (et éventuellement dans le README.md ou d'autres fichiers, cf le sed)
# - créer un tag git du numéro de version en question
# - pousser le tout sur le dépôt github et faire la fusion avec la branche develop
git config --global user.email "github-action@noreply"
git config --global user.name "Github Action"
npm config set tag-version-prefix ''
npm config set git-tag-version false
npm version $NEW_TAG
sed -i "s#Version: [0-9]+\.[0-9]+\.[0-9]+#Version: $NEW_TAG#g" README.md
git add .
git commit -m "Version $NEW_TAG"
git tag $NEW_TAG
git push origin $NEW_TAG
git commit --amend -m "Version $NEW_TAG [skip ci]"
git push
# merge la préparation de la nouvelle version sur develop
# (version X.X.X-SNAPSHOT)
git switch develop
git merge main -m "Merge main to develop [skip ci]"
npm version $NEW_SNAPSHOT_TAG
sed -i "s#Version: [0-9]+\.[0-9]+\.[0-9]+#Version: $NEW_SNAPSHOT_TAG#g" README.md
git add .
git commit -m "Version $NEW_SNAPSHOT_TAG [skip ci]"
git push
- name: 'Create the github release'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.releaseVersion }}
generate_release_notes: true
token: ${{ secrets.TOKEN_GITHUB_FOR_GITHUB_ACTION }}
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
###
# Phase de compilation de l'appli vuejs
FROM node:20.15.0 as build-image
WORKDIR /build/
# Mise en cache docker pour le téléchargement
# des dépendances npm (répertoire node_modules/)
COPY ./package*.json /build/
# si on a un node_modules/ local on peut décommenter la ligne suivante pour
# éviter que npm retélécharge toutes les dépendances
#COPY ./node_modules/ /build/node_modules/
RUN npm install

# Compilation du TS en JS compilé
# en injectant des placeholders dans les variables .env de vuejs
# (cf le fichier docker/vuejs_env_placeholder) pour pouvoir créer des conteneurs
# en dev, test, prod ou en local en passant les valeurs de ce .env
# via des variables d'environement Docker
# Par exemple, cela permet d'injecter l'URL où se trouvent les API (back) différente
# si on est en dev, test ou prod ou local.
RUN echo 'Copy des fichier env'
COPY ./docker/vuejs_env_placeholder /build/.env
#COPY ./.browserslistrc /build/.browserslistrc
#COPY ./.eslintrc.js /build/.eslintrc.js
RUN echo 'Copy des fichier js'
COPY ./*.js /build/
RUN echo 'Copy des fichier json'
COPY ./*.json /build/
RUN echo 'Copy des fichier src'
COPY ./src/ /build/src/
COPY ./src/plugins/ /build/src/plugins/
RUN echo 'Copy des fichier public'
COPY ./*.html /build/
COPY ./public/ /build/public/
RUN npm run build






###
# Serveur web (nginx) pour exec l'appli vuejs
FROM nginx:1.20.2 as front-image
COPY --from=build-image /build/dist/ /usr/share/nginx/html.orig/
COPY ./docker/nginx-default.conf /etc/nginx/conf.d/default.conf
COPY ./docker/docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]
EXPOSE 80
30 changes: 30 additions & 0 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Paramètres par défaut du conteneur
export PERISCOPE_FRONT_API_BASEURL=${PERISCOPE_FRONT_API_BASEURL:='http://localhost:8081/'}
export PERISCOPE_FRONT_TIMELINE_URL=${PERISCOPE_FRONT_TIMELINE_URL:='http://localhost:8081/'}
export PERISCOPE_FRONT_APICOM_URL=${PERISCOPE_FRONT_APICOM_URL:='http://localhost:8081/'}


# Remplace les placeholders dans le code généré en prod
# PERISCOPE_PLACEHOLDER_VUE_APP_ROOT_API
# On va remplacer les placeholders depuis les JS originales
echo "-> Remplacement des placeholders venant du .env de vuejs dans la destination /usr/share/nginx/html/"
echo "-> PERISCOPE_FRONT_API_BASEURL=${PERISCOPE_FRONT_API_BASEURL}"
echo "-> PERISCOPE_FRONT_TIMELINE_URL=${PERISCOPE_FRONT_TIMELINE_URL}"
echo "-> PERISCOPE_FRONT_APICOM_URL=${PERISCOPE_FRONT_APICOM_URL}"
rm -rf /usr/share/nginx/html/
cp -rf /usr/share/nginx/html.orig/ /usr/share/nginx/html/
sed -i \
"s#PLACEHOLDER_VUE_APP_PERISCOPE_V2_API_URL#${PERISCOPE_FRONT_API_BASEURL}#g" \
/usr/share/nginx/html/js/*
sed -i \
"s#PLACEHOLDER_VUE_APP_TIMELINE_PERISCOPE_V1#${PERISCOPE_FRONT_TIMELINE_URL}#g" \
/usr/share/nginx/html/js/*
sed -i \
"s#PLACEHOLDER_VUE_APP_WS_APICOM#${PERISCOPE_FRONT_APICOM_URL}#g" \
/usr/share/nginx/html/js/*


# execute nginx (cf CMD dans Dockerfile)
exec "$@"
19 changes: 19 additions & 0 deletions docker/nginx-default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# active gzip sur les retours des requetes http
# pour optimiser les perf pour les chargements
# initiaux des pages de l'appli
gzip on;
gzip_types *;

server {
listen 80;
server_name localhost;

# subtilité pour vuejs
# toutes les URL doivent charger la même page
# https://zestedesavoir.com/forums/sujet/15137/docker-nginx-et-vuejs-avec-un-prefix/
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html?$args;
}
}
7 changes: 7 additions & 0 deletions docker/vuejs_env_placeholder
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# .env pour vuejs qui permet de positionner un placeholder
# à la place de l'URL de l'API de PERISCOPE-api
# pour injecter une URL de l'API au moment de la création du conteneur
# et éviter ainsi d'avoir une URL de l'API en static dans l'image docker
VUE_APP_PERISCOPE_V2_API_URL=PLACEHOLDER_VUE_APP_PERISCOPE_V2_API_URL
VUE_APP_TIMELINE_PERISCOPE_V1=PLACEHOLDER_VUE_APP_TIMELINE_PERISCOPE_V1
VUE_APP_WS_APICOM=PLACEHOLDER_VUE_APP_WS_APICOM
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"@mdi/font": "^5.9.55",
"axios": "^0.21.2",
"axios": "1.7.4",
"core-js": "^3.9.0",
"cosmiconfig": "^7.0.0",
"js-cookie": "^2.2.1",
Expand Down
5 changes: 2 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Vue from 'vue';
import App from './App.vue';
import index from './router';
import store from './store/store';
import vuetify from './plugins/vuetify';
import 'roboto-fontface/css/roboto/roboto-fontface.css';
Expand All @@ -17,7 +16,7 @@ Vue.config.ignoredElements = ['Regions'];

// Handle all Vue errors
//Vue.config.errorHandler = (error, vm, info) => Logger.error(error.message, error.constructor.name, vm, info);

//console.log(process.env.VUE_APP_PERISCOPE_V2_API_URL);
Vue.use(VueClipboard); // Plugin pour l'historique
// utilisation de piwik/matomo uniquement en production
if (process.env.VUE_APP_PERISCOPE_V2_API_URL.includes('periscope.sudoc')) {
Expand All @@ -42,7 +41,7 @@ if (process.env.VUE_APP_PERISCOPE_V2_API_URL.includes('periscope.sudoc')) {
Vue.component('downloadCsv', JsonCSV); // Plugin d'export au format CSV

const vue = new Vue({
router: index,
router: router,
store,
vuetify,
render: (h) => h(App),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,9 @@
<v-row justify="center">
<v-col sm="10">
<!--Elements-->
<v-row justify="center">
<v-col xs="6" sm="3" class="margin-v-col-accueil">
<v-checkbox @change="updateCheckboxes()" v-for="m in 5" :key="m" v-model="regions[m - 1].value" :label="regions[m - 1].text" hide-details class="margin-v-checkbox-accueil"></v-checkbox>
</v-col>
<v-col xs="6" sm="3" class="margin-v-col-accueil">
<v-checkbox @change="updateCheckboxes()" v-for="m in 5" :key="m" v-model="regions[m + 4].value" :label="regions[m + 4].text" hide-details class="margin-v-checkbox-accueil"></v-checkbox>
</v-col>
<v-col xs="6" sm="3" class="margin-v-col-accueil">
<v-checkbox @change="updateCheckboxes()" v-for="m in 5" :key="m" v-model="regions[m + 9].value" :label="regions[m + 9].text" hide-details class="margin-v-checkbox-accueil"></v-checkbox>
</v-col>
<v-col xs="6" sm="3" class="margin-v-col-accueil">
<v-checkbox @change="updateCheckboxes()" v-for="m in 5" :key="m" v-model="regions[m + 14].value" :label="regions[m + 14].text" hide-details class="margin-v-checkbox-accueil"></v-checkbox>
<v-row class='mb-5'>
<v-col v-for="region in regions" :key="region.id" cols="3" class="d-flex justify-start align-center pa-0">
<v-checkbox @change="updateCheckboxes()" v-model="region.value" :label="region.text" hide-details class="margin-v-checkbox-accueil"></v-checkbox>
</v-col>
</v-row>
<!--Internal BlocOperator-->
Expand Down Expand Up @@ -353,3 +344,10 @@ export default class ComponentPlanConservationRegions extends Vue {
}
}
</script>
<style>
.checkbox-grid {
display: grid;
grid-template-columns: repeat(4, 1fr); /* 4 colonnes de même taille */
grid-gap: 10px; /* Espace entre les éléments */
}
</style>
Empty file removed tests/files/holdingsResult.json
Empty file.

0 comments on commit 6709669

Please sign in to comment.