diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..8f55ed0 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,77 @@ +name: CI +'on': + - push +jobs: + code_checks: + runs-on: ubuntu-latest + container: + image: 'ruby:3.2.2' + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: 20.x + registry-url: 'https://registry.npmjs.org' + # - name: Install MySQL + # uses: mirromutth/mysql-action@v1.1 + # with: + # host port: 3307 # Optional, default value is 3306. The port of host + # container port: 3307 # Optional, default value is 3306. The port of container + # character set server: 'utf8mb4' # Optional, default value is 'utf8mb4'. The '--character-set-server' option for mysqld + # collation server: 'utf8mb4_general_ci' # Optional, default value is 'utf8mb4_general_ci'. The '--collation-server' option for mysqld + # mysql version: '5.7.44' # Optional, default value is "latest". The version of the MySQL + # mysql database: 'homework_assignment_2024_test' # Optional, default value is "test". The specified database which will be create + # mysql root password: password # Required if "mysql user" is empty, default is empty. The root superuser password + # mysql user: 'rails_user' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too + # mysql password: password # Required if "mysql user" exists. The password for the "mysql user" + - name: Start MySQL + uses: shogo82148/actions-setup-mysql@v1 + with: + mysql-version: "5.7.44" + auto-start: true + root-password: password #The password for the root user. + user: rails_user # The name of the new user. + password: password # The password for the new user. + # database: homework_assignment_2024_test # The name of the new database. + - run: mysql -uroot -e 'SELECT version()' + - name: Gem cache + id: cache-bundle + uses: actions/cache@v1 + with: + path: vendor/bundle + key: 'bundle-${{ hashFiles(''**/Gemfile.lock'') }}' + - name: Bundle install + env: + RAILS_ENV: test + run: | + gem install bundler + bundle install --jobs 4 --retry 3 --path vendor/bundle + - name: Install yarn + run: npm install -g yarn + - name: Get yarn cache dir + id: yarn-cache-dir + run: 'echo "::set-output name=dir::$(yarn cache dir)"' + - name: Yarn cache + id: cache-yarn + uses: actions/cache@v1 + with: + path: '${{ steps.yarn-cache-dir.outputs.dir }}' + key: 'yarn-${{ hashFiles(''**/yarn.lock'') }}' + - name: Yarn install + run: yarn install + - name: 'Setup DB, Run tests' + env: + RAILS_ENV: test + run: bundle exec rails db:create db:schema:load + - name: Audit + env: + RAILS_ENV: test + run: bundle exec rake audit + - name: Rubocop + env: + RAILS_ENV: test + run: bundle exec rubocop + - name: RSpec + env: + RAILS_ENV: test + run: bundle exec rspec diff --git a/Gemfile.lock b/Gemfile.lock index c780028..2c935f9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -181,7 +181,8 @@ GEM regexp_parser (2.9.1) reline (0.4.2) io-console (~> 0.5) - rexml (3.2.6) + rexml (3.2.8) + strscan (>= 3.0.9) rspec-core (3.13.0) rspec-support (~> 3.13.0) rspec-expectations (3.13.0) @@ -246,6 +247,7 @@ GEM stimulus-rails (1.3.3) railties (>= 6.0.0) stringio (3.1.0) + strscan (3.1.0) thor (1.3.1) timeout (0.4.1) turbo-rails (1.5.0) diff --git a/config/database.yml b/config/database.yml index 7059849..0fcd3fc 100644 --- a/config/database.yml +++ b/config/database.yml @@ -30,6 +30,7 @@ development: test: <<: *default database: homework_assignment_2024_test + port: 3306 # As with config/credentials.yml, you never want to store sensitive information, # like your database password, in your source code. If your source code is