Can not trigger build with indication of "Not Run" in CircleCI - continuous-integration

I am planning to migrate my existing CI to CircleCI 2 in favor of the docker. Once I tried to trigger a build it's shown something like this:
I also checked the steps as indicated in the below alert here https://circleci.com/sunset1-0/
Service alert: Your project references CircleCI 1.0 or it has no
configuration. CircleCI 1.0 and projects without configuration files
are no longer supported. You must update your project to use CircleCI
2.0 configuration to continue. Learn more.
Is there anything I missed out?
Below is my .circleci/config.yml
version: 2 # use CircleCI 2.0
jobs: # a collection of steps
build: # runs not using Workflows must have a `build` job as entry point
parallelism: 3 # run three instances of this job in parallel
docker: # run the steps with Docker
- image: circleci/ruby:2.4.2-jessie-node # ...with this image as the primary container; this is where all `steps` will run
environment: # environment variables for primary container
BUNDLE_JOBS: 3
BUNDLE_RETRY: 3
BUNDLE_PATH: vendor/bundle
RAILS_ENV: test
- image: mysql:5.7 # database image
environment: # environment variables for database
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
steps: # a collection of executable commands
- checkout # special step to check out source code to working directory
- run:
name: setup
command: |
curl -sL https://deb.nodesource.com/setup_10.x | bash \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
- run:
name: Dependencies
command: |
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential mysql-client nodejs yarn && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Which version of bundler?
- run:
name: Which bundler?
command: bundle -v
# Restore bundle cache
# Read about caching dependencies: https://circleci.com/docs/2.0/caching/
- restore_cache:
keys:
- rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
- rails-demo-bundle-v2-
- run: # Install Ruby dependencies
name: Bundle Install
command: bundle check --path vendor/bundle || bundle install --deployment
# Store bundle cache for Ruby dependencies
- save_cache:
key: rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
# Only necessary if app uses webpacker or yarn in some other way
- restore_cache:
keys:
- rails-demo-yarn-{{ checksum "yarn.lock" }}
- rails-demo-yarn-
- run:
name: Yarn Install
command: yarn install --cache-folder ~/.cache/yarn
# Store yarn / webpacker cache
- save_cache:
key: rails-demo-yarn-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- run:
name: Wait for DB
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Database setup
command: bin/rails db:schema:load --trace
- run:
name: Run rspec in parallel
command: |
bundle exec rspec --profile 10 \
--format RspecJunitFormatter \
--out test_results/rspec.xml \
--format progress \
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
# Save test results for timing analysis
- store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
path: test_results
# See https://circleci.com/docs/2.0/deployment-integrations/ for example deploy configs

In order for the build work, your config.yml file must live inside a .circleci folder at the root of your project directory.
You post a very good description. Thanks for the code. The version config looks fine. However, you wrote that your config currently lives at .circle/config.yml (Notice the missing ci at end of circle)
Move the config.yml to .circleci/config.yml and the build should proceed further. (right now the build is failing because it has no configuration.
E

Related

Azure DevOps CI pipeline for standard Laravel 9 project

My team and I are familiarizing ourselves with Azure DevOps. I'd like to set up a CI pipeline for the standard Laravel 9 project as a proof of concept, but haven't been successful.
I also haven't been able to find a template.
All that needs to happen in our pipeline is for the new code to be built, tested and containerised as a docker container which can then be pushed to a repo for later deployment.
If anyone could help point me in the right direction, I'd greatly appreciate it!
Using the below YAML file, I've continously run into errors that I do not understand. With the version below, failing a unit test that only asserts whether true is true.
trigger:
- main
pool:
vmImage: 'Ubuntu-Latest'
variables:
PHP_VERSION: '8.0.2'
PHPUNIT_VERSION: '9.5.10'
steps:
- task: NodeTool#0
inputs:
versionSpec: '14.x'
- script: |
sudo apt-get update
sudo apt-get install -y php${{ variables.PHP_VERSION }} php${{ variables.PHP_VERSION }}-cli php${{ variables.PHP_VERSION }}-mbstring unzip
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
sudo composer global require "phpunit/phpunit:${{ variables.PHPUNIT_VERSION }}"
displayName: 'Install PHP and Composer'
- script: |
sudo apt-get install -y git
git clone https://github.com/RadicalRumin/fluffy-fiesta.git
cd /fluffy-fiesta
composer install
displayName: 'Clone and install dependencies'
- script: |
phpunit
displayName: 'Run PHPUnit tests'

Connection refused for local server in github actions workflow

I'm trying to run a local server for my project CI/CD Pipeline. When I start the server I got a "Connection refused" on it.
My project is a fastAPI application and I'm trying to run a integration tests on PR to validate the app before merge the code. I tried to start my app directly (gunicorn), building a docker image and starting it... I tried a lot of things. Then, I tried to run a simple server instead of my app and... got the same error!
This is my simple server workflow:
on:
push:
branches:
- "develop"
jobs:
mylocalserver:
name: Run server
runs-on: ubuntu-latest
steps:
- name: Setup python
uses: actions/setup-python#v3
with:
python-version: 3.9
- name: Run server in background
run: |
python -V
python -m http.server 3000 &> /dev/null &
sudo lsof -i -P -n | grep LISTEN
curl http://localhost:3000
- name: Run server with console
run: |
python -m http.server 3000
Output:
If I run my app with console (no daemon mode in gunicorn), the server start and log to console in workflow with success:
But this way I cannot run nothing after this (and I have to cancel workflow). Some idea? Thank you!
Maybe not the best answer, but for now runnig the job into a container works (only add a container label in question example). Example for my fastAPI app:
on:
pull_request:
branches:
- 'main'
- 'develop'
jobs:
run-on-pr:
runs-on: ubuntu-latest
container: ubuntu
services:
mongodb:
image: mongo
ports:
- 27017:27017
steps:
- name: Setup git
run: |
apt-get update; apt-get install -y git
- name: Git checkout
uses: actions/checkout#v3
with:
path: api
- name: Setup python
uses: actions/setup-python#v4
with:
python-version: 3.9
- name: Install pip
run: |
apt-get update; apt-get install -y python3-pip
- name: Build and ENV
run: |
cd api
cp .env_example_docker .env
pip3 install -r requirements.txt
- name: Run fastAPI
run: |
cd api
gunicorn -D -k uvicorn.workers.UvicornWorker -c ./gunicorn_conf.py app.main:app
env:
MONGO_URL: "mongodb://mongodb:27017"
- name: Install curl
run: |
apt-get update; apt-get install -y curl
- name: Run curl
run: |
curl http://localhost:3000
This works, but I have to install all in container (git, pip). I will try a solution without using the container label and if I found anything I can post here.

CircleCi Build is failing due to the wrong Ruby version

We originally were using Ruby 2.2.3 for our application, however, now I'm updating the gems due to vulnerabilities and as a result, I have to update the ruby version that the application is running on. Locally, this was fairly straight forward (using rbenv), however, when I push it to GitHub, it fails the CircleCi build because it's pulling the ruby version from an old docker image that's using the old ruby version.
So far, I've pulled the old docker image down using docker pull, ran the image using docker run -it, opened it in VSCode using the Remote Extension, and downloaded rbenv, updated the ruby version, committed the changes with docker commit, pushed it to GitHub with docker push, and tested it but it's still failing the CircleCi build with an error saying that the updated gems need to use the updated version of ruby.
config.yml:
version: 2.1
jobs:
build:
docker:
- image: 073991710092.dkr.ecr.us-east-1.amazonaws.com/signage-dev:latest-v2
environment:
RAILS_LOG_TO_STDOUT: 'true'
RAILS_ENV: test
APP_ENV: development
DB_USERNAME: *******
DB_PASSWORD: *******
DB_HOST: mysql
CACHE_HOST: redis
TZ: "America/New_York"
- image: mysql:5.6.37
name: mysql
environment:
MYSQL_ROOT_PASSWORD: *******
MYSQL_USER: *******
MYSQL_PASSWORD: *******
MYSQL_DATABASE: *******
- image: redis:2.8.6
name: redis
command: redis-server
steps:
- checkout
- run:
name: setup
command: |
mkdir app/log
touch app/log/oink.log
chmod a+rw app/log/oink.log
touch app/rspec.xml
mkdir -p app/tmp/cache/assets/test/sprockets/v3.0
- run:
name: setup database
command: (cd ./app && gem install bundler && bundle install && bundle exec rake --trace db:setup)
- run:
name: run tests
command: |
cd ./app
mkdir /tmp/test-results
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
bundle exec rspec --format progress \
--format RspecJunitFormatter \
--out /tmp/test-results/rspec.xml \
--format progress \
$TEST_FILES
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results
Here's what happens when I open the image in a container and check the ruby version:
docker run -it 073991710092.dkr.ecr.us-east-1.amazonaws.com/signage-dev:latest-v2 bash
root#836591d2e6bf:/# ls
Gemfile bin dev home lib media opt root sbin sys usr
Gemfile.lock boot etc index.html lib64 mnt proc run srv tmp var
root#836591d2e6bf:/# ruby -v
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
Error message in CircleCi (Setup Database):
#!/bin/bash -eo pipefail
(cd ./app && gem install bundler && bundle install && bundle exec rake --trace db:setup)
ERROR: Error installing bundler:
bundler requires Ruby version >= 2.3.0.
Exited with code exit status 1
CircleCI received exit code 1

Postgres installation on Docker Ruby Alpine

I'm trying to complete the setup for my Rails application, using Docker. For development I use docker-compose.yml, and for production just the Dockerfile, as I want to deploy using Dokku (which has no support for compose).
In development everything is running fine, I'm getting my containers (app, webpacker and postgres), but in production mode my postgres container is missing... and also Dokku can't deploy correctly. I tried many ways, but nothing seems to work :(
Dockerfile
FROM ruby:2.5.5-alpine
ARG PRECOMPILEASSETS
ENV NODE_OPTIONS "--max_old_space_size=4096"
ENV SECRET_KEY_BASE=foo
RUN apk add --update --no-cache \
build-base \
git \
postgresql-dev \
postgresql-client \
imagemagick \
nodejs-current \
yarn \
python2 \
tzdata \
file
RUN gem install bundler
# Install gems
RUN mkdir /gems
WORKDIR /gems
COPY Gemfile .
COPY Gemfile.lock .
RUN bundle install -j4 --retry 3 \
# Remove unneeded files (cached *.gem, *.o, *.c)
&& rm -rf /usr/local/bundle/cache/*.gem \
&& find /usr/local/bundle/gems/ -name "*.c" -delete \
&& find /usr/local/bundle/gems/ -name "*.o" -delete
RUN yarn install
ARG INSTALL_PATH=/beweeg
ENV INSTALL_PATH $INSTALL_PATH
WORKDIR $INSTALL_PATH
COPY . .
# Precompile assets (or not)
RUN docker/potential_asset_precompile.sh $PRECOMPILEASSETS
# Expose Puma port
EXPOSE 3000
CMD ["docker/startup.sh"]
docker-compose.yml
version: '3.0'
services:
db:
image: postgres:11-alpine
ports:
- 5433:5432
environment:
POSTGRES_PASSWORD: postgres
webpacker:
image: beweeg_development
command: bin/webpack-dev-server
volumes:
- .:/beweeg:cached
ports:
- 3035:3035
app:
image: beweeg_development
build:
context: .
args:
- PRECOMPILEASSETS=NO
links:
- db
- webpacker
ports:
- 3000:3000
volumes:
- .:/beweeg:cached
As you'll see using docker-compose makes no problem, but if I want to build and run as production (without compose), then I cannot get pg installed correctly.
Previously I was using a Ruby slim image, and then using the following command:
RUN apt-get update && apt-get install -y curl gnupg
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN curl -q https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
was working nicely... but in order to reduce my images sizes, I'd prefer to stay now with Alpine.
I'm quite a noob, so please forgive me if the answer seems obvious... And thanks in advance for your help!

CircleCI YAML config fails

I have created a CircleCI config which will run my PHPUnit tests against my laravel application and that is working 100% however I am now trying to add a workflow to then SSH and deploy my app to an AWS EC2 server and I am getting the following errors:
Your config file has errors and may not run correctly:
2 schema violations found
required key [jobs] not found
required key [version] not found
However I cannot see an issue with my CircleCI config file, have I made a mistake somewhere?
version: 2
jobs:
build:
docker:
- image: circleci/php:7.1-browsers
working_directory: ~/laravel
steps:
- checkout
- run:
name: Download NodeJS v6
command: curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
- run:
name: Install SQLite and NodeJS 6
command: sudo apt-get install -y libsqlite3-dev nodejs
- run:
name: Setup Laravel testing environment variables for CircleCI test
command: cp .env.circleci .env
- run:
name: Update composer to latest version
command: composer self-update
- restore_cache:
keys:
- composer-v1-{{ checksum "composer.json" }}
- composer-v1-
- run: composer install -n --prefer-dist --ignore-platform-reqs
- save_cache:
key: composer-v1-{{ checksum "composer.json" }}
paths:
- vendor
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install NodeJS Packages
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: Create SQLite Database
command: touch database/database.sqlite
- run:
name: Migrate Laravel Database
command: php artisan migrate --database=sqlite --force
- run:
name: Run NPM
command: npm run production
# Run Laravel Server for front-end tests
- run:
name: Run Laravel Server
command: php artisan serve
background: true
- run:
name: Run PHPUnit Tests
command: vendor/bin/phpunit
deploy:
machine:
enabled: true
steps:
- run:
name: Deploy Over SSH
command: |
ssh $SSH_USER#$SSH_HOST "cd /var/www/html"
workflows:
version: 2
build-and-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
Any help is appreciated, thank you!
CircleCI has documentation for AWS deployment. Look here https://circleci.com/docs/1.0/continuous-deployment-with-aws-codedeploy/
I think your problem is with SSH authorization for AWS. You can try it locally and make sure that your authorization is successfully, and then do the same thing with your AWS.

Resources