Google cloud build unexpected char : in cloudbuild.yaml - google-app-engine

I am getting the following error in my google cloud build
Failed to trigger build: failed unmarshalling build config cloudbuild.yaml: yaml: line 12: could not find expected ':'
I can not pinpoint where exactly I am missing : in my cloudbuild.yaml file
steps:
# Install
- name: "gcr.io/cloud-builders/npm"
args: ["install"]
# Update submodules
- name: "gcr.io/cloud-builders/git"
entrypoint: "bash"
args:
- "-c"
- |
git config -f .gitmodules submodule.myprojectsubmodule.url https://source.developers.google.com/p/myproject/r/github_myprojectsubmodule
git submodule init
git submodule update
# Lint
- name: "gcr.io/cloud-builders/npm"
args: ["run", "lint"]
# Test
- name: "gcr.io/cloud-builders/npm"
args: ["run", "test"]
# Build
- name: "gcr.io/cloud-builders/gcloud"
args:
- kms
- decrypt
- --ciphertext-file=.env.enc
- --plaintext-file=.env
- --location=global
- --keyring=myproject
- --key=cloudbuild-env
- name: "gcr.io/cloud-builders/npm"
args: ["run", "build"]
# Deploy
- name: "gcr.io/cloud-builders/npm"
args: ["run", "deploy"]
I have added # Update submodules step using the following comment https://github.com/GoogleCloudPlatform/cloud-builders/issues/26#issuecomment-463465138

To be a valid yaml format, the git commands should be correctly aligned under the | symbol in Update submodules section.
# Update submodules
- name: "gcr.io/cloud-builders/git"
entrypoint: "bash"
args:
- "-c"
- |
git config -f .gitmodules submodule.myprojectsubmodule.url https://source.developers.google.com/p/myproject/r/github_myprojectsubmodule
git submodule init
git submodule update
A YAML validator could be useful in this case, for example https://codebeautify.org/yaml-validator.

Related

Azure deployment of react app fails in deployment phase due to package path or zip deploy

I am new to azure and I made a setup on the azure portal with GitHub and set .yml. the pipeline runs successfully in the build phase but fails in the deployment phase.
here is my workflow file.
push:
branches: ["master"]
workflow_dispatch:
env:
AZURE_WEBAPP_NAME: wep-app-name # set this to your application's name
AZURE_WEBAPP_PACKAGE_PATH: "." # set this to the path to your web app project, defaults to the repository root
NODE_VERSION: "16.15.0" # set this to the node version to use
NODE_OPTIONS: "--max-old-space-size=8192"
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: Set up Node.js
uses: actions/setup-node#v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
#- name: yarn install, build, and test
# run: |
# node --max_old_space_size=8192
# yarn
#yarn run build
#zip artifact
- name: Zip artifact for deployment
run: zip release.zip ./build/* -r #get files and folder in build folder and
#compress into release.zip with linux zip command
- name: Upload artifact for deployment job
uses: actions/upload-artifact#v3
with:
name: node-app
path: build
deploy:
permissions:
contents: none
runs-on: ubuntu-latest
needs: build
environment:
name: "Development"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact#v3
with:
name: node-app
path: .
- name: "Deploy to Azure WebApp"
uses: azure/webapps-deploy#v2
id: deploy-to-webapp
with:
app-name: "app-name"
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_B2318A4382DB625 }}
package: .

Module not found in Nest JS after deploying to App engine

I tried to deploy a Nest JS app to App Engine through Google Build Cloud & Manually
Both tries gives same error Modules not found
Error when deploying manually through Shell
Error when dploying using clouf build
My cloudbuild.yaml
- name: node:14.15.1
entrypoint: npm
args: ["install"]
- name: node:14.15.1
entrypoint: npm
args: ["run", "build"]
- name: node:14.15.1
entrypoint: npm
args: ["run", "create-env"]
env:
- "_APP_LUNE_DEV_TOKEN=${_APP_LUNE_DEV_TOKEN}"
- "_BUCKET_NAME=${_BUCKET_NAME}"
- "_FIREBASE_API_KEY=${_FIREBASE_API_KEY}"
- "_FIREBASE_APP_ID=${_FIREBASE_APP_ID}"
- "_FIREBASE_AUTH_DOMAIN=${_FIREBASE_AUTH_DOMAIN}"
- "_FIREBASE_MESSAGING_SENDER_ID=${_FIREBASE_MESSAGING_SENDER_ID}"
- "_FIREBASE_PROJECT_ID=${_FIREBASE_PROJECT_ID}"
- "_FIREBASE_STORAGE_BUCKET=${_FIREBASE_STORAGE_BUCKET}"
- "_GOOGLE_APPLICATION_CREDENTIALS=${_GOOGLE_APPLICATION_CREDENTIALS}"
- "_LUNE_API_BASE_URL=${_LUNE_API_BASE_URL}"
- "_STRIPE_SECRET_KEY=${_STRIPE_SECRET_KEY}"
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]
timeout: "1600s"
options:
logging: CLOUD_LOGGING_ONLY
My app.yaml
runtime: nodejs14
service: backend
What I'm doing wrong ?
The problem was caused by Nest Js CLI Aliases, When I changed src/example/service to ../example/service the deployment worked
It's recommended to use typescript aliases in tsconfig file instead of CLI

Gitlab CI: why do I get an error when I try to define the pages stage?

I'm trying to publish a create-react-app on Gitlab, using its CI.
This is my .gitlab-ci.yml file:
stages:
- build
- pages
build:
image: node:16
stage: build
script:
- npm install
- npm build
artifacts:
paths:
- build/
pages:
image: alpine:latest
stage: deploy
variables:
GIT_STRATEGY: none # Do not clone git repo
script:
- mv build public
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
But unfortunately I get this error:
This GitLab CI configuration is invalid: pages job: chosen stage does not exist; available stages are .pre, build, pages, .post.
What's wrong with my configuration?
You need to change your stages.
You have:
stages:
- build
- pages
but define:
pages:
image: alpine:latest
stage: deploy
The stage needs to match:
stages:
- build
- deploy <-------

Configure GitLab CI to run features tests with rspec / selenium / Firefox

I am new to gitlab CI and I need help to configure gitlab-ci to run feature tests with Firefox (Ruby 2.7 / Rails 6 / Rspec / Capybara).
All is ok except feature tests.
I think I have to configure something with Firefox, or maybe install something.
Thanks for your help !
Error message when running tests :
Failure/Error: visit "/meth/methodologies/#{#meth.id}/edit"
Selenium::WebDriver::Error::WebDriverError:
Could not find Firefox binary (os=linux). Make sure Firefox is installed or set the path manually with Selenium::WebDriver::Firefox::Binary.path=
File .gitlab-ci.yml
stages:
- build
- test
- deploy
image: ruby:2.7.1
cache: &global_cache
key: ${CI_COMMIT_REF_SLUG}
paths:
- apt-cache/
- vendor/ruby
- node_modules
- .yarn-cache
policy: pull-push
.base:
cache:
# inherit all global cache settings
<<: *global_cache
before_script:
- gem install bundler --no-document
- bundle install --jobs $(nproc) "${FLAGS[#]}" --path=vendor
.base_db:
# extends: .base
services:
- name: mysql:8.0.21
command: ['--default-authentication-plugin=mysql_native_password']
- name: selenium/standalone-firefox
alias: selenium
variables:
MYSQL_ROOT_PASSWORD: xxxx
DB_USERNAME: xxxx
DB_PASSWORD: xxxx
DB_HOST: mysql
RAILS_ENV: test
DISABLE_SPRING: 1
BUNDLE_PATH: vendor/bundle
cache:
# inherit all global cache settings
<<: *global_cache
before_script:
# install yarn & dependencies
- export APT_CACHE_DIR=`pwd`/apt-cache && mkdir -pv $APT_CACHE_DIR
- wget -q -O - https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
- echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list
- apt-get update -qq && apt-get -o dir::cache::archives="$APT_CACHE_DIR" install -y yarn
- yarn config set cache-folder .yarn-cache
- yarn install
- gem install bundler --no-document
- bundle install --jobs $(nproc) "${FLAGS[#]}" --path=vendor/ruby
# Setup test database
- cp config/database.ci.yml config/database.yml
- RAILS_ENV=test bundle exec rails db:create db:migrate
rubocop:
extends: .base
stage: build
# cache:
# policy: pull-push
script:
- bundle exec rubocop app --fail-level W
rspec:
extends: .base_db
stage: test
script:
- bundle exec rspec -t ~type:feature
artifacts:
paths:
- coverage/
features:
extends: .base_db
stage: test
script:
- bundle exec rspec
# services:
# - name: selenium/standalone-firefox
# alias: selenium
# artifacts:
# paths:
# - coverage/
pages:
stage: deploy
dependencies:
- rspec
script:
- mv coverage/ public/
artifacts:
paths:
- public
expire_in: 30 days
# only:
# - master
EDIT :
I added the installation of firefox.
Tests that use js still don't work. The error is now as follows :
Failure/Error: visit "/meth/methodologies/#{#meth.id}/edit"
Selenium::WebDriver::Error::UnknownError:
Process unexpectedly closed with status 1
You have to use your browser with headless option
rails_helper.rb
Capybara.register_driver :headless_firefox do |app|
browser_options = Selenium::WebDriver::Firefox::Options.new()
browser_options.args << '--headless'
Capybara::Selenium::Driver.new(
app,
browser: :firefox,
options: browser_options
)
end
Capybara.javascript_driver = :headless_firefox
Capybara.configure do |config|
config.default_max_wait_time = 10 # seconds
config.default_driver = :headless_firefox
end

Deploy Vue Build On Google Cloud Platform

I am running command "gcloud app deploy" from my "vue" app folder and at the last getting vue-cli error, attached snap for it.
it seems like vue-cli-service isn't installed this is my cloudbuild.yaml if it helps
steps:
- name: node
entrypoint: npm
args: ['install']
# Necessary for vue.js projects
- name: node
entrypoint: npm
args: ['install', '-g', '#vue/cli']
- name: node
entrypoint: npm
args: ['test']
- name: node
entrypoint: npm
args: ['run', 'build']
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]
app.yaml:
runtime: nodejs12
handlers:
# Serve all static files with urls ending with a file extension
- url: /(.*\..+)$
static_files: dist/\1
upload: dist/(.*\..+)$ # catch all handler to index.html
- url: /.*
static_files: dist/index.html
upload: dist/index.html
Note: if your package.json isn't in your repository root you should define set in npm commands as:
- name: node
entrypoint: npm
# --prefix and path:
args: ['install','--prefix','myapp']
and for deployment in gcloud if app.yaml isn't in root either:
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy","myapp/app.yaml"]
Are you trying to deploy the app on GAE ( Google App Engine )?
If you are, the error might be caused because of GAE is not compatible with nodejs ( npm ), you need to deploy it in GAE flex if you want to use Vue of that way.
Another option could be, build the vue app and deploy it with another runtime, for example: python server; using the build as a static site.

Resources