Frappe github actions pipeline

Hi everyone,

I am trying to make a github actions pipeline for a frappe project and I am using github runners. So I have to go throughout the frappe setup on every push.

all the steps are working except for the mariaDB setup , I am facing an issue regarding the setup of the db root default password as the pipeline is happening in a non-interactive mode, I have no prompt for setting this password.

I’ve tried so many approaches to do this

Approach 1.

    `export DEBIAN_FRONTEND=noninteractive
        sudo debconf-set-selections <<< 'mariadb-server-10.3 mysql-server/root_password password myPassword'
        sudo debconf-set-selections <<< 'mariadb-server-10.3 mysql-server/root_password_again password myPassword'

Approach 2 : change the password after install

      sudo systemctl stop mariadb
       sudo mysqld_safe --skip-grant-tables &
       mysql -u root <<<"
              use mysql;
             update user SET PASSWORD=PASSWORD("myPassword") WHERE USER='root';
              flush privileges;
              exit 
            sudo systemctl start mariadb 

But when I run

bench new-site example.com --mariadb-root-password myPassword --admin-password myAdminPassword

I get this error:
Access Denied for User 'root'@'localhost' (using password: YES)

Is there any better approach to do this please? knowing that if I use a mariaDB service in my pipeline I will have to append the /etc/mysql/my.cnf to allow it to work with frappe.

Thanks a lot !

https://docs.github.com/en/actions/configuring-and-managing-workflows/about-service-containers

Try service container for mariadb. Place the additional config in your github repo and mount it as volume.

e.g.

services:
  mariadb:
    image: mariadb:10.3
    env:
      - MYSQL_ROOT_PASSWORD=myPassword
    options: -v ${{ github.workspace }}/frappe.cnf:/etc/mysql/conf.d/frappe.cnf

For further container specific setup refer frappe_docker/development at main · frappe/frappe_docker · GitHub

1 Like

Thanks a lot for your answer , the approach is so interesting and I tried it.
I Successfully mounted my extra config file inside /etc/mysql/conf.d , the only issue I have now is that the config is not taken in consideration . I am still getting this error :

For key character_set_server. Expected value utf8mb4, found value latin1
check_suite_focus=true#step:7:141)For key collation_server. Expected value utf8mb4_unicode_ci, found value latin1_swedish_ci

check_suite_focus=true#step:7:142)================================================================================

check_suite_focus=true#step:7:143)Creation of your site - example.com failed because MariaDB is not properly

check_suite_focus=true#step:7:144)configured. If using version 10.2.x or earlier, make sure you use the

  check_suite_focus=true#step:7:145)the Barracuda storage engine.

check_suite_focus=true#step:7:146)
check_suite_focus=true#step:7:147)Please verify the settings above in MariaDB's my.cnf. Restart MariaDB. And

check_suite_focus=true#step:7:148)then run `bench new-site example.com` again.
check_suite_focus=true#step:7:149)

and here is my extra configuration (which I mmounted on /etc/mysql/conf.d/frappe.cnf

[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

[mysql]
default-character-set = utf8mb4

I think that my file is not included in /etc/mysql/my.cnf
How can I check that this line figures inside /etc/mysql/my.cnf
includedir /etc/mysql/conf.d/

Thanks again!

Can you share the yml?

name: CI


on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
 
  build:
  
    runs-on: ubuntu-18.04
    services:
      mariadb:
        image: mariadb:10.3
        ports:
          - 3306:3306
        env:
          MYSQL_USER: user
          MYSQL_PASSWORD: frappe
          MYSQL_DATABASE: test
          MYSQL_ROOT_PASSWORD: frappe
        options:  -v ${{ github.workspace }}/frappe.cnf:/etc/mysql/conf.d/frappe.cnf --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3  
   
    steps:
    - uses: actions/checkout@v2

    - name: Shutdown Ubuntu MySQL (SUDO)
      run: sudo service mysql stop # Shutdown the Default MySQL, "sudo" is necessary, please not remove it

    - name: Getting dependencies
      run: |
        alias python=python3
        alias pip=pip3
        sudo apt install git python-dev redis-server 
        sudo apt-get install -y python-wheel
        sudo apt-get install software-properties-common
        sudo apt-get install python3-dev
        sudo apt-get install python3-setuptools python3-pip
        sudo apt-get install virtualenv
        sudo apt-get install libmysqlclient-dev
        
      
    - name: getting other dependencies
      run: |
        sudo apt-get install redis-server
        sudo apt-get install curl
        curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
        sudo apt-get install -y nodejs
        sudo apt install yarn
        pip3 install wheel
        pip install wheel
        
        
 
    - name: initialize the frappe 
      run: |
        pip3 install frappe-bench
        export PATH=$PATH:~/.local/bin
        bench --version
        bench init --frappe-branch version-12 --python /usr/bin/python3.6 frappe-bench
        cd frappe-bench
        ls -alt
        
        bench new-site example.com --mariadb-root-password frappe  --admin-password frappe --no-mariadb-socket
        bench get-app https://github.com/yaacine/Frappe_Tuto.git
        bench --site example.com install-app library_management

Note: If your workflows use Docker container actions or service containers, then you must use a Linux runner:

  • If you are using GitHub-hosted runners, you must use the ubuntu-latest runner.
  • If you are using self-hosted runners, you must use a Linux machine as your runner and Docker must be installed.

Also try using the frappe/bench:latest image. It has all the prerequisites installed

In case of mariadb cold start, it takes few seconds to configure and start mariadb container.

1 Like

I don’t know if I am missing something but I think that the frappe/bench:latest does not come with a pre-installed maraidb service so I have to use another mariadb image and then specify it as a host

bench set-mariadb-host mariadb

in this case , I think that this would not resolve the issue
Am I right , please ?

And again thanks for your help

MariaDB issue will not be resolved by using frappe/bench:latest image. It will just not install things during CI.

I’ll have to try it. instead of options: may by using volumes:

Hello Yacine,

I wish you are at your best, I’m trying to do the same thing here and passed by your post. Now I’m facing the same issue. Did you find a solution for it yet?

Thanks in advance.

Mostafa Yasin
Software Engineer