Merge pull request #223 from hayat01sh1da/hayat01sh1da/ruby-on-rails/… #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow uses actions that are not certified by GitHub. They are | |
| # provided by a third-party and are governed by separate terms of service, | |
| # privacy policy, and support documentation. | |
| # | |
| # This workflow will install a prebuilt Ruby version, install dependencies, and | |
| # run tests and linters. | |
| name: RESTful API | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - '.github/workflows/restful-api.yml' | |
| - '.ruby-version' | |
| - 'ruby-on-rails/restful-api/.ruby-version' | |
| - 'ruby-on-rails/restful-api/Gemfile' | |
| - 'ruby-on-rails/restful-api/Gemfile.lock' | |
| - 'ruby-on-rails/restful-api/Rakefile' | |
| - 'ruby-on-rails/restful-api/**/*.rb' | |
| - 'ruby-on-rails/restful-api/**/*.rake' | |
| - 'ruby-on-rails/restful-api/**/*.yml' | |
| pull_request: | |
| paths: | |
| - '.github/workflows/restful-api.yml' | |
| - '.ruby-version' | |
| - 'ruby-on-rails/restful-api/.ruby-version' | |
| - 'ruby-on-rails/restful-api/Gemfile' | |
| - 'ruby-on-rails/restful-api/Gemfile.lock' | |
| - 'ruby-on-rails/restful-api/Rakefile' | |
| - 'ruby-on-rails/restful-api/**/*.rb' | |
| - 'ruby-on-rails/restful-api/**/*.rake' | |
| - 'ruby-on-rails/restful-api/**/*.yml' | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| timeout-minutes: 10 | |
| runs-on: ubuntu-latest | |
| services: | |
| mysql: | |
| image: mysql:9.6.0 | |
| env: | |
| DB_USERNAME: '${{ secrets.DB_USERNAME }}' | |
| MYSQL_ROOT_PASSWORD: '${{ secrets.DB_ROOT_PASSWORD }}' | |
| DB_HOST: '${{ secrets.DB_HOST }}' | |
| MYSQL_ALLOW_EMPTY_PASSWORD: yes | |
| ports: | |
| - 3306:3306 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, | |
| # change this to (see https://github.com/ruby/setup-ruby#versioning): | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| bundler-cache: true | |
| - name: Bundle Install | |
| working-directory: ./ruby-on-rails/restful-api | |
| run: | | |
| bundle config set --local path 'vendor/bundle' | |
| bundle install | |
| - name: Set up Database | |
| working-directory: ./ruby-on-rails/restful-api | |
| run: | | |
| sudo mkdir -p /var/run/mysqld | |
| sudo chown -R mysql:mysql /var/run/mysqld | |
| sudo mysqld_safe --skip-grant-tables & | |
| sleep 10 | |
| bin/setup --skip-server | |
| - name: Run RSpec | |
| working-directory: ./ruby-on-rails/restful-api | |
| run: bundle exec rspec | |
| - name: Run Brakeman | |
| working-directory: ./ruby-on-rails/restful-api | |
| run: bundle exec brakeman --no-pager |