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.
Related
I'm tasked to automate a dotnet build and deployment process on GitHub. Earlier the engineers were manually building the solution on VScode and didn't face this issue.
Here's the Error screenshot: Build Error Screenshot
Here's my workflow file:
name: Build_Artifacts_Pipeline
on:
push:
branches:
- 'cs1_pipeline_test'
jobs:
build_artifacts:
runs-on: [windows-2019]
steps:
- name: pre-checkout
run:
git config --system core.longpaths true
- name: checkout repo
uses: actions/checkout#v3
- name: Setup MSBuild
uses: microsoft/setup-msbuild#v1.1
with:
vs-version: '15.0'
- name: Create a deploy folder
run: |
cd
mkdir D:\a\CS\Deploy_Reports
- name: Setup dotnet
uses: actions/setup-dotnet#v2
with:
dotnet-version: '5.0'
DOTNET_NOLOGO: 'true'
DOTNET_CLI_TELEMETRY_OPTOUT: 'true'
- name: Setup NuGet
uses: Nuget/setup-nuget#v1
with:
nuget-version: '6.0.2'
- name: Cache NuGet Packages
uses: actions/cache#v1
id: cache
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
# - name: NuGet Restore
# if: steps.cache.outputs.cache-hit != 'true'
# run: nuget restore ./WBC.sln
- name: Build Dotnet Framework Project
run: |
nuget install ./WBC.UI.Reporting.Web/packages.config -Source http://nuget.org/api/v2
msbuild ./WBC.UI.Reporting.Web/WBC.UI.Reporting.Web.csproj /p:GenerateSerializationAssemblies=Off /t:Build /p:DeployOnBuild=true /p:Configuration=Release /p:PublishProfile=NewProfile.pubxml /p:OutDir=D:\a\CS\Deploy_Reports\
Here's my csproj: .csproj
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.
In my server, if I run
sudo ./svc.sh status
I got this
It says status is active. But Runner listener exited with error code null
In my, Github accounts actions page runner is offline.
The runner should be Idle as far as I know.
This is my workflow
name: Node.js CI
on:
push:
branches: [ dev ]
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
node-version: [ 12.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout#v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v1
with:
node-version: ${{ matrix.node-version }}
Here I don't have any build scripts because I directly push the build folder to Github repo.
How do I fix this error?
I ran into this issue when I first installed the runner application under $USER1 but configured it as a service when I was $USER2.
In the end, I ran cd /home/$USER1/actions-runner && sudo ./svc.sh uninstall to remove the service.
Changed the owner of the all files in the /home/$USER1/actions-runner/ by
sudo chown -R $USER2 /home/$USER1/actions-runner.
And ran ./config.sh remove --token $HASHNUBER (you can get this by following this page) to removed all the runner application.
I also removed it from github settings runner page.
In the end, I installed eveything again as the same user, and it worked out.
I ran into this same issue and it turned out to be a disk space problem. Make sure your server has enough allocated storage.
I've been unsucessfully trying to setup lintr package with GitHub actions (circleCi would be good too, since it's a private repo) to check PR and pushes.
My project is a book so i don't need package build checks, but only enforcing style since there are serveral authors.
I've read this readme and this article but i couldn't figure out what should a .yml file look like is this case.
Figured that out. Still need to cache lintr but at least it is working:
on:
push:
branches:
- master
pull_request:
branches:
- master
name: lint
jobs:
lint:
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout#v2
- uses: r-lib/actions/setup-r#master
- name: Install lintr
run: install.packages("lintr")
shell: Rscript {0}
- name: Lint
run: lintr::lint_dir(linters = lintr::with_defaults(assignment_linter = NULL, line_length_linter = NULL, spaces_left_parentheses_linter = NULL), pattern = '[.]R$|[.]Rmd')
shell: Rscript {0}
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'