Skip to content

Commit

Permalink
actions
Browse files Browse the repository at this point in the history
  • Loading branch information
madmatvey committed May 17, 2024
1 parent 0a5dbf7 commit e7e303b
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/GH-mysql-init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE USER 'rails_user'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'rails_user'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
81 changes: 81 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI
'on':
- push
jobs:
code_checks:
runs-on: ubuntu-20.04
services:
db:
image: mysql:5.7.44
ports:
- 3307:3307
env:
MYSQL_DATABASE: 'homework_assignment_2024_test'
MYSQL_USER: 'rails_user'
MYSQL_PASSWORD: 'password'
MYSQL_ROOT_PASSWORD: 'password'
MYSQL_ROOT_HOST: '%'
MYSQL_TCP_PORT: 3307
# MYSQL_HOST: localhost
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Show databases for root user
run: mysql --protocol=tcp -h 127.0.0.1 -P 3307 -u root -proot_password -e "SHOW DATABASES"
- name: Show databases for rails_user
run: mysql --protocol=tcp -h 127.0.0.1 -P 3307 -u rails_user -ppassword -e "SHOW DATABASES"
- uses: actions/setup-node@v1
with:
node-version: 20.x
registry-url: 'https://registry.npmjs.org'
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- run: bundle exec rake
# - 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
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e7e303b

Please sign in to comment.