# This is based on the sample build configuration for JavaScript. # Check our guides at https://confluence.atlassian.com/x/14UWN for more examples. # Only use spaces to indent your .yml configuration. # ----- # You can specify a custom docker image from Docker Hub as your build environment. image: node:8 pipelines: default: - step: # # Validate swagger definitions against the swagger 2.0 JSON schema spec # NOTE: we have to download it manually as ajv-cli only supports local # schemas at present. # name: "Swagger schema validation" caches: - node script: - npm install -g ajv-cli - TEMPLATEFILE=`mktemp` || exit 1 - wget -q http://json.schemastore.org/swagger-2.0 -O $TEMPLATEFILE - DEREFEDSWAGGERFILE=`mktemp` || exit 1 - npm install -g json-refs - json-refs resolve node_server/swagger_api/api_swagger_def.json > $DEREFEDSWAGGERFILE - ajv test -s $TEMPLATEFILE -d $DEREFEDSWAGGERFILE --valid --errors=json - ajv test -s $TEMPLATEFILE -d node_server/integration_api/integration_swagger_def.json --valid --errors=json - step: # # Run ESLint against all the JS files that were changed in this branch. # # The linting is run using a script as its a little too complex for # standalone commands. # # Note that this will also run on master when changes are merged in, but # as `HEAD` and `master` will be the same revision there will be no files # in the list of changes and ESLint won't be run. # # name: "ESLint" caches: - node script: # Install packages to get our expected version of ESLint and related configs # pipeline runs as root, but npm doesn't like installing packages as # root for security reasons. As this is just CI we allow it, using # unsafe-perm to make npm accept it. # - npm install --unsafe-perm # Run the tests - chmod +x ./tools/bitbucket-pipeline-scripts/eslint-changes.sh - ./tools/bitbucket-pipeline-scripts/eslint-changes.sh - step: # # All unit tests are run every time in case a change has an unexpected # effect on other areas. # name: "Unit tests" caches: - node script: - npm install -g gulp # # pipeline runs as root, but npm doesn't like installing packages as # root for security reasons. As this is just CI we allow it, using # unsafe-perm to make npm accept it. # - npm install --unsafe-perm # # As described in the docs, we need to use the mccha-junit-reporter # to output results in a format pipelines understands, plus set an # environment variable to put them in a location that it looks in. # See: # https://confluence.atlassian.com/bitbucket/test-reporting-in-pipelines-939708543.html # - MOCHA_FILE=./test-reports/[hash].xml gulp --cwd node_server test --reporter mocha-junit-reporter