Skip to content
Snippets Groups Projects
Commit 7fab0a73 authored by michael.minelli's avatar michael.minelli
Browse files

Merge branch 'v2.0.0' into main

parents 065c4f9b 341fe00c
No related branches found
No related tags found
No related merge requests found
Showing
with 350 additions and 188 deletions
variables: variables:
GIT_SUBMODULE_STRATEGY: recursive GIT_SUBMODULE_STRATEGY: recursive
GIT_SUBMODULE_FORCE_HTTPS: "true" GIT_SUBMODULE_FORCE_HTTPS: "true"
DOCKER_HOST: tcp://docker:2375 DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: DOCKER_TLS_CERTDIR:
DOCKER_DRIVER: overlay2 DOCKER_DRIVER: overlay2
DOCKERFILE: Dockerfile_ExerciceChecker
PLATFORMS: linux/amd64,linux/arm64/v8
CHECKER_PROJECT_FOLDER: ExerciceChecker
stages: PROJECT_NAME: DojoExerciseChecker
- build
- release
default: VERSION_DEV_SUFFIX: '-dev'
tags:
- docker GITLAB_API_PROJECT_URL: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}
image: docker:latest
services: DOCKERFILE: Dockerfile_ExerciseChecker
- docker:dind DOCKER_PLATFORMS: linux/amd64,linux/arm64/v8
before_script:
PROJECT_FOLDER: ExerciseChecker
.get_version:
script:
- IS_DEV=$([[ $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]] && echo false || echo true)
- VERSION=$(jq -r .version $PROJECT_FOLDER/package.json)$([[ $IS_DEV == true ]] && echo $VERSION_DEV_SUFFIX || echo '')
- DOCKER_LOCAL_IMAGE_PATH=$ARTIFACTS_FOLDER/$VERSION.tar
.get_packages_url:
script:
- PACKAGE_URL_DOCKER_IMAGE="${PACKAGE_REGISTRY_URL}/${VERSION}/${PROJECT_NAME}.tar"
.init_dind_script:
script:
# Install dependencies
- apk update - apk update
- apk add git - apk add git
- apk add jq - apk add jq
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY # Init docker buildx
- docker login -u $DOCKER_REGISTRY_USER -p $DOCKER_REGISTRY_PASSWORD $DOCKER_REGISTRY
- docker buildx create --use - docker buildx create --use
- > # Get version from package.json
VERSION=$(jq -r .version $CHECKER_PROJECT_FOLDER/package.json) - !reference [.get_version, script]
- > - CONTAINER_IMAGE=$DOCKER_REGISTRY_IMAGE:$VERSION
CONTAINER_IMAGE=$CI_REGISTRY_IMAGE:$VERSION-dev
build: .build_script:
stage: build
tags:
- build
script: script:
- !reference [ .init_dind_script, script ]
- mkdir -p $ARTIFACTS_FOLDER
# Download secure files
- apk add curl - apk add curl
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | sh - curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | sh
- mv .secure_files/env $CHECKER_PROJECT_FOLDER/.env - mv .secure_files/env_$VERSION $PROJECT_FOLDER/.env
# Need to build for each platform separately because of multi-stage builds (docker buildx don't use cache same way as docker build) # Need to build for each platform separately because of multi-stage builds (docker buildx don't use cache same way as docker build)
- > - >
platform_array=$(echo $PLATFORMS | tr "," "\n"); platform_array=$(echo $DOCKER_PLATFORMS | tr "," "\n");
for platform in $platform_array; do for platform in $platform_array; do
echo "Buildind for : $platform" echo "Buildind for : $platform"
docker buildx build --pull --platform $platform --file $DOCKERFILE --tag $CONTAINER_IMAGE . docker buildx build --pull --platform $platform --file $DOCKERFILE --tag $CONTAINER_IMAGE .
done done
.clean_release:
script:
# Delete release if it already exists
- 'curl --request DELETE --header "JOB-TOKEN: $CI_JOB_TOKEN" "${GITLAB_API_PROJECT_URL}/releases/${VERSION}"'
# Delete tag if it already exists (use private-token because job-token don't have permission to delete tags)
- 'curl --request DELETE --header "PRIVATE-TOKEN: $GITLAB_PROJECT_ACCESS_TOKEN" "${GITLAB_API_PROJECT_URL}/repository/tags/${VERSION}"'
stages:
- build
- clean-same-release
- clean-dev-release
- release
build:test:
stage: build
tags:
- build
- dind
image: docker:latest
services:
- docker:dind
script:
- !reference [ .build_script, script ]
rules:
- if: '$CI_COMMIT_TAG =~ "/^$/" && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_BRANCH !~ /^v[0-9]+(\.[0-9]+)*$/'
build:version:
stage: build
tags:
- build
- dind
image: docker:latest
services:
- docker:dind
script:
- !reference [ .build_script, script ]
# Here docker buildx can use cached images created in previous step # Here docker buildx can use cached images created in previous step
- docker buildx build --platform $PLATFORMS --file $DOCKERFILE --push --tag $CONTAINER_IMAGE . - docker buildx build --platform $DOCKER_PLATFORMS --file $DOCKERFILE --push --tag $CONTAINER_IMAGE .
rules: rules:
- if: '$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH =~ /^v[0-9]+(\.[0-9]+)*$/' - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^v[0-9]+(\.[0-9]+)*$/'
release-image: clean:release:
stage: clean-same-release
tags:
- gitlab_clean
image: registry.gitlab.com/gitlab-ci-utils/curl-jq:latest
script:
- !reference [.get_version, script]
- !reference [.clean_release, script]
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^v[0-9]+(\.[0-9]+)*$/'
clean-dev:release:
stage: clean-dev-release
tags:
- gitlab_clean
image: registry.gitlab.com/gitlab-ci-utils/curl-jq:latest
script:
- !reference [.get_version, script]
- VERSION="${VERSION}${VERSION_DEV_SUFFIX}"
- !reference [.clean_release, script]
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
clean:dockerhub:dev:
stage: clean-dev-release
tags:
- clean
- dind
image: docker:latest
services:
- docker:dind
script:
- !reference [.init_dind_script, script]
- VERSION="${VERSION}${VERSION_DEV_SUFFIX}"
# Remove dev tag
## Login to dockerhub (get JWT token)
- GET_TOKEN_DATA=$(jq --null-input --arg username "$DOCKER_REGISTRY_USER" --arg password "$DOCKER_REGISTRY_PASSWORD" '{"username":$username,"password":$password}')
- >
TOKEN=`curl --data "${GET_TOKEN_DATA}" \
--header "Content-Type: application/json" \
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
"https://hub.docker.com/v2/users/login/" | jq -r .token`
## Delete tag
- 'curl --header "Authorization: JWT ${TOKEN}" --request DELETE "https://hub.docker.com/v2/repositories/${DOCKER_REGISTRY_IMAGE}/tags/${VERSION}/"'
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
release:dockerhub:latest:
stage: release
tags:
- release
- dind
image: docker:latest
services:
- docker:dind
script:
- !reference [.init_dind_script, script]
# Push latest tag
- docker buildx imagetools create $CONTAINER_IMAGE --tag $DOCKER_REGISTRY_IMAGE:latest
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
release_job:
stage: release stage: release
tags: tags:
- release - release
image: registry.gitlab.com/gitlab-ci-utils/curl-jq:latest
script: script:
- docker buildx imagetools create $CONTAINER_IMAGE --tag $CI_REGISTRY_IMAGE:$VERSION - !reference [.get_version, script]
- docker buildx imagetools create $CONTAINER_IMAGE --tag $CI_REGISTRY_IMAGE:latest - !reference [.get_packages_url, script]
- echo 'Running release_job'
# Extract description from CHANGELOG.md
- CHANGELOG_LINE_START=`awk '/##\ [0-9]+\.[0-9]+\.[0-9]+/{print NR; exit;}' CHANGELOG.md`
- CHANGELOG_LINE_END=`awk '/##\ [0-9]+\.[0-9]+\.[0-9]+/{ count++; if(count>1) {print NR; exit;}}' CHANGELOG.md`
- DESCRIPTION=`awk 'NR > '$CHANGELOG_LINE_START' && NR < '$CHANGELOG_LINE_END'' CHANGELOG.md`
# Create Release (can't be done by release_step of gitlab image because it don't have access to env var defined in script_step)
- >
RELEASE_DATA=$(jq --null-input --arg version "$VERSION" --arg description "# Changelog (version $VERSION) $DESCRIPTION" --arg tag_name "$VERSION" --arg ref "$CI_COMMIT_SHORT_SHA" '{
"name": $version,
"description": $description,
"tag_name": $tag_name,
"ref": $ref
}')
- >
curl --data "${RELEASE_DATA}" \
--header "Content-Type: application/json" \
--header "JOB-TOKEN: $CI_JOB_TOKEN" \
--request POST "${GITLAB_API_PROJECT_URL}/releases"
rules: rules:
- if: '$CI_COMMIT_BRANCH == "main"' - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^v[0-9]+(\.[0-9]+)*$/'
\ No newline at end of file \ No newline at end of file
[submodule "ExerciceChecker/.idea/jetbrainsConfiguration"] [submodule "ExerciseChecker/src/sharedByClients"]
path = ExerciceChecker/.idea/jetbrainsConfiguration path = ExerciseChecker/src/sharedByClients
url = ../../shared/jetbrains_configuration.git
[submodule "ExerciceChecker/src/shared"]
path = ExerciceChecker/src/shared
url = ../../shared/nodesharedcode.git
[submodule "ExerciceChecker/src/sharedByClients"]
path = ExerciceChecker/src/sharedByClients
url = ../../shared/nodeclientsharedcode.git url = ../../shared/nodeclientsharedcode.git
[submodule "ExerciseChecker/src/shared"]
path = ExerciseChecker/src/shared
url = ../../shared/nodesharedcode.git
[submodule "ExerciseChecker/.idea/jetbrainsConfiguration"]
path = ExerciseChecker/.idea/jetbrainsConfiguration
url = ../../shared/jetbrains_configuration.git
# Changelog
<!--
### ✨ Feature
### 🤏 Minor change
### 🎨 Interface
### 🐛 Bugfix
### 🔒 Security
### 🚀‍️ CI / CD
### 🔨 Internal / Developers
### 📚 Documentation
**💥 Breaking:**
**⚠️ Deprecation:**
-->
## 2.0.0 (2023-09-15)
### ✨ Feature
- Added license: AGPLv3
### 🎨 Interface
- **💥 Breaking:** Renamed `enonce` to `assignment`
- **💥 Breaking:** Renamed `exercice` to `exercise`
### 🔨 Internal / Developers
- Auto release by pipeline
- For vX.Y.Z branch create release and tag with `-dev` suffix
- For main branch create definitive release and remove `-dev` releases
## 1.0.1 (2023-08-12)
### ✨ Feature
- 🎉 Initial release of the project
\ No newline at end of file
ARG BUILD_WORKDIR=/dojo/ExerciceChecker ARG BUILD_WORKDIR=/dojo/ExerciseChecker
######################################################################## Build stage ######################################################################## Build stage
FROM node:18-alpine AS builder FROM node:18-alpine AS builder
LABEL maintainer="Michaël Minelli <michael-jean.minelli@hesge.ch>" LABEL maintainer="Michaël Minelli <michael-jean.minelli@hesge.ch>"
LABEL Description="Dojo exercice checker - Build stage" LABEL Description="Dojo exercise checker - Build stage"
ARG BUILD_WORKDIR ARG BUILD_WORKDIR
# Create app directory # Create app directory
ADD ExerciceChecker/ ${BUILD_WORKDIR}/ ADD ExerciseChecker/ ${BUILD_WORKDIR}/
WORKDIR ${BUILD_WORKDIR} WORKDIR ${BUILD_WORKDIR}
...@@ -29,11 +29,11 @@ RUN npx pkg . -t node18 --output ${BUILD_WORKDIR}/bin/app --public-packages "*" ...@@ -29,11 +29,11 @@ RUN npx pkg . -t node18 --output ${BUILD_WORKDIR}/bin/app --public-packages "*"
######################################################################## Run stage ######################################################################## Run stage
FROM docker:latest FROM docker:latest
LABEL maintainer="Michaël Minelli <michael-jean.minelli@hesge.ch>" LABEL maintainer="Michaël Minelli <michael-jean.minelli@hesge.ch>"
LABEL Description="Dojo exercice checker - Container generation for usage in exercice pipelines" LABEL Description="Dojo exercise checker - Container generation for usage in exercise pipelines"
RUN apk update RUN apk update
RUN apk add git RUN apk add git
ARG BUILD_WORKDIR ARG BUILD_WORKDIR
COPY --from=builder ${BUILD_WORKDIR}/bin/app /usr/local/bin/dojo_exercice_checker COPY --from=builder ${BUILD_WORKDIR}/bin/app /usr/local/bin/dojo_exercise_checker
\ No newline at end of file \ No newline at end of file
File moved
File moved
Subproject commit 4d703a2dd39ec0c2b71bbbbda8900588c4e360bd
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<project version="4"> <project version="4">
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ExerciceChecker.iml" filepath="$PROJECT_DIR$/.idea/ExerciceChecker.iml" /> <module fileurl="file://$PROJECT_DIR$/.idea/ExerciseChecker.iml" filepath="$PROJECT_DIR$/.idea/ExerciseChecker.iml" />
</modules> </modules>
</component> </component>
</project> </project>
\ No newline at end of file
File moved
{ {
"name": "dojo_exercice_checker", "name": "dojo_exercise_checker",
"version": "1.0.0", "version": "2.0.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "dojo_exercice_checker", "name": "dojo_exercise_checker",
"version": "1.0.0", "version": "2.0.0",
"dependencies": { "dependencies": {
"ajv": "^8.12.0", "ajv": "^8.12.0",
"axios": "^1.4.0", "axios": "^1.4.0",
...@@ -60,9 +60,9 @@ ...@@ -60,9 +60,9 @@
} }
}, },
"node_modules/@babel/helper-validator-identifier": { "node_modules/@babel/helper-validator-identifier": {
"version": "7.22.5", "version": "7.22.15",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.15.tgz",
"integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", "integrity": "sha512-4E/F9IIEi8WR94324mbDUMo074YTheJmd7eZF5vITTeYchqAi6sYXRLHUVsmkdmY4QjfKTcB2jB7dVP3NaBElQ==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=6.9.0" "node": ">=6.9.0"
...@@ -154,9 +154,9 @@ ...@@ -154,9 +154,9 @@
} }
}, },
"node_modules/@jridgewell/resolve-uri": { "node_modules/@jridgewell/resolve-uri": {
"version": "3.1.0", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz",
"integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">=6.0.0" "node": ">=6.0.0"
...@@ -178,21 +178,15 @@ ...@@ -178,21 +178,15 @@
"dev": true "dev": true
}, },
"node_modules/@jridgewell/trace-mapping": { "node_modules/@jridgewell/trace-mapping": {
"version": "0.3.18", "version": "0.3.19",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.19.tgz",
"integrity": "sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA==", "integrity": "sha512-kf37QtfW+Hwx/buWGMPcR60iF9ziHa6r/CZJIHbmcm4+0qrXiVdxegAH0F6yddEVQ7zdkjcGCgCzUu+BcbhQxw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@jridgewell/resolve-uri": "3.1.0", "@jridgewell/resolve-uri": "^3.1.0",
"@jridgewell/sourcemap-codec": "1.4.14" "@jridgewell/sourcemap-codec": "^1.4.14"
} }
}, },
"node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec": {
"version": "1.4.14",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz",
"integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==",
"dev": true
},
"node_modules/@nodelib/fs.scandir": { "node_modules/@nodelib/fs.scandir": {
"version": "2.1.5", "version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
...@@ -253,9 +247,9 @@ ...@@ -253,9 +247,9 @@
"dev": true "dev": true
}, },
"node_modules/@types/docker-modem": { "node_modules/@types/docker-modem": {
"version": "3.0.2", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/docker-modem/-/docker-modem-3.0.2.tgz", "resolved": "https://registry.npmjs.org/@types/docker-modem/-/docker-modem-3.0.3.tgz",
"integrity": "sha512-qC7prjoEYR2QEe6SmCVfB1x3rfcQtUr1n4x89+3e0wSTMQ/KYCyf+/RAA9n2tllkkNc6//JMUZePdFRiGIWfaQ==", "integrity": "sha512-i1A2Etnav7uHizZ87vUf4EqwJehY3JOcTfBS0pGBlO+HQ0jg2lUMCaJRg9VQM8ldZkpYdIfsenxcTOCpwxPXEg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@types/node": "*", "@types/node": "*",
...@@ -298,9 +292,9 @@ ...@@ -298,9 +292,9 @@
} }
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "18.17.1", "version": "18.17.15",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.17.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.17.15.tgz",
"integrity": "sha512-xlR1jahfizdplZYRU59JlUx9uzF1ARa8jbhM11ccpCJya8kvos5jwdm2ZAgxSCwOl0fq21svP18EVwPBXMQudw==", "integrity": "sha512-2yrWpBk32tvV/JAd3HNHWuZn/VDN1P+72hWirHnvsvTGSqbANi+kSeuQR9yAHnbvaBvHDsoTdXV0Fe+iRtHLKA==",
"dev": true "dev": true
}, },
"node_modules/@types/ssh2": { "node_modules/@types/ssh2": {
...@@ -313,18 +307,18 @@ ...@@ -313,18 +307,18 @@
} }
}, },
"node_modules/@types/tar-stream": { "node_modules/@types/tar-stream": {
"version": "2.2.2", "version": "2.2.3",
"resolved": "https://registry.npmjs.org/@types/tar-stream/-/tar-stream-2.2.2.tgz", "resolved": "https://registry.npmjs.org/@types/tar-stream/-/tar-stream-2.2.3.tgz",
"integrity": "sha512-1AX+Yt3icFuU6kxwmPakaiGrJUwG44MpuiqPg4dSolRFk6jmvs4b3IbUol9wKDLIgU76gevn3EwE8y/DkSJCZQ==", "integrity": "sha512-if3mugZfjVkXOMZdFjIHySxY13r6GXPpyOlsDmLffvyI7tLz9wXE8BFjNivXsvUeyJ1KNlOpfLnag+ISmxgxPw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@types/node": "*" "@types/node": "*"
} }
}, },
"node_modules/@types/triple-beam": { "node_modules/@types/triple-beam": {
"version": "1.3.2", "version": "1.3.3",
"resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.2.tgz", "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.3.tgz",
"integrity": "sha512-txGIh+0eDFzKGC25zORnswy+br1Ha7hj5cMVwKIU7+s0U2AxxJru/jZSMU6OC9MJWP6+pc/hc6ZjyZShpsyY2g==" "integrity": "sha512-6tOUG+nVHn0cJbVp25JFayS5UE6+xlbcNF9Lo9mU7U0zk3zeUShZied4YEQZjy1JBF043FSkdXw8YkUJuVtB5g=="
}, },
"node_modules/acorn": { "node_modules/acorn": {
"version": "8.10.0", "version": "8.10.0",
...@@ -447,9 +441,9 @@ ...@@ -447,9 +441,9 @@
} }
}, },
"node_modules/axios": { "node_modules/axios": {
"version": "1.4.0", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", "resolved": "https://registry.npmjs.org/axios/-/axios-1.5.0.tgz",
"integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", "integrity": "sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==",
"dependencies": { "dependencies": {
"follow-redirects": "^1.15.0", "follow-redirects": "^1.15.0",
"form-data": "^4.0.0", "form-data": "^4.0.0",
...@@ -720,9 +714,9 @@ ...@@ -720,9 +714,9 @@
"dev": true "dev": true
}, },
"node_modules/cpu-features": { "node_modules/cpu-features": {
"version": "0.0.8", "version": "0.0.9",
"resolved": "https://registry.npmjs.org/cpu-features/-/cpu-features-0.0.8.tgz", "resolved": "https://registry.npmjs.org/cpu-features/-/cpu-features-0.0.9.tgz",
"integrity": "sha512-BbHBvtYhUhksqTjr6bhNOjGgMnhwhGTQmOoZGD+K7BCaQDCuZl/Ve1ZxUSMRwVC4D/rkCPQ2MAIeYzrWyK7eEg==", "integrity": "sha512-AKjgn2rP2yJyfbepsmLfiYcmtNn/2eUvocUyM/09yB0YDiz39HteK/5/T4Onf0pmdYDMgkBoGvRLvEguzyL7wQ==",
"hasInstallScript": true, "hasInstallScript": true,
"optional": true, "optional": true,
"dependencies": { "dependencies": {
...@@ -855,32 +849,6 @@ ...@@ -855,32 +849,6 @@
"node": ">= 8.0" "node": ">= 8.0"
} }
}, },
"node_modules/dockerode/node_modules/tar-fs": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.0.1.tgz",
"integrity": "sha512-6tzWDMeroL87uF/+lin46k+Q+46rAJ0SyPGz7OW7wTgblI273hsBqk2C1j0/xNadNLKDTUL9BukSjB7cwgmlPA==",
"dependencies": {
"chownr": "^1.1.1",
"mkdirp-classic": "^0.5.2",
"pump": "^3.0.0",
"tar-stream": "^2.0.0"
}
},
"node_modules/dockerode/node_modules/tar-stream": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz",
"integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==",
"dependencies": {
"bl": "^4.0.3",
"end-of-stream": "^1.4.1",
"fs-constants": "^1.0.0",
"inherits": "^2.0.3",
"readable-stream": "^3.1.1"
},
"engines": {
"node": ">=6"
}
},
"node_modules/dotenv": { "node_modules/dotenv": {
"version": "16.3.1", "version": "16.3.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
...@@ -934,9 +902,9 @@ ...@@ -934,9 +902,9 @@
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
}, },
"node_modules/fast-fifo": { "node_modules/fast-fifo": {
"version": "1.3.0", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.0.tgz", "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz",
"integrity": "sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw==" "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ=="
}, },
"node_modules/fast-glob": { "node_modules/fast-glob": {
"version": "3.3.1", "version": "3.3.1",
...@@ -1512,9 +1480,9 @@ ...@@ -1512,9 +1480,9 @@
} }
}, },
"node_modules/nan": { "node_modules/nan": {
"version": "2.17.0", "version": "2.18.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.17.0.tgz", "resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz",
"integrity": "sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==", "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==",
"optional": true "optional": true
}, },
"node_modules/napi-build-utils": { "node_modules/napi-build-utils": {
...@@ -1524,9 +1492,9 @@ ...@@ -1524,9 +1492,9 @@
"dev": true "dev": true
}, },
"node_modules/node-abi": { "node_modules/node-abi": {
"version": "3.45.0", "version": "3.47.0",
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.45.0.tgz", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.47.0.tgz",
"integrity": "sha512-iwXuFrMAcFVi/ZoZiqq8BzAdsLw9kxDfTC0HMyjXfSL/6CSDAGD5UmR7azrAgWV1zKYq7dUUMj4owusBWKLsiQ==", "integrity": "sha512-2s6B2CWZM//kPgwnuI0KrYwNjfdByE25zvAaEpq9IH4zcNsarH8Ihu/UuX6XMPEogDAxkuUFeZn60pXNHAqn3A==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"semver": "^7.3.5" "semver": "^7.3.5"
...@@ -1536,9 +1504,9 @@ ...@@ -1536,9 +1504,9 @@
} }
}, },
"node_modules/node-fetch": { "node_modules/node-fetch": {
"version": "2.6.12", "version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==", "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"whatwg-url": "^5.0.0" "whatwg-url": "^5.0.0"
...@@ -1710,6 +1678,34 @@ ...@@ -1710,6 +1678,34 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/pkg-fetch/node_modules/tar-fs": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz",
"integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==",
"dev": true,
"dependencies": {
"chownr": "^1.1.1",
"mkdirp-classic": "^0.5.2",
"pump": "^3.0.0",
"tar-stream": "^2.1.4"
}
},
"node_modules/pkg-fetch/node_modules/tar-stream": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz",
"integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==",
"dev": true,
"dependencies": {
"bl": "^4.0.3",
"end-of-stream": "^1.4.1",
"fs-constants": "^1.0.0",
"inherits": "^2.0.3",
"readable-stream": "^3.1.1"
},
"engines": {
"node": ">=6"
}
},
"node_modules/pkg/node_modules/fs-extra": { "node_modules/pkg/node_modules/fs-extra": {
"version": "9.1.0", "version": "9.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
...@@ -1859,12 +1855,12 @@ ...@@ -1859,12 +1855,12 @@
} }
}, },
"node_modules/resolve": { "node_modules/resolve": {
"version": "1.22.2", "version": "1.22.4",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.4.tgz",
"integrity": "sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==", "integrity": "sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"is-core-module": "^2.11.0", "is-core-module": "^2.13.0",
"path-parse": "^1.0.7", "path-parse": "^1.0.7",
"supports-preserve-symlinks-flag": "^1.0.0" "supports-preserve-symlinks-flag": "^1.0.0"
}, },
...@@ -1876,9 +1872,9 @@ ...@@ -1876,9 +1872,9 @@
} }
}, },
"node_modules/resolve/node_modules/is-core-module": { "node_modules/resolve/node_modules/is-core-module": {
"version": "2.12.1", "version": "2.13.0",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.12.1.tgz", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz",
"integrity": "sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg==", "integrity": "sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"has": "^1.0.3" "has": "^1.0.3"
...@@ -2189,22 +2185,20 @@ ...@@ -2189,22 +2185,20 @@
} }
}, },
"node_modules/tar-fs": { "node_modules/tar-fs": {
"version": "2.1.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.0.1.tgz",
"integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", "integrity": "sha512-6tzWDMeroL87uF/+lin46k+Q+46rAJ0SyPGz7OW7wTgblI273hsBqk2C1j0/xNadNLKDTUL9BukSjB7cwgmlPA==",
"dev": true,
"dependencies": { "dependencies": {
"chownr": "^1.1.1", "chownr": "^1.1.1",
"mkdirp-classic": "^0.5.2", "mkdirp-classic": "^0.5.2",
"pump": "^3.0.0", "pump": "^3.0.0",
"tar-stream": "^2.1.4" "tar-stream": "^2.0.0"
} }
}, },
"node_modules/tar-fs/node_modules/tar-stream": { "node_modules/tar-fs/node_modules/tar-stream": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz",
"integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==",
"dev": true,
"dependencies": { "dependencies": {
"bl": "^4.0.3", "bl": "^4.0.3",
"end-of-stream": "^1.4.1", "end-of-stream": "^1.4.1",
...@@ -2344,9 +2338,9 @@ ...@@ -2344,9 +2338,9 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "5.1.6", "version": "5.2.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
"integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
"dev": true, "dev": true,
"bin": { "bin": {
"tsc": "bin/tsc", "tsc": "bin/tsc",
......
{ {
"name" : "dojo_exercice_checker", "name" : "dojo_exercise_checker",
"version" : "1.0.1", "version" : "2.0.0",
"main" : "dist/app.js", "main" : "dist/app.js",
"bin" : { "bin" : {
"dirmanager": "./dist/app.js" "dirmanager": "./dist/app.js"
......
...@@ -9,7 +9,7 @@ import Styles from './types/Style'; ...@@ -9,7 +9,7 @@ import Styles from './types/Style';
import Icon from './sharedByClients/types/Icon'; import Icon from './sharedByClients/types/Icon';
import RecursiveFilesStats from './shared/helpers/recursiveFilesStats/RecursiveFilesStats'; import RecursiveFilesStats from './shared/helpers/recursiveFilesStats/RecursiveFilesStats';
import Toolbox from './shared/helpers/Toolbox'; import Toolbox from './shared/helpers/Toolbox';
import ExerciceCheckerError from './shared/types/Dojo/ExerciceCheckerError'; import ExerciseCheckerError from './shared/types/Dojo/ExerciseCheckerError';
import { exec } from 'child_process'; import { exec } from 'child_process';
import util from 'util'; import util from 'util';
import fs from 'fs-extra'; import fs from 'fs-extra';
...@@ -17,10 +17,10 @@ import HttpManager from './managers/HttpManager'; ...@@ -17,10 +17,10 @@ import HttpManager from './managers/HttpManager';
import DojoBackendManager from './managers/DojoBackendManager'; import DojoBackendManager from './managers/DojoBackendManager';
import Config from './config/Config'; import Config from './config/Config';
import ArchiveHelper from './shared/helpers/ArchiveHelper'; import ArchiveHelper from './shared/helpers/ArchiveHelper';
import ExerciceDockerCompose from './sharedByClients/helpers/Dojo/ExerciceDockerCompose'; import ExerciseDockerCompose from './sharedByClients/helpers/Dojo/ExerciseDockerCompose';
import ExerciceResultsValidation from './sharedByClients/helpers/Dojo/ExerciceResultsValidation'; import ExerciseResultsValidation from './sharedByClients/helpers/Dojo/ExerciseResultsValidation';
import ExerciceEnonce from './sharedByClients/models/ExerciceEnonce'; import ExerciseAssignment from './sharedByClients/models/ExerciseAssignment';
import ClientsSharedExerciceHelper from './sharedByClients/helpers/Dojo/ClientsSharedExerciceHelper'; import ClientsSharedExerciseHelper from './sharedByClients/helpers/Dojo/ClientsSharedExerciseHelper';
(async () => { (async () => {
...@@ -30,24 +30,24 @@ import ClientsSharedExerciceHelper from './sharedByClients/helpers/Dojo/ClientsS ...@@ -30,24 +30,24 @@ import ClientsSharedExerciceHelper from './sharedByClients/helpers/Dojo/ClientsS
console.log(Styles.APP_NAME(Config.appName)); console.log(Styles.APP_NAME(Config.appName));
let exerciceEnonce: ExerciceEnonce | undefined; let exerciseAssignment: ExerciseAssignment | undefined;
let exerciceDockerCompose: ExerciceDockerCompose; let exerciseDockerCompose: ExerciseDockerCompose;
let exerciceResultsValidation: ExerciceResultsValidation; let exerciseResultsValidation: ExerciseResultsValidation;
/* /*
//////////////////////////////////////////////////////////////////////////////////////////////////////////// Step 1: //////////////////////////////////////////////////////////////////////////////////////////////////////////// Step 1:
- Read the dojo enonce file from the enonce repository - Read the dojo assignment file from the assignment repository
- Download immutables files (maybe throw or show an error if the files have been modified ?) - Download immutables files (maybe throw or show an error if the files have been modified ?)
*/ */
{ {
console.log(Styles.INFO(`${ Icon.INFO }️ Checking the exercice's enonce and his immutable files`)); console.log(Styles.INFO(`${ Icon.INFO }️ Checking the exercise's assignment and his immutable files`));
exerciceEnonce = await DojoBackendManager.getExerciceEnonce(); exerciseAssignment = await DojoBackendManager.getExerciseAssignment();
if ( !exerciceEnonce ) { if ( !exerciseAssignment ) {
console.error(Styles.ERROR(`${ Icon.ERROR } Error while getting the exercice's enonce`)); console.error(Styles.ERROR(`${ Icon.ERROR } Error while getting the exercise's assignment`));
process.exit(ExerciceCheckerError.EXERCICE_ENONCE_GET_ERROR); process.exit(ExerciseCheckerError.EXERCISE_ASSIGNMENT_GET_ERROR);
} }
exerciceEnonce.immutable.forEach(immutableFile => { exerciseAssignment.immutable.forEach(immutableFile => {
const filePath = path.join(Config.folders.project, immutableFile.file_path); const filePath = path.join(Config.folders.project, immutableFile.file_path);
fs.mkdirSync(path.dirname(filePath), { recursive: true }); fs.mkdirSync(path.dirname(filePath), { recursive: true });
fs.writeFileSync(filePath, immutableFile.content, { encoding: 'base64' }); fs.writeFileSync(filePath, immutableFile.content, { encoding: 'base64' });
...@@ -64,58 +64,58 @@ import ClientsSharedExerciceHelper from './sharedByClients/helpers/Dojo/ClientsS ...@@ -64,58 +64,58 @@ import ClientsSharedExerciceHelper from './sharedByClients/helpers/Dojo/ClientsS
{ {
const composeOverridePath: string = path.join(Config.folders.project, 'docker-compose-override.yml'); const composeOverridePath: string = path.join(Config.folders.project, 'docker-compose-override.yml');
const composeOverride = fs.readFileSync(path.join(__dirname, '../assets/docker-compose-override.yml'), 'utf8').replace('{{VOLUME_NAME}}', exerciceEnonce.enonceFile.result.volume).replace('{{MOUNT_PATH}}', Config.folders.resultsExercice); const composeOverride = fs.readFileSync(path.join(__dirname, '../assets/docker-compose-override.yml'), 'utf8').replace('{{VOLUME_NAME}}', exerciseAssignment.assignmentFile.result.volume).replace('{{MOUNT_PATH}}', Config.folders.resultsExercise);
fs.writeFileSync(composeOverridePath, composeOverride); fs.writeFileSync(composeOverridePath, composeOverride);
exerciceDockerCompose = new ExerciceDockerCompose(ClientsSharedConfig.dockerCompose.projectName, exerciceEnonce.enonceFile, Config.folders.project, [ composeOverridePath ]); exerciseDockerCompose = new ExerciseDockerCompose(ClientsSharedConfig.dockerCompose.projectName, exerciseAssignment.assignmentFile, Config.folders.project, [ composeOverridePath ]);
try { try {
await new Promise<void>((resolve, reject) => { await new Promise<void>((resolve, reject) => {
exerciceDockerCompose.events.on('step', (name: string, message: string) => { exerciseDockerCompose.events.on('step', (name: string, message: string) => {
console.log(Styles.INFO(`${ Icon.INFO } ${ message }`)); console.log(Styles.INFO(`${ Icon.INFO } ${ message }`));
}); });
exerciceDockerCompose.events.on('endStep', (stepName: string, message: string, error: boolean) => { exerciseDockerCompose.events.on('endStep', (stepName: string, message: string, error: boolean) => {
if ( error ) { if ( error ) {
console.error(Styles.ERROR(`${ Icon.ERROR } ${ message }`)); console.error(Styles.ERROR(`${ Icon.ERROR } ${ message }`));
} }
}); });
exerciceDockerCompose.events.on('finished', (success: boolean, exitCode: number) => { exerciseDockerCompose.events.on('finished', (success: boolean, exitCode: number) => {
success ? resolve() : reject(); success ? resolve() : reject();
}); });
exerciceDockerCompose.run(); exerciseDockerCompose.run();
}); });
} catch ( error ) { } } catch ( error ) { }
fs.rmSync(composeOverridePath); fs.rmSync(composeOverridePath);
fs.writeFileSync(path.join(Config.folders.resultsDojo, 'dockerComposeLogs.txt'), exerciceDockerCompose.allLogs); fs.writeFileSync(path.join(Config.folders.resultsDojo, 'dockerComposeLogs.txt'), exerciseDockerCompose.allLogs);
if ( !exerciceDockerCompose.success ) { if ( !exerciseDockerCompose.success ) {
console.error(Styles.ERROR(`${ Icon.ERROR } Execution logs are available in artifacts`)); console.error(Styles.ERROR(`${ Icon.ERROR } Execution logs are available in artifacts`));
process.exit(exerciceDockerCompose.exitCode); process.exit(exerciseDockerCompose.exitCode);
} }
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////// Step 3: Check content requirements and content size //////////////////////////////////////////////////////////////////////////////////////////////////////////// Step 3: Check content requirements and content size
{ {
exerciceResultsValidation = new ExerciceResultsValidation(Config.folders.resultsDojo, Config.folders.resultsExercice); exerciseResultsValidation = new ExerciseResultsValidation(Config.folders.resultsDojo, Config.folders.resultsExercise);
try { try {
await new Promise<void>((resolve) => { await new Promise<void>((resolve) => {
exerciceResultsValidation.events.on('step', (name: string, message: string) => { exerciseResultsValidation.events.on('step', (name: string, message: string) => {
console.log(Styles.INFO(`${ Icon.INFO } ${ message }`)); console.log(Styles.INFO(`${ Icon.INFO } ${ message }`));
}); });
exerciceResultsValidation.events.on('endStep', (stepName: string, message: string, error: boolean) => { exerciseResultsValidation.events.on('endStep', (stepName: string, message: string, error: boolean) => {
if ( error ) { if ( error ) {
console.error(Styles.ERROR(`${ Icon.ERROR } ${ message }`)); console.error(Styles.ERROR(`${ Icon.ERROR } ${ message }`));
} }
}); });
exerciceResultsValidation.events.on('finished', (success: boolean, exitCode: number) => { exerciseResultsValidation.events.on('finished', (success: boolean, exitCode: number) => {
if ( !success ) { if ( !success ) {
process.exit(exitCode); process.exit(exitCode);
} }
...@@ -123,7 +123,7 @@ import ClientsSharedExerciceHelper from './sharedByClients/helpers/Dojo/ClientsS ...@@ -123,7 +123,7 @@ import ClientsSharedExerciceHelper from './sharedByClients/helpers/Dojo/ClientsS
resolve(); resolve();
}); });
exerciceResultsValidation.run(); exerciseResultsValidation.run();
}); });
} catch ( error ) { } } catch ( error ) { }
} }
...@@ -143,11 +143,11 @@ import ClientsSharedExerciceHelper from './sharedByClients/helpers/Dojo/ClientsS ...@@ -143,11 +143,11 @@ import ClientsSharedExerciceHelper from './sharedByClients/helpers/Dojo/ClientsS
liteStats : true liteStats : true
}); });
await DojoBackendManager.sendResults(exerciceDockerCompose.exitCode, commit, exerciceResultsValidation.exerciceResults!, files, await ArchiveHelper.getBase64(Config.folders.resultsVolume)); await DojoBackendManager.sendResults(exerciseDockerCompose.exitCode, commit, exerciseResultsValidation.exerciseResults!, files, await ArchiveHelper.getBase64(Config.folders.resultsVolume));
} catch ( error ) { } catch ( error ) {
console.error(Styles.ERROR(`${ Icon.ERROR } Error while uploading the results`)); console.error(Styles.ERROR(`${ Icon.ERROR } Error while uploading the results`));
console.error(JSON.stringify(error)); console.error(JSON.stringify(error));
process.exit(ExerciceCheckerError.UPLOAD); process.exit(ExerciseCheckerError.UPLOAD);
} }
} }
...@@ -158,8 +158,8 @@ import ClientsSharedExerciceHelper from './sharedByClients/helpers/Dojo/ClientsS ...@@ -158,8 +158,8 @@ import ClientsSharedExerciceHelper from './sharedByClients/helpers/Dojo/ClientsS
- Exit with container exit code - Exit with container exit code
*/ */
{ {
ClientsSharedExerciceHelper.displayExecutionResults(exerciceResultsValidation.exerciceResults!, exerciceDockerCompose.exitCode, Styles, `\n\n${ Icon.INFO }️ More detailed logs and resources may be available in artifacts`); ClientsSharedExerciseHelper.displayExecutionResults(exerciseResultsValidation.exerciseResults!, exerciseDockerCompose.exitCode, Styles, `\n\n${ Icon.INFO }️ More detailed logs and resources may be available in artifacts`);
process.exit(exerciceDockerCompose.exitCode); process.exit(exerciseDockerCompose.exitCode);
} }
})(); })();
\ No newline at end of file
...@@ -6,10 +6,10 @@ class Config { ...@@ -6,10 +6,10 @@ class Config {
public readonly appName: string; public readonly appName: string;
public readonly folders: { public readonly folders: {
project: string; resultsVolume: string; resultsDojo: string; resultsExercice: string; project: string; resultsVolume: string; resultsDojo: string; resultsExercise: string;
}; };
public readonly exercice: { public readonly exercise: {
id: string; secret: string; id: string; secret: string;
}; };
...@@ -18,14 +18,14 @@ class Config { ...@@ -18,14 +18,14 @@ class Config {
this.folders = { this.folders = {
project : process.env.PROJECT_FOLDER?.convertWithEnvVars() ?? './', project : process.env.PROJECT_FOLDER?.convertWithEnvVars() ?? './',
resultsVolume : process.env.EXERCICE_RESULTS_VOLUME?.convertWithEnvVars() ?? '', resultsVolume : process.env.EXERCISE_RESULTS_VOLUME?.convertWithEnvVars() ?? '',
resultsDojo : path.join(process.env.EXERCICE_RESULTS_VOLUME?.convertWithEnvVars() ?? '', 'Dojo/'), resultsDojo : path.join(process.env.EXERCISE_RESULTS_VOLUME?.convertWithEnvVars() ?? '', 'Dojo/'),
resultsExercice: path.join(process.env.EXERCICE_RESULTS_VOLUME?.convertWithEnvVars() ?? '', 'Exercice/') resultsExercise: path.join(process.env.EXERCISE_RESULTS_VOLUME?.convertWithEnvVars() ?? '', 'Exercise/')
}; };
this.resetResultsVolume(); this.resetResultsVolume();
this.exercice = { this.exercise = {
id : process.env.DOJO_EXERCICE_ID || '', id : process.env.DOJO_EXERCISE_ID || '',
secret: process.env.DOJO_SECRET || '' secret: process.env.DOJO_SECRET || ''
}; };
} }
...@@ -33,7 +33,7 @@ class Config { ...@@ -33,7 +33,7 @@ class Config {
private resetResultsVolume(): void { private resetResultsVolume(): void {
fs.emptyDirSync(this.folders.resultsVolume); fs.emptyDirSync(this.folders.resultsVolume);
fs.emptyDirSync(this.folders.resultsDojo); fs.emptyDirSync(this.folders.resultsDojo);
fs.emptyDirSync(this.folders.resultsExercice); fs.emptyDirSync(this.folders.resultsExercise);
} }
} }
......
import ClientsSharedConfig from '../sharedByClients/config/ClientsSharedConfig'; import ClientsSharedConfig from '../sharedByClients/config/ClientsSharedConfig';
import axios from 'axios'; import axios from 'axios';
import DojoResponse from '../shared/types/Dojo/DojoResponse'; import DojoBackendResponse from '../shared/types/Dojo/DojoBackendResponse';
import ExerciceEnonce from '../sharedByClients/models/ExerciceEnonce'; import ExerciseAssignment from '../sharedByClients/models/ExerciseAssignment';
import Config from '../config/Config'; import Config from '../config/Config';
import ExerciceResultsFile from '../shared/types/Dojo/ExerciceResultsFile'; import ExerciseResultsFile from '../shared/types/Dojo/ExerciseResultsFile';
import ApiRoute from '../sharedByClients/types/Dojo/ApiRoute'; import ApiRoute from '../sharedByClients/types/Dojo/ApiRoute';
...@@ -12,17 +12,17 @@ class DojoBackendManager { ...@@ -12,17 +12,17 @@ class DojoBackendManager {
return `${ ClientsSharedConfig.apiURL }${ route }`; return `${ ClientsSharedConfig.apiURL }${ route }`;
} }
public async getExerciceEnonce(): Promise<ExerciceEnonce | undefined> { public async getExerciseAssignment(): Promise<ExerciseAssignment | undefined> {
try { try {
return (await axios.get<DojoResponse<ExerciceEnonce>>(this.getApiUrl(ApiRoute.EXERCICE_ENONCE).replace('{{id}}', Config.exercice.id))).data.data; return (await axios.get<DojoBackendResponse<ExerciseAssignment>>(this.getApiUrl(ApiRoute.EXERCISE_ASSIGNMENT).replace('{{id}}', Config.exercise.id))).data.data;
} catch ( error ) { } catch ( error ) {
return undefined; return undefined;
} }
} }
public async sendResults(exitCode: number, commit: any, results: ExerciceResultsFile, files: any, archiveBase64: string): Promise<void> { public async sendResults(exitCode: number, commit: any, results: ExerciseResultsFile, files: any, archiveBase64: string): Promise<void> {
try { try {
await axios.post(this.getApiUrl(ApiRoute.EXERCICE_RESULTS).replace('{{id}}', Config.exercice.id), { await axios.post(this.getApiUrl(ApiRoute.EXERCISE_RESULTS).replace('{{id}}', Config.exercise.id), {
exitCode : exitCode, exitCode : exitCode,
commit : JSON.stringify(commit), commit : JSON.stringify(commit),
results : JSON.stringify(results), results : JSON.stringify(results),
......
...@@ -25,7 +25,7 @@ class HttpManager { ...@@ -25,7 +25,7 @@ class HttpManager {
config.headers['Content-Type'] = 'multipart/form-data'; config.headers['Content-Type'] = 'multipart/form-data';
} }
config.headers.Authorization = `ExerciceSecret ${ Config.exercice.secret }`; config.headers.Authorization = `ExerciseSecret ${ Config.exercise.secret }`;
} }
return config; return config;
......
Subproject commit 8d7e3ca0cca10e874ac48e19e47da8a1491ccba7
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment