Circle CI migration to 2.0 config - meteor

My tests work fine on circle 1.0 config. But when i try to migration to the new 2.0 config, it gives me this error -
[Error: Selenium server did not start.Another Selenium process may already be running or your java version may be out of date.]
I've already tried added jre/jdk installation. I logged in with ssh and checked - there is nothing else running on 4444 port and java is installed.. So I'm not sure whats wrong.
Here is my 1.0 config
machine:
node:
version: 4.6.2
dependencies:
pre:
- echo $METEOR_SETTINGS > settings.json
- echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
cache_directories:
- "~/.npm"
- "~/.meteor"
- "node_modules"
- "./.meteor/local/build"
- "./.meteor/local/bundler-cache"
- "./.meteor/local/isopacks"
- "./.meteor/local/plugin-cache"
- "/opt/circleci/nodejs/v4.6.2/bin"
- "/opt/circleci/nodejs/v4.6.2/lib/node_modules"
override:
- ./.testing/upgrade_chrome_version.sh
- ./.testing/cache_meteor.sh
- ./.testing/cache_npm_dependencies.sh
- ./.testing/cache_build_and_dependencies.sh
checkout:
post:
- git submodule update --init
test:
override:
- case $CIRCLE_NODE_INDEX in 0) meteor npm test ;; 1) ./tests/acceptance_run ;; esac:
parallel: true
Here is my 2.0 config
version: 2
jobs:
build:
working_directory: ~/newkeyz
docker:
- image: circleci/node:4.8.3-browsers
environment:
_JAVA_OPTIONS: "-Xms512m -Xmx1024m"
- image: selenium/standalone-chrome-debug
- image: mongo:3.4.4
steps:
- checkout
- restore_cache:
name: Restore Meteor Cache
key: meteor-cache-{{ checksum ".meteor/release" }}
- restore_cache:
name : Restore NPM Cache
key: npm-cache-{{ checksum "package.json" }}
- restore_cache:
name: Restore Meteor Package Cache
key: packages-cache-{{ checksum ".meteor/versions" }}
- run: sudo sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && sudo dpkg-reconfigure --frontend=noninteractive locales
- run: sudo apt-get install default-jdk
- run:
name: Create Settings File
command: echo $METEOR_SETTINGS > settings.json
- run: ./.testing/cache_meteor.sh
- save_cache:
name: Save Meteor Cache
key: meteor-cache-{{ checksum ".meteor/release" }}
paths:
- '~/.meteor'
- run: meteor npm install
- run: ./.testing/cache_npm_dependencies.sh
- save_cache:
name: Save NPM Cache
key: npm-cache-{{ checksum "package.json" }}
paths:
- '~/.npm'
- 'node_modules'
- run:
name: Run Test
command: ./tests/acceptance_run
- save_cache:
key: packages-cache-{{ checksum ".meteor/versions" }}
paths:
- './.meteor/local/build'
- './.meteor/local/bundler-cache'
- './.meteor/local/isopacks'
- './.meteor/local/plugin-cache'

Related

Symfony5 workflow with githubaction issue on database and migrations

Currently, I'm trying to set up a workflow with GitHub action.
I took example from https://github.com/shivammathur/setup-php/blob/master/examples/symfony-mysql.yml
My ci.yml is:
name: phpunit
on: [push]
jobs:
tests :
name: Running functional and unit test
runs-on: ubuntu-20.04
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: symfony
MYSQL_DATABASE: symfony
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: true
matrix:
php-versions: ['7.4-apache']
steps:
# —— Setup Github actions 🐙 —————————————————————————————————————————————
# https://github.com/actions/checkout (official)
- name: Checkout
uses: actions/checkout#v2
# https://github.com/shivammathur/setup-php (community)
- name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php#v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, dom, filter, gd, iconv, json, mbstring, mysqli
env:
update: true
- name: Check PHP Version
run: php -v
# —— Composer 🧙‍️ —————————————————————————————————————————————————————————
- name: Validate composer.json and composer.lock
run: composer validate
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache#v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- run: composer require symfony/runtime
- name: Run Migration && Load Fixtures
run: |
composer require --dev symfony/orm-pack
php bin/console doctrine:database:drop --if-exists --force --env=test
php bin/console doctrine:database:create --if-not-exists --env=test
php bin/console doctrine:schema:update --env=test --force || echo "No migrations found or schema update failed"
php bin/console doctrine:migrations:migrate --env=test || echo "No migrations found or migration failed"
php bin/console doctrine:fixtures:load --no-interaction
env:
DATABASE_URL: mysql://root:symfony#127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony
## —— NPM 🐱 ————————————————————————————————————————————————————————————
- name: npm install
uses: actions/setup-node#v2
with:
node-version: '14'
#registry-url: npm.fontawesome.com
- run: npm install
#env:
#NODE_AUTH_TOKEN: ${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }}
- run: npm run build
- run: php bin/phpunit
I'm getting issue in the step of Run migrations & load Fixtures':
ci error:
Ci error:
Error: Migration DoctrineMigrations\Version20220222101244 failed during Execution. Error: "An exception occurred while executing a query: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'user' already exists"
In ExceptionConverter.php line 47:
An exception occurred while executing a query: SQLSTATE[42S01]: Base table
or view already exists: 1050 Table 'user' already exists
I tried to remove schema update, this also lead into another error.
I also removed dropping database, then another error.
You create your schema twice:
First you do a doctrine:schema:update, that creates all tables like it is defined in your mapping.
Then you want to do the doctrine:migrations:migrate. I assume, that you have the CREATE TABLE definitions there, too. Thats why it complains.
If you remove this following line
php bin/console doctrine:schema:update --env=test --force || echo "No migrations found or schema update failed"
and have all setup in your migrations, it should work.

Run Sendria (MailTrap) in a Github workflow to test mail delivery in a WordPress plugin

I like to test the mail functionally from a WordPress plugin via a Github Workflow and Sendria (MailTrap)
This is my working workflow:
# Based on https://github.com/wp-cli/scaffold-command/blob/f9bad3dd7224d5684d950d31c486df70905e386f/templates/plugin-github.mustache
name: WordPress Test
on: [push]
env:
WP_TESTS_DIR: /github/home/wp-tests/wordpress-tests-lib
WP_CORE_DIR: /github/home/wp-tests/wordpress
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [7.2]
wordpress-version: [latest]
container:
image: junaidbhura/wp-tests:php-${{ matrix.php-version }}
services:
mysql:
image: mysql:5.7.27
env:
MYSQL_ROOT_PASSWORD: root
steps:
- name: Checkout repository
uses: actions/checkout#v1
- name: Install Composer dependencies
run: |
composer install --no-dev
composer global require "phpunit/phpunit=6.1.0"
composer global require "yoast/phpunit-polyfills=1.0.3"
- name: Install WordPress test suite
run: bash bin/install-wp-tests.sh wordpress_test root root mysql ${{ matrix.wordpress-version }}
- name: Tests
run: $HOME/.composer/vendor/bin/phpunit --config=phpunit-integration.xml
This workflow
checkout my plugin
install composer dependencies
install the WordPress test suite
run the Tests (which should contain mail tests)
Now I like to add Sendria to this flow by adding this action right above the first step:
- name: Start Sendira
uses: upgundecha/start-sendria-github-action#v1.0.0
with:
smtp-port: 1025
http-port: 1080
To test that Sendria is running I check the endpoint via curl with an additional step:
- name: Test
run: |
curl -LI http://127.0.0.1:1080
And this "Test" fails:
I tried the workflow locally with act where this step worked but have no idea how to get this working on Github.
I've also created a test repo on Github here.

.NET Core embedded resources + Gitlab: ERROR: No files to upload

I am working on the .NET Core solution below:
and I am using the Gitlab CI definition below:
.gitlab-ci.yml:
image: docker:stable
services:
- docker:dind
stages:
- test
- build
- deploy-db
- deploy
variables:
DOCKER_REGISTRY: "our.registry.eu"
IMAGE_NAME: "${DOCKER_REGISTRY}/membercreditor"
# secrets are on GitLab environment variables (settings > ci/cd)
RANCHER_ENV: 1a10
RANCHER_STACK: api
RANCHER_SVC: membercreditor
RANCHER_DEV_KEY: a dev key
RANCHER_DEV_URL: http://our.dev.rancher.io:8080
RANCHER_PREPROD_KEY: a preprod key
RANCHER_PREPROD_URL: http://our.preprod.rancher.io:8080
RANCHER_PROD_KEY: a prod key
RANCHER_PROD_URL: http://our.prod.rancher.io:8080
.test:
stage: test
image: mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
script:
- dotnet test ./Rm.MemberCreditor.Api.Tests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/
- dotnet test ./Rm.MemberCreditor.Domain.Tests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/ /p:MergeWith=../Rm.MemberCreditor.Api.Tests/TestResults/coverage.json
- dotnet test ./Rm.MemberCreditor.IntegrationTests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/ /p:MergeWith=../Rm.MemberCreditor.Domain.Tests/TestResults/coverage.json
coverage: '/Total[ |]+(\d+[,.]\d+)%/'
artifacts:
reports:
junit: ./*.Tests/TestResults/*.xml
.build:
stage: build
tags:
- dind
script:
- docker build -t $IMAGE_NAME:$APP_VERSION -f Dockerfile .
- docker login $DOCKER_REGISTRY -u svc_finance_revmgt -p $SVC_FINANCE_REVMGT_TOKEN
- docker push $IMAGE_NAME:$APP_VERSION
.deploy-db:
stage: deploy-db
image: mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
script:
- export CONNECTIONSTRINGS__MEMBERCREDITOR=$CONNECTIONSTRINGS__MEMBERCREDITOR
- export SECRETS__CS_MEMBERCREDITOR=$SECRETS__CS_MEMBERCREDITOR
- dotnet tool restore
- dotnet ef database update -p ./Rm.MemberCreditor.Data.Migrations -s ./Rm.MemberCreditor.Api -v
.deploy:
stage: deploy
image: cdrx/rancher-gitlab-deploy
script:
- upgrade --rancher-key $RANCHER_KEY
--rancher-secret $RANCHER_SECRET
--rancher-url $RANCHER_URL
--environment $RANCHER_ENV
--stack $RANCHER_STACK
--service $RANCHER_SVC
--new-image $IMAGE_NAME:$APP_VERSION
###########################
### Merge Requests
###########################
test-merge-request:
extends: .test
only:
refs:
- merge_requests
###########################
### Integration
###########################
test-integration:
extends: .test
environment:
name: integration
only:
- develop
build-integration:
extends: .build
environment:
name: integration
dependencies:
- test-integration
before_script:
- APP_VERSION=latest-integration
only:
- develop
deploy-db-integration:
extends: .deploy-db
environment:
name: integration
dependencies:
- build-integration
before_script:
- export ASPNETCORE_ENVIRONMENT=Integration
only:
- develop
deploy-integration:
extends: .deploy
environment:
name: integration
dependencies:
- deploy-db-integration
before_script:
- APP_VERSION=latest-integration
- RANCHER_KEY=$RANCHER_DEV_KEY
- RANCHER_SECRET=$RANCHER_DEV_SECRET
- RANCHER_URL=$RANCHER_DEV_URL
only:
- develop
###########################
### UAT
###########################
test-uat:
extends: .test
environment:
name: uat
only:
- master
build-uat:
extends: .build
environment:
name: uat
dependencies:
- test-uat
before_script:
- APP_VERSION=latest-uat
only:
- master
deploy-db-uat:
extends: .deploy-db
environment:
name: uat
dependencies:
- build-uat
before_script:
- export ASPNETCORE_ENVIRONMENT=Uat
only:
- master
deploy-uat:
extends: .deploy
environment:
name: uat
dependencies:
- deploy-db-uat
before_script:
- APP_VERSION=latest-uat
- RANCHER_KEY=$RANCHER_PREPROD_KEY
- RANCHER_SECRET=$RANCHER_PREPROD_SECRET
- RANCHER_URL=$RANCHER_PREPROD_URL
only:
- master
###########################
### Production
###########################
build-prod:
extends: .build
environment:
name: production
before_script:
- APP_VERSION=$CI_COMMIT_TAG
only:
- /^\d+.\d+.\d+$/
except:
- /^(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]).*#/
deploy-db-prod:
extends: .deploy-db
environment:
name: production
dependencies:
- build-prod
before_script:
- export ASPNETCORE_ENVIRONMENT=Production
only:
- /^\d+.\d+.\d+$/
except:
- /^(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]).*#/
deploy-prod:
extends: .deploy
environment:
name: production
when: manual
dependencies:
- deploy-db-prod
before_script:
- APP_VERSION=$CI_COMMIT_TAG
- RANCHER_KEY=$RANCHER_PROD_KEY
- RANCHER_SECRET=$RANCHER_PROD_SECRET
- RANCHER_URL=$RANCHER_PROD_URL
only:
- /^\d+.\d+.\d+$/
except:
- /^(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]).*#/
When the Gitlab is running the test-merge-request, I am getting the error below:
Fetching changes with git depth set to 50...
00:02
Initialized empty Git repository in /builds/finance/products/revenuemgmt/modules/membercreditor/.git/
Created fresh repository.
From https://our.org/finance/products/revenuemgmt/modules/membercreditor
* [new ref] refs/merge-requests/38/head -> refs/merge-requests/38/head
* [new ref] refs/pipelines/355543 -> refs/pipelines/355543
Checking out 603e9a2c as refs/merge-requests/38/head...
Skipping Git submodules setup
$ dotnet test ./Rm.MemberCreditor.Api.Tests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/
00:12
FSC : error FS0078: Unable to find the file 'Legacy/Queries/GetOrderRelatedInfoForAccountingEntryCreation.sql' in any of /builds/finance/products/revenuemgmt/modules/membercreditor/Rm.MemberCreditor.Data [/builds/finance/products/revenuemgmt/modules/membercreditor/Rm.MemberCreditor.Data/Rm.MemberCreditor.Data.fsproj]
Uploading artifacts...
00:02
WARNING: ./*.Tests/TestResults/*.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1
GetOrderRelatedInfoForAccountingEntryCreation.sql is defined as an embedded resource, I tried to force to copy the file to the output but I still am getting the same very same error.
I am not sure why this post has been down-voted, but fun fact, seems there is a bug in Rider 2019.3.1.
The issue arose because even though the file was showing up as GetOrderRelatedInfoForAccountingEntryCreation.sql in Rider aka pascal case it was actually written as a camel case (i.e. getOrderRelatedInfoForAccountingEntryCreation.sql) on the disk, go figure.
Once the name adjusted to pascal for the actual file on the disk, everything worked fine.

Symfony app with redis fails in Gitlab CI

I'm usin REDIS in my Symfony app and today Gitlab CI stopped working with error (after composer install and cache clear):
!! In AbstractConnection.php line 155:
!!
!! php_network_getaddresses: getaddrinfo failed: Name does not resolve [tcp://
!! redis:6379]
Here is my gitlab-ci.yml:
image: docker:latest
services:
- docker:dind
- name: redis:5-alpine
alias: redis
stages:
- dependencies
- build-docker
variables:
#REDIS_PORT: 6379 - doesn't help
#REDIS_HOST: redis - doesn't help
dependencies:
stage: dependencies
image: docker
cache:
paths:
- bin
- vendor
- config/packages
- public/bundles
policy: push
script:
- sh ./run composer install --ignore-platform-reqs --prefer-dist --optimize-autoloader
except:
- tags
Gitlab CI works fine until today's morning... Can anyone help? Thanks a lot.

start a system service using cron - SaltStack

I would like to override default tmp.conf at /usr/lib/tmpfiles.d/ with /etc/tmpfiles.d/tmp.conf and run the cron job at midnight on everyday. The service need to run as systemd-tmpfiles --clean. How can I run the service at midnight, Somebody help me please?
Sample code:
tmp.conf:
file.managed:
- name: /etc/tmpfiles.d/tmp.conf
- source: salt://tmp/files/tmp.conf
- user: root
- mode: 644
- require:
- user: root
run_systemd-tmpfiles:
cron.present:
- user: root
- minute: 0
- hour: 0
- require:
- file: tmp.conf
enable_tmp_service:
service.running:
- name: systemd-tmpfiles --clean
- enable: True
- require:
- cron: run_systemd-tmpfiles
If you just want the command to run as part of a cron, you would need to have that cron.present setup to run the command.
cron_systemd-tmpfiles:
cron.present:
- name: systemd-tmpfiles --clean
- user: root
- minute: 0
- hour: 0
- require:
- file: tmp.conf
If you then want to run it in this state, you can't use the tmpfile.service, you would just run the command through a cmd.run, or if you only want it run when the file.managed changes, you would use cmd.wait
run tmpfiles:
cmd.wait:
- name: systemd-tmpfiles --clean
- listen:
- file: tmp.conf
But systemd-tmpfiles.service is already run on boot if you are using systemd, so there is no reason to enable it again. And when it runs during the beginning of the boot process, it will run the same way tmpfile --clean runs.

Resources