Commit a293c68e authored by LAVENIER's avatar LAVENIER
Browse files

[fix] CI: fix runner

parent be3d7e05
Pipeline #11726 failed with stages
in 9 minutes and 58 seconds
default:
image: node:12.19.1
# ---------------------------------------------------------------
# Global
# ---------------------------------------------------------------
# Validate that the repository contains a package.json and extract a few values from it.
before_script:
- |
if [[ ! -f package.json ]]; then
echo "No package.json found! A package.json file is required to publish a package to GitLab's NPM registry."
echo 'For more information, see https://docs.gitlab.com/ee/user/packages/npm_registry/#creating-a-project'
exit 1
fi
- NPM_PACKAGE_NAME=$(node -p "require('./package.json').name")
- NPM_PACKAGE_VERSION=$(node -p "require('./package.json').version")
# default image
image: node:12
stages:
- build
- alt_build
# - test
# - release
- docker
- docs
# ---------------------------------------------------------------
# Global variables
# ---------------------------------------------------------------
variables:
CI_BUILD_IMAGE: $CI_REGISTRY_IMAGE/build:develop
BUILD_ENVIRONMENT: prod
ARTIFACT_ZIP_FILES: ${OUTPUT_DIR}/${CI_PROJECT_NAME}-*.zip
# ---------------------------------------------------------------
# Jobs templates
# ---------------------------------------------------------------
.docker:
image: docker:latest
tags: [simm-runner]
services:
- docker:dind
before_script:
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
after_script:
- docker logout ${CI_REGISTRY}
allow_failure: false
# ---------------------------------------------------------------
# Build jobs
# ---------------------------------------------------------------
# Validate that the package name is properly scoped to the project's root namespace.
# For more information, see https://docs.gitlab.com/ee/user/packages/npm_registry/#package-naming-convention
validate_package_scope:
.build:
stage: build
tags: [simm-runner]
script:
- |
if [[ ! $NPM_PACKAGE_NAME =~ ^@$CI_PROJECT_ROOT_NAMESPACE/ ]]; then
echo "Invalid package scope! Packages must be scoped in the root namespace of the project, e.g. \"@${CI_PROJECT_ROOT_NAMESPACE}/${CI_PROJECT_NAME}\""
echo 'For more information, see https://docs.gitlab.com/ee/user/packages/npm_registry/#package-naming-convention'
exit 1
fi
# If no .npmrc if included in the repo, generate a temporary one to use during the publish step
# that is configured to publish to GitLab's NPM registry
create_npmrc:
stage: build
# Update dependencies
- scripts/ci/dependencies.sh check || yarn install
- yarn run build.${BUILD_ENVIRONMENT}
after_script:
# Remember version
- APP_VERSION=$(node -e "console.log(require('./package.json').version)")
- echo "APP_VERSION=${APP_VERSION}" > variables.env
artifacts:
paths:
- www
reports:
dotenv: variables.env
expire_in: 72 hours
build:
extends: .build
image: ${CI_BUILD_IMAGE}
before_script:
# Get project dependencies
- mv /tmp/.build-cache/node_modules ./
only:
- develop
- feature/imagine
failsafe-build:
extends: .build
stage: alt_build
when: on_failure
before_script:
# Install global dependencies
- yarn global add @ionic/cli @angular/cli
# Update project dependencies
- yarn install
only:
- develop
- feature/imagine
docker:ci:
extends: .docker
stage: alt_build
when: on_failure
allow_failure: true
script:
- |
if [[ ! -f .npmrc ]]; then
echo 'No .npmrc found! Creating one now. Please review the following link for more information: https://docs.gitlab.com/ee/user/packages/npm_registry/index.html#authenticating-with-a-ci-job-token'
# Build and push the CI image
- docker build --cache-from ${CI_BUILD_IMAGE} --pull -t ${CI_BUILD_IMAGE} --build-arg="CACHE_DIR=/tmp/build-cache" -f scripts/ci/Dockerfile .
#- docker build --no-cache -t ${CI_BUILD_IMAGE} -f target/ci/DockerFile .
- docker push ${CI_BUILD_IMAGE}
only:
- develop
- feature/imagine
{
echo '@${CI_PROJECT_ROOT_NAMESPACE}:registry=${CI_SERVER_PROTOCOL}://${CI_SERVER_HOST}:${CI_SERVER_PORT}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/'
echo '//${CI_SERVER_HOST}:${CI_SERVER_PORT}/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}'
echo '//${CI_SERVER_HOST}:${CI_SERVER_PORT}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}'
} >> .npmrc
# ---------------------------------------------------------------
# Release jobs
# ---------------------------------------------------------------
fi
artifacts:
paths:
- .npmrc
# TODO
cache:
paths:
- node_modules/
# ---------------------------------------------------------------
# Docker jobs
# ---------------------------------------------------------------
install_dependencies:
stage: build
.docker-build:
extends: .docker
stage: docker
script:
- npm install
- npm run build.prod
# Build docker image
- docker pull ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} || true
- docker build --cache-from ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} --pull -t ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} --build-arg="HTML=www" --build-arg="NGINX_CONF=scripts/docker/site.conf" -f scripts/docker/Dockerfile .
- docker push ${CI_REGISTRY_IMAGE}:${IMAGE_TAG}
docker:develop:
extends: .docker-build
variables:
IMAGE_TAG: develop
only:
- develop
docker:imagine:
extends: .docker-build
variables:
IMAGE_TAG: imagine
only:
- feature/imagine
docker:release:
extends: .docker-build
variables:
IMAGE_TAG: $CI_COMMIT_TAG
only:
- tags
docker:production:
extends: .docker-build
variables:
# IMAGE_TAG: $CI_COMMIT_TAG
IMAGE_TAG: 'production'
only:
- tags
- feature/imagine
when: manual
# ---------------------------------------------------------------
# Docs jobs
# ---------------------------------------------------------------
pages:
stage: docs
tags: [simm-runner]
image: python:3.7-alpine
before_script:
- apk --update --upgrade add gcc musl-dev jpeg-dev zlib-dev libffi-dev cairo-dev pango-dev gdk-pixbuf-dev
- pip install --upgrade pip
- pip install --upgrade mkdocs
- pip install --upgrade mkdocs-pdf-export-plugin==0.5.5
script:
- mkdocs -v build
- mv site public
artifacts:
paths:
- node_modules/
- public
only:
- develop
- feature/imagine
when: manual
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment