From 8439441f7523321c2ca5feba03a2dae56cf689cb Mon Sep 17 00:00:00 2001 From: Santosh Wadghule Date: Sat, 5 Aug 2023 16:23:19 +0530 Subject: [PATCH] Fix issue with MySQL server --- .github/workflows/main.yml | 39 ++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e7f2c4d..da79ad0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,18 +11,28 @@ jobs: services: postgres: - image: postgres:12.1-alpine + image: postgres + env: + POSTGRES_HOST_AUTH_METHOD: trust ports: - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 mysql: - image: mysql:latest + image: mysql:5.7 env: - MYSQL_ROOT_PASSWORD: rootpassword + MYSQL_ROOT_PASSWORD: password ports: - - 3306:3306 + - 32574:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 steps: + - name: Show postgres version + run: psql -h localhost -U postgres -d postgres -c 'SHOW server_version' + - name: Checkout code uses: actions/checkout@v2 @@ -38,21 +48,26 @@ jobs: - name: Install dependencies run: bundle install - - name: Set up Code Climate Test Reporter + - name: Start PostgreSQL service run: | - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - chmod +x ./cc-test-reporter - ./cc-test-reporter before-build + docker-compose up -d postgres + sleep 5 # Wait for a few seconds for the PostgreSQL server to start - name: Create MySQL and PostgreSQL databases run: | - mysql -u root -e "CREATE DATABASE set_as_primary_test;" - mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql + sudo apt-get install -y mysql-client + mysql --host 127.0.0.1 --port 32574 -uroot -ppassword -e "CREATE DATABASE set_as_primary_test;" createdb set_as_primary_test - name: Run tests run: bundle exec rake + - name: Set up Code Climate Test Reporter + run: | + curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + chmod +x ./cc-test-reporter + ./cc-test-reporter before-build + - name: Upload test coverage results to Code Climate if: always() && ${{ github.ref == 'refs/heads/master' }} # Adjust the branch name if needed - run: ./cc-test-reporter after-build --debug --exit-code ${{ job.status }} + run: ./cc-test-reporter after-build --debug --exit-code ${{ job.status }} \ No newline at end of file