Issue
Trying to create a .gitlab-ci.yml file to do builds in GitLab.
All attempts thus far fail.
Few examples I am able to find and those seem to have node_modules saved to the repository and use of Docker.
I've no knowledge about Docker.
Are Docker and storing node_modules required in order to perform builds on GitLab? (We don't store the node_modules)?
Here is the entirety of the script which is minimalist and does not work.
stages: # List of stages for jobs, and their order of execution
- build
build-job: # This job runs in the build stage, which runs first.
stage: build
script:
# - npm run build_def_fouo
- ng build -c def-fouo
- echo "Compiling the code..."
With npm I get: npm: command not found
With ng I get: ng: command not found
I'm at a loss.
===updated 05/06/2022
Made a little bit of progress this morning after 51 failed pipelines.
Here is my latest script but I'm reviewing the logs and will update with information to debug...
image: node:14.17.0
cache:
paths:
- node_modules/
stages: # List of stages for jobs, and their order of execution
- setup
- build
Test:
stage: setup
script:
- npm install # or `npm install` or whatever you use to install deps
Builder:
stage: build
script: # ... your other build steps here
- npm run build_def_fouo
=== Error Log
Error: node_modules/ng2-material-dropdown/src/modules/components/button/ng2-dropdown-button.d.ts:18:21 - error TS2694: Namespace '"/builds/elijah.d.j.marshall/ghostshot/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.
Solution
To answer my question. NO I DON'T NEED TO SAVE TO GIT THE node_modules diroectory.
This is my file that I got working.
# This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at: https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Getting-Started.gitlab-ci.yml
# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages
# START of file content below.
image: node:14.17.0 # This is the container for our Docker we will build in
cache:
paths:
- dist/
- node_modules/
stages: # List of stages for jobs, and their order of execution
- install_dependencies
- install_angular
- build
- test
install_dep:
stage: install_dependencies
image: node:14
script: # Execute script commands just as you would on terminal command line
- echo $CI_PROJECT_DIR
- npm install
- echo npm --version
artifacts: # This is required for other stage to have access to what gets created
paths:
- node_modules/
install_ang:
stage: install_angular
image: node:14
script:
- npm install -D typescript @angular/cli@12.2.16 @angular/compiler@12.2.16
build:
stage: build
script:
- echo "Compiling the code..."
- npm run build_def_fouo
- ls dist/
- echo "Compile complete."
artifacts: # This is required for other stage to have access to what gets created
paths:
- dist/
.post:
stage: test # It only starts when the job in the build stage completes successfully.
before_script:
- apt-get update
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd65.deb
- apt install -y ./google-chrome*.deb
- export CHROME_BIN=/usr/bin/google-chrome
script:
- echo "Running unit tests... This will take about 60 seconds."
# - sleep 60
# - echo "Code coverage is 90%"
- test -f "/node_modules/"
- npm run test -- --no-watch --browsers=ChromeHeadlessCI
# test_async:
# script:
# - npm install
# - node ./specs/start.js ./specs/async.spec.js
# lint-test-job: # This job also runs in the test stage.
# stage: test # It can run at the same time as unit-test-job (in parallel).
# script:
# - echo "Linting code... This will take about 10 seconds."
# - sleep 10
# - echo "No lint issues found."
# deploy-job: # This job runs in the deploy stage.
# stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
# script:
# - echo "Deploying application..."
# - echo "Application successfully deployed."
Answered By - edjm
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.