Skip to content
Snippets Groups Projects
Commit aac57c06 authored by Charles-Francis Damedey's avatar Charles-Francis Damedey
Browse files

Jenkins: check linting and run tests

GitLab: #1
Change-Id: Iaa566609f2b6e02c1521aad91739525daaf2fcde
parent e14983ee
Branches
No related tags found
No related merge requests found
...@@ -5,13 +5,18 @@ COPY package*.json ./ ...@@ -5,13 +5,18 @@ COPY package*.json ./
RUN npm install RUN npm install
COPY . . COPY . .
# Stage 2: Final Image for running the server # Stage 2: Image for checking the linting
FROM base as lint
RUN npm install gts
CMD ["npm", "run", "lint"]
# Stage 3: Image for running the server
FROM base as server FROM base as server
EXPOSE 3000 EXPOSE 3000
ENV DATA_DIRECTORY=/data ENV DATA_DIRECTORY=/data
CMD ["npm", "run", "start"] CMD ["npm", "run", "start"]
# Stage 3: Final Image for running the tests # Stage 4: Image for running the tests
FROM base as test FROM base as test
ENV DATA_DIRECTORY=/tests/data ENV DATA_DIRECTORY=/tests/data
CMD ["npm", "run", "test"] CMD ["npm", "run", "test"]
...@@ -55,7 +55,14 @@ pipeline { ...@@ -55,7 +55,14 @@ pipeline {
userRemoteConfigs: [[refspec: '${GERRIT_REFSPEC}', url: 'https://${JAMI_GERRIT_URL}/jami-plugins-store']]] userRemoteConfigs: [[refspec: '${GERRIT_REFSPEC}', url: 'https://${JAMI_GERRIT_URL}/jami-plugins-store']]]
} }
} }
stage('lint') {
steps {
script {
docker.build("jami-plugins-store:${env.BUILD_ID}", "--target lint .")
sh "docker run -t --rm jami-plugins-store:${env.BUILD_ID}"
}
}
}
stage('test') { stage('test') {
steps { steps {
script { script {
......
...@@ -70,6 +70,8 @@ To install Docker please read this manual: https://docs.docker.com/engine/instal ...@@ -70,6 +70,8 @@ To install Docker please read this manual: https://docs.docker.com/engine/instal
The Docker needs a data directory to store the plugins. You need a /data/ folder in your repo. The API will look for the plugins in this folder. This is a temporary situation until we have a database implemented. The Docker needs a data directory to store the plugins. You need a /data/ folder in your repo. The API will look for the plugins in this folder. This is a temporary situation until we have a database implemented.
## Run the server in a docker container
Build a docker image: Build a docker image:
`docker build -t server-image --target server .` `docker build -t server-image --target server .`
...@@ -82,7 +84,7 @@ Run the docker container: ...@@ -82,7 +84,7 @@ Run the docker container:
To stop the container do CTRL + C in the terminal. To stop the container do CTRL + C in the terminal.
To run tests in the docker container ## To run tests in the docker container
Build the test image: Build the test image:
...@@ -92,6 +94,16 @@ Run the test image: ...@@ -92,6 +94,16 @@ Run the test image:
`docker run test-image` `docker run test-image`
## To check if the code has been linted correctly in the docker container
Build the lint image:
`docker build -t lint-image --target lint .`
Run the lint image:
`docker run lint-image`
# Linting via pre-commit hook # Linting via pre-commit hook
Set up the pre-commit hook: Set up the pre-commit hook:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment