Skip to content

Commit

Permalink
Merge pull request #86 from cul/ERIXUPDATES-1124-ruby-gems-node
Browse files Browse the repository at this point in the history
Updates to ruby version, node version, and gem updates
  • Loading branch information
elohanlon authored Nov 26, 2024
2 parents d549a0b + 4f2fb34 commit deb78e9
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 66 deletions.
33 changes: 2 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,12 @@ jobs:
strategy:
matrix:
ruby-version: ['3.2.2']
node: ['14', '16']
node: ['20']
env:
RAILS_ENV: test
MYSQL_HOST: 127.0.0.1
MYSQL_PORT: 3306
MYSQL_VERSION: 5.7
MYSQL_DATABASE: hours_test
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_USER: user
MYSQL_USER_PASSWORD: password
NOKOGIRI_USE_SYSTEM_LIBRARIES: true

steps:
# Set up MySQL first because it can take some time to start up
- uses: mirromutth/mysql-action@v1.1
with:
host port: ${{ env.MYSQL_PORT }}
container port: ${{ env.MYSQL_PORT }}
character set server: 'utf8mb4'
mysql version: ${{ env.MYSQL_VERSION }}
collation server: 'utf8mb4_general_ci'
mysql database: ${{ env.MYSQL_DATABASE }}
mysql root password: ${{ env.MYSQL_ROOT_PASSWORD }}
- uses: actions/checkout@v2
- name: Install libxslt for nokogiri gem (required for version < 1.11)
run: sudo apt-get install -y libxml2-dev libxslt-dev
Expand All @@ -49,21 +32,9 @@ jobs:
node-version: ${{ matrix.node }}
- run: npm install -g yarn
- run: yarn install
- run: cp config/database.gh-actions.yml config/database.yml
- run: cp config/database.template.yml config/database.yml
- run: cp config/secrets.template.yml config/secrets.yml
- run: cp config/wifi_density.template.yml config/wifi_density.yml
# Before we run any MySQL-related commands, make sure that MySQL has started
- name: Wait for MySQL to start
run: |
for i in 1 2 3 4 5; do mysqladmin ping -u root -p${{ env.MYSQL_ROOT_PASSWORD }} -h ${{ env.MYSQL_HOST }} --port ${{ env.MYSQL_PORT }} && break || sleep 5; done
# Run one final time to return success or error status (cancelling CI run if we get an error status)
mysqladmin ping -u root -p${{ env.MYSQL_ROOT_PASSWORD }} -h ${{ env.MYSQL_HOST }} --port ${{ env.MYSQL_PORT }}
- name: Grant database permissions
run: |
mysql -u root -p${{ env.MYSQL_ROOT_PASSWORD }} -h ${{ env.MYSQL_HOST }} --port ${{ env.MYSQL_PORT }} -e "CREATE USER '${{ env.MYSQL_USER }}'@'%' IDENTIFIED BY '${{ env.MYSQL_USER_PASSWORD }}';";
mysql -u root -p${{ env.MYSQL_ROOT_PASSWORD }} -h ${{ env.MYSQL_HOST }} --port ${{ env.MYSQL_PORT }} -e "GRANT ALL PRIVILEGES ON ${{ env.MYSQL_DATABASE }}.* TO '${{ env.MYSQL_USER }}'@'%';";
- name: Database user connection test
run: mysql -u ${{ env.MYSQL_USER }} -p${{ env.MYSQL_USER_PASSWORD }} -h ${{ env.MYSQL_HOST }} --port ${{ env.MYSQL_PORT }} -e "SHOW DATABASES;";
- run: RAILS_ENV=test bundle exec rake db:schema:load --trace
- run: RAILS_ENV=test bundle exec rake db:test:prepare
- name: Run tests
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-3.0.3
3.2.2
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ gem 'jbuilder', '~> 2.5'
# gem 'redis', '~> 3.0'

# Use sqlite3 as the database for Active Record
gem "sqlite3", "~> 1.4.2"
gem "sqlite3", "~> 1.5.0"

gem 'mysql2'

Expand Down
7 changes: 4 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ GEM
bootsnap (1.10.3)
msgpack (~> 1.2)
builder (3.2.4)
byebug (11.0.0)
byebug (11.1.3)
cancancan (3.5.0)
capistrano (3.17.3)
airbrussh (>= 1.0.0)
Expand Down Expand Up @@ -289,7 +289,8 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
sqlite3 (1.5.4)
mini_portile2 (~> 2.8.0)
sshkit (1.21.6)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
Expand Down Expand Up @@ -357,7 +358,7 @@ DEPENDENCIES
spring
spring-watcher-listen (~> 2.0.0)
sprockets-rails
sqlite3 (~> 1.4.2)
sqlite3 (~> 1.5.0)
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
- Git clone this repo
- Setup a MySQL db locally and add credentials to config/database.yml
- `$ bundle install`
- `$ rake db:migrate`
- If you don't have yarn currently installed please run `brew install yarn`
- `$ yarn`
- `$ rake db:seed`
- `$ bundle exec rake db:migrate`
- If you don't have yarn currently installed, install node 20 (preferably using nvm) and then run `npm install -g yarn`
- `$ yarn install`
- `$ bundle exec rake db:seed`

Seeds the db with two locations and an administrative user. Administrative credentials are:
The above seed command will seed the db with two locations and an administrative user. Administrative credentials are:
```
name: Test User
email: admin@example.com
```
- `$ rails s`
- Navigate to `localhost:3000`
- `$ bundle exec rails s`
- Navigate to `http://localhost:3000`


## Testing
Expand Down
12 changes: 0 additions & 12 deletions config/database.gh-actions.yml

This file was deleted.

10 changes: 4 additions & 6 deletions config/database.template.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
default: &default
adapter: mysql2
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
database: "hours"
username: "user"
password: "password"
timeout: 5000

development:
<<: *default
database: "hours_dev"
database: db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: "hours_test"
database: db/test.sqlite3
6 changes: 3 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
t.string "summary"
t.datetime "created_at", precision: nil, null: false
t.datetime "updated_at", precision: nil, null: false
t.bigint "primary_location_id"
t.integer "primary_location_id"
t.boolean "primary", default: false
t.boolean "front_page", default: false, null: false
t.string "short_note"
Expand All @@ -50,7 +50,7 @@
end

create_table "permissions", force: :cascade do |t|
t.bigint "user_id"
t.integer "user_id"
t.string "role", null: false
t.string "subject_class"
t.integer "subject_id"
Expand All @@ -69,7 +69,7 @@
t.boolean "tbd", default: false, null: false
t.boolean "closed", default: false, null: false
t.string "note"
t.bigint "location_id"
t.integer "location_id"
t.index ["close"], name: "index_timetables_on_close"
t.index ["date"], name: "index_timetables_on_date"
t.index ["location_id", "date"], name: "index_timetables_on_location_id_and_date", unique: true
Expand Down
4 changes: 2 additions & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Character.create(name: 'Luke', movie: movies.first)

all_location = Location.create(name: "All Locations", code: "all", primary: true, front_page: false)
butler = Location.create(name: "Butler", code: "butler", primary: true)
avery = Location.create(name: "Avery", code: "avery", primary: true)
butler = Location.create(name: "Butler", code: "butler", primary: true, front_page: true)
avery = Location.create(name: "Avery", code: "avery", primary: true, front_page: true)
rbml = Location.create(name: "Rare Books", code: "rbml", primary_location: butler)

admin = User.create(email: "admin@example.com", provider: :developer, name: "Test Admin")
Expand Down

0 comments on commit deb78e9

Please sign in to comment.