Installing Mailcatcher inside Github Workflow takes forever - ruby

Update 1: Got mailatcher working but running every test now takes 4 minutes.
I need to do some Mailcatcher Acceptance Tests inside a Github Workflow. All other Tests are running fine. I also got the Mailcatcher running but installing the gem with all dependencies takes around 4 Minutes(!) which is not acceptable.
Is there a way to speed this up? The environment is LAMP.
So this is the YAML file:
name: Codeception Tests
on: [push]
jobs:
tests:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: true
matrix:
operating-system: [ubuntu-latest]
php: ["7.4"]
name: PHP ${{ matrix.php }} Test on ${{ matrix.operating-system }}
env:
php-ini-values: post_max_size=32M
steps:
- name: Checkout
uses: actions/checkout#v2
with:
ref: "develop"
- name: Checkout Tests
uses: actions/checkout#v2
with:
repository: xxx/tests
ref: "develop"
path: tests
- name: Install Ruby & run mailcatcher
run: |
sudo gem install mailcatcher
mailcatcher
The composer.json
{
"name": "tests",
"description": "Tests",
"license": "GPL-2.0-or-later",
"require-dev": {
"codeception/codeception": "~4.0",
"codeception/module-asserts": "^1.0",
"codeception/module-webdriver": "^1.0",
"codeception/module-phpbrowser": "^1.0",
"codeception/module-filesystem": "^1.0",
"codeception/module-db": "^1.0",
"joomla-projects/joomla-browser": "#dev",
"joomla-projects/selenium-server-standalone": "~v3",
"fzaninotto/faker": "^1.6",
"behat/gherkin": "^4.4.1",
"phing/phing": "2.*",
"captbaritone/mailcatcher-codeception-module": "^2.2"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/stell/joomla-browser"
}
]
}
The Acceptance Suite:
class_name: AcceptanceTester
modules:
enabled:
- Asserts
- JoomlaBrowser
- Helper\Acceptance
- DbHelper
- Filesystem
- MailCatcher
config:
MailCatcher:
url: "http://127.0.0.1"
port: "1080"
JoomlaBrowser:
url: "http://127.0.0.1:800

Related

Need to post github action steps test result on slack channal based on environment

I want to post my test result on slack channel based on envornment using github action.
But when i run - name: Post Status to Slack - Prod & - name: Post Status to Slack - Stage both get executed. In slack channel its posting both message.
I think written if condition under - name is been ignored.
name: Test - 1
env:
REPO_OWNER: XXX
REPO_NAME: XXX
GITHUB_TOKEN: XXX
on:
workflow_dispatch:
inputs:
typeOfTesting:
type: choice
description: Select Type of Test
default: "stage-test-Uptime"
required: true
options:
- stage-test-Uptime
- prod-test-Uptime
jobs:
Uptime-Run:
runs-on: ubuntu-latest
steps:
- name: Selection of Testing type
run: |
echo "Test Name: ${{ github.event.inputs.typeOfTesting }}"
- name: Checkout
uses: actions/checkout#v2
- uses: actions/setup-node#v1
with:
node-version: 16.13.0
- name: Install
run: npm install
- name: Run stage-test-Uptime
run: npm run stage-test-Uptime
- name: Post Status to Slack - Stage
if: ${{ github.event.inputs.typeOfTesting }} == "stage-test-Uptime"
id: slack
uses: slackapi/slack-github-action#v1.18.0
with:
# For posting a rich message using Block Kit
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "GitHub Action build result: * ${{ job.status }}*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "XXX"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "XXXX"
}
}
]
}
env:
SLACK_WEBHOOK_URL: https://hooks.slack.com/services/XXX/XXX/XXX
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
- name: Post Status to Slack - Prod
if: ${{ github.event.inputs.typeOfTesting }} == "prod-test-Uptime"
id: slack1
uses: slackapi/slack-github-action#v1.18.0
with:
# For posting a rich message using Block Kit
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "GitHub Action build result: * ${{ job.status }}*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "XXX"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "XXX"
}
}
]
}
env:
SLACK_WEBHOOK_URL: https://hooks.slack.com/services/XXX/CCCC/SSSS
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

Getting "Error: Pattern mochawesome-report/*.json matched no report files" error only when test running in github action

I am able to merge and generate reports in my local but when I am running mt test into GitHub action through error ERROR: Failed to merge reports. I never used GitHub action before so maybe I have made a mistake. Any suggestions are welcome.
Here is my cypress.json file
{
"reporter": "cypress-mochawesome-reporter",
"reporterOptions": {
"reportDir": "cypress/Reports",
"charts": true,
"overwrite": false,
"html": false,
"json": true,
"reportPageTitle": "Legrande Cypress",
"reportFilename": "Legrande Cypress Test Report",
"embeddedScreenshots": true,
"inlineAssets": true
},
"defaultCommandTimeout": 30000,
"retries": {
"runMode": 1,
"openMode": 1
},
"video": false,
"scrollBehavior": "nearest",
"chromeWebSecurity": false,
}
Here is my package.json file.
{
"name": "cypressautomation",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"delete:reportFolder": "rm -rf mochawesome-report/",
"test:cli": "npm run delete:reportFolder && cypress run",
"merge:reports": "mochawesome-merge mochawesome-report/*.json > cypress-combined-report.json",
"create:html:report": "npm run merge:reports && marge --reportDir TestReport cypress-combined-report.json",
"cy:run": "cypress run",
"record-test": "cypress run --record --key ######################"
},
"reporter": "cypress-mochawesome-reporter",
"reporterOptions": {
"reportDir": "cypress/Reports",
"charts": true,
"reportPageTitle": "My Test Suite",
"embeddedScreenshots": true,
"inlineAssets": true
},
"video": false,
"author": "weblylab",
"license": "ISC",
"devDependencies": {
"cypress": "^9.5.0",
"cypress-file-upload": "^5.0.2",
"cypress-mochawesome-reporter": "^2.2.0",
"cypress-slack-reporter": "^1.2.1",
"cypress-xpath": "^1.6.1",
"faker": "^5.5.3",
"i": "^0.3.6",
"mocha": "^8.4.0",
"mochawesome": "^6.2.2",
"mochawesome-merge": "^4.2.0",
"mochawesome-report-generator": "^5.2.0",
"tsconfig-paths": "^3.9.0"
},
"dependencies": {
"#auth0/auth0-spa-js": "^1.13.6",
"#types/bluebird": "^3.5.33",
"#types/lodash": "^4.14.168",
"chai": "^4.3.0",
"cypress-iframe": "^1.0.1",
"cypress-skip-test": "^1.0.0",
"delay": "^5.0.0",
"Faker": "^0.7.2",
"lodash": "^4.17.21",
"moment": "^2.29.1",
"resolve-url": "^0.2.1",
"save": "^2.4.0",
"source-map-resolve": "^0.6.0",
"urix": "^0.1.0",
"xlsx": "^0.17.0"
}
}
And here is my cypress.yml file that I used for GitHub action.
name: GitHub Actions Demo
on:
schedule:
- cron: "0 0 * * *"
push:
branches:
- 'master'
jobs:
cypress-test:
name: Run on windows
runs-on: windows-latest
steps:
- uses: actions/checkout#v2
- name: Install dependencies
run: |
npm install
npm install --dev
npm run record-test
- name: Copy execution test screenshots
run: |
mkdir public
cp -r cypress/screenshots public/screenshots
- name: Merge test reports
run: npm run merge:reports
- name: Generate HTML reports
run: npm run create:html:report
I am getting the below error for merging reports. In my local machine, it working fine.
Did you try to change the
"reportDir": "cypress/Reports",
to the mochawesome-report
"reportDir": "cypress/reports/mochawesome-report",
Also, check your plugins/index.js
on('before:run', async (details) => {
console.log('Override before:run');
await beforeRunHook(details);
// Note: if you are using other than Windows remove below two lines, start with await exec
//await exec("IF EXIST cypress\\screenshots rmdir /Q /S cypress\\screenshots")
//await exec("IF EXIST cypress\\reports rmdir /Q /S cypress\\test-reports")
//await exec("IF EXIST cypress\\reports rmdir /Q /S cypress\\reports")
});
on('after:run', async () => {
console.log('Override after:run');
// Note: if you are using other than Windows remove below line, starts with await exec
//await exec("npx jrm ./cypress/reports/junitreport.xml ./cypress/test-reports/junit-report-[hash].xml");
//await exec("npx jrm ./cypress/reports/junitreport.xml ./cypress/reports/junit-report-[hash].xml");
await afterRunHook();
});
I had similar issues and solved some of them with
reporter: '../node_modules/cypress-mochawesome-reporter',
video: true,
reporterOptions: {
reportDir: 'reports/mochawesome',
That said, I found a reference saying that you need a relative directory now for reportDir, so I suspect that my reportDir above is only working because I happened to select the default directory used by Mochawesome.

Github action deployment fails because of not matching composer-runtime-api ^2.0.0 but actions/checkout#v2 is used

Github action deployment fails because of not matching composer-runtime-api ^2.0.0 even though actions/checkout#v2 is used that uses composer v2
laravel.yml:
name: Deploy to staging
on:
push:
branches: [ staging ]
jobs:
vapor:
name: Check out, build and deploy using Vapor
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: ubient/laravel-vapor-action#master
env:
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
with:
args: "deploy staging"
composer.json:
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^7.4",
"aws/aws-sdk-php": "3.166.2",
"barryvdh/laravel-dompdf": "^0.8.7",
"bensampo/laravel-enum": "^3.2.0",
"doctrine/dbal": "^2.10",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.0",
"laravel/helpers": "^1.3",
"laravel/sanctum": "^2.4",
"laravel/tinker": "^2.5",
"laravel/vapor-cli": "^1.12",
"laravel/vapor-core": "^2.8",
"laravel/vapor-ui": "^1.0",
"owen-it/laravel-auditing": "^10.0",
"pusher/pusher-php-server": "^4.1",
"sentry/sentry-laravel": "^2.3",
"spatie/laravel-permission": "^3.16",
"spatie/laravel-tags": "^2.7"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.8",
"beyondcode/laravel-dump-server": "^1.4",
"facade/ignition": "^2.5",
"fzaninotto/faker": "^1.9.1",
"laravel/horizon": "^5.6",
"laravel/sail": "^1.1",
"laravel/telescope": "^4.4.0",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"extra": {
"laravel": {
"dont-discover": [
"barryvdh/laravel-ide-helper",
"laravel/telescope"
]
}
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
},
"classmap": [
],
"files": [
"bootstrap/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover --ansi"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"#php artisan ide-helper:generate",
"#php artisan ide-helper:meta"
],
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate --ansi"
]
}
}
error:
Building project...
==> Validating Manifest File
==> Copying Application Files
==> Harmonizing Configuration Files
==> Setting Build Environment
==> Executing Build Commands
==> Running Command: composer install --no-dev
Loading composer repositories with package information
Installing dependencies from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for jean85/pretty-package-versions 2.0.3 -> satisfiable by jean85/pretty-package-versions[2.0.3].
- jean85/pretty-package-versions 2.0.3 requires composer-runtime-api ^2.0.0 -> no matching package found.
Problem 2
- jean85/pretty-package-versions 2.0.3 requires composer-runtime-api ^2.0.0 -> no matching package found.
- sentry/sentry 3.2.0 requires jean85/pretty-package-versions ^1.5|^2.0.1 -> satisfiable by jean85/pretty-package-versions[2.0.3].
- Installation request for sentry/sentry 3.2.0 -> satisfiable by sentry/sentry[3.2.0].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
- It's a private package and you forgot to add a custom repository to find it
The deployment command is 'composer install --no-dev' . At first, I was using actions/checkout#v1 when having this error, then I moved to actions/checkout#v2 once I understood that composer v2 is on checkout#v2 vs v1 on checkout#v1, but the problem persists... Any hints on why this is happening would be welcome.
Edit: I am able to run the deployment from my local device without any issues(once I moved to composer v2).
as #bk2204 helped me to realize my faulty assumption that checkout#v2 sets composer to v2 I was able to resolve my problem by changing the laravel.yml deployment instructions as follows:
name: Deploy to staging
on:
push:
branches: [ staging ]
jobs:
vapor:
name: Check out, build and deploy using Vapor
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Setup PHP (w/ extensions) & Composer
uses: shivammathur/setup-php#v2
with:
php-version: 7.4
tools: pecl
extensions: bcmath, ctype, fileinfo, json, mbstring, openssl, pdo, tokenizer, xml, zip, pcntl
coverage: none
- name: Obtain 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 }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Vapor CLI Globally
run: composer global require laravel/vapor-cli
- name: Install Composer dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader --no-dev
- name: Deploy using Laravel Vapor
env:
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
run: /home/runner/.composer/vendor/bin/vapor deploy staging

Prefixes when using docker-compose run -rm

I am working on a PHP project using Laravel and I have several utilities in my docker-compose:
composer:
image: composer:latest
container_name: composer
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
depends_on:
- php
networks:
- laravel
npm:
image: node:13.7
container_name: npm
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
entrypoint: ["npm"]
With this I have to prefix each command with docker-compose run -rm such as:
docker-compose run -rm npm update
Is there a way to simply have an environment that set some aliases (npm, grunt, composer, mysql...) when I am in that project in VSCode?
You can add a task in VS code
Lots of tools exist to automate tasks like linting, building, packaging, testing, or deploying software systems. Examples include the TypeScript Compiler, linters like ESLint and TSLint as well as build systems like Make, Ant, Gulp, Jake, Rake, and MSBuild.
VScode Task
it should be placed inside .vscode
├── docker-compose.yml
└── .vscode
└── tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "npm",
"type": "shell",
"command": "docker-compose run ${input:npm}",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "composer",
"type": "shell",
"command": "docker-compose run ${input:compose}",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"inputs": [
{
"id": "npm",
"description": "npm argument:",
"default": "npm",
"type": "promptString"
},
{
"id": "compose",
"description": "compose argument:",
"default": "composer",
"type": "promptString"
}
]
}
Now All set, all you need to press
Ctrl+Shift+B and both task will be listed, select and execute the task.

Permission denied in Bitbucket pipeline

I am having trouble getting a bitbucket pipeline to run correctly, it keeps throwing a permission denied error and I can't for the life of me see why?
This is my composer file:
{
"name": "pswebsolutionsltd/psadoptables",
"description": "Framework for Building Adoptable Sites",
"version": "0.0.1",
"type": "project",
"homepage": "https://www.pswebsolutions.co.uk/",
"authors": [
{
"name": "Paul Cook",
"email": "paul.cook#pswebsolutions.co.uk",
"homepage": "https://www.pswebsolutions.co.uk/"
}
],
"support": {
"issues": "https://bitbucket.org/pswebsolutionsltd/psadoptables/issues?status=new&status=open",
"wiki": "https://bitbucket.org/pswebsolutionsltd/psadoptables/wiki/",
"source": "https://bitbucket.org/pswebsolutionsltd/psadoptables/src"
},
"scripts": {
"test": [
"#clean",
"#load",
"#clearCache",
"#phpCS",
"#phpUnit",
"#phpDoc"
],
"clean": "composer clear-cache",
"load": "composer dump-autoload -o",
"clearCache": "rm -rf cache && mkdir cache",
"phpUnit": "phpunit --configuration phpunit.xml tests",
"phpDoc": "phpdoc",
"phpCS": "phpcs --config-set default_standard PSR2 phpcs src/ --extensions=php && phpcs tests/ --extensions=php",
"phpCBF": "phpcbf ./ --extensions=php"
},
"autoload": {
"psr-4": {
"AdoptableFramework\\": "src/",
"AdoptableFramework\\Tests\\": "tests/",
"AdoptableFramework\\Extend\\": "src/extend/"
}
},
"require": {
"matthiasmullie/minify": "^1.3"
},
"require-dev": {
"phpunit/phpunit": "5.7",
"phpdocumentor/phpdocumentor": "2.*",
"squizlabs/php_codesniffer": "3.*"
}
}
This is my bitbucket pipeline config file:
P S Adoptable build configuration for PHP.
pipelines:
default:
- step:
name: php56-mysql57
image: php:5.6-apache
script:
# update apt
- apt-get update && apt-get install -y unzip
# install mysqli
- apt-get install -y mysql-client
- docker-php-ext-install mysqli
# install and configure composer
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer install --no-interaction --no-progress --prefer-dist
- composer test
services:
- mysql57
definitions:
services:
mysql57:
image: mysql:5.7
environment:
MYSQL_DATABASE: psadoptables
MYSQL_ROOT_PASSWORD: root
The output is:
sh: 1: phpcs: Permission denied
Script phpcs --config-set default_standard PSR2 phpcs src/ --extensions=php && phpcs tests/ --extensions=php handling the phpCS event returned with error code 126
Is there some trick I am missing? Any help would be greatly appreciated!
I would suspect the permission of composer in /usr/local/bin or the directory itself. For debugging you could add a "ls -l /usr/local/bin/composer" in the pipeline config, right after the installation of composer.

Resources