From b712fdab6efc67c2718d2d2f47514706602a24a5 Mon Sep 17 00:00:00 2001 From: Didier Lafforgue Date: Mon, 1 Apr 2024 19:23:10 +0200 Subject: [PATCH 1/4] replace Travis by Github actions --- .github/workflows/continuous_integration.yml | 45 ++++++++++++++++++++ .travis.yml | 10 ----- MIT-LICENSE | 2 +- README.md | 4 +- Rakefile | 4 +- script/ci/before_build.sh | 5 --- spec/support/helpers.rb | 2 +- 7 files changed, 50 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/continuous_integration.yml delete mode 100644 .travis.yml delete mode 100755 script/ci/before_build.sh diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml new file mode 100644 index 00000000..d15e2715 --- /dev/null +++ b/.github/workflows/continuous_integration.yml @@ -0,0 +1,45 @@ +name: Validate Project + +# on: +# push: +# branches-ignore: +# - main + +on: [push] + +jobs: + ci_validation: + runs-on: ubuntu-latest + + services: + mongo: + image: mongo:6.0.14 + ports: + - 27017:27017 + env: + # MONGO_INITDB_ROOT_USERNAME: test + # MONGO_INITDB_ROOT_PASSWORD: password + MONGO_INITDB_DATABASE: steam_test_1_8_x + options: >- + --health-cmd "echo 'db.runCommand("ping").ok' | mongosh --quiet" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + --name mongo_container + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1.4 + bundler-cache: true + cache-version: 1 + + - name: Prepare the DB + run: bundle exec rake mongodb:test:seed + + - name: Test + run: bundle exec rspec \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 133efc32..00000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ -language: ruby -services: mongodb -before_script: ./script/ci/before_build.sh -rvm: - - 2.7.7 - - 3.0.5 - - 3.1.3 -addons: - code_climate: - repo_token: 3fa74f2ade25037fccd7261090acbdeae232639c3a83aafb80ee428ec16b8cf9 diff --git a/MIT-LICENSE b/MIT-LICENSE index 6e829705..a9545bda 100644 --- a/MIT-LICENSE +++ b/MIT-LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2023 NoCoffee +Copyright (c) 2010-2024 NoCoffee Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 43044038..2df0ca79 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # Steam -[![Code Climate](https://codeclimate.com/github/locomotivecms/steam/badges/gpa.svg)](https://codeclimate.com/github/locomotivecms/steam) [![Build Status](https://travis-ci.com/locomotivecms/steam.svg?branch=master)](https://travis-ci.com/locomotivecms/steam) [![Coverage Status](https://coveralls.io/repos/locomotivecms/steam/badge.svg?branch=master)](https://coveralls.io/r/locomotivecms/steam?branch=master) [![Gitter](https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg)](https://gitter.im/locomotivecms/steam) - The rendering stack used by both Wagon and Engine. It includes: - the rack stack to pages and already precompiled assets (through webpack, vite or other). @@ -103,4 +101,4 @@ Note: you do not need to prefix with bundle exec as the docky-ruby image already ## License -Copyright (c) 2023 NoCoffee. MIT Licensed, see MIT-LICENSE for details. +Copyright (c) 2010-2024 NoCoffee. MIT Licensed, see MIT-LICENSE for details. diff --git a/Rakefile b/Rakefile index e24e287c..2e215e8b 100755 --- a/Rakefile +++ b/Rakefile @@ -27,8 +27,8 @@ namespace :mongodb do `mv #{dump_path} #{db_path}` end - `mongo steam_test_1_7_x --eval "db.dropDatabase()" #{host}` - `mongorestore -d steam_test_1_7_x #{db_path} #{host}` + `mongo steam_test_1_8_x --eval "db.dropDatabase()" #{host}` + `mongorestore -d steam_test_1_8_x #{db_path} #{host}` puts "Done! Update now the spec/support/helpers.rb file by setting the new id of the site returned by the mongodb_site_id method" end diff --git a/script/ci/before_build.sh b/script/ci/before_build.sh deleted file mode 100755 index 313a4c26..00000000 --- a/script/ci/before_build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -echo 'America/Chicago' | sudo tee /etc/timezone -sudo dpkg-reconfigure --frontend noninteractive tzdata -date -mongo --version diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb index b863ec8a..25aa6cc3 100644 --- a/spec/support/helpers.rb +++ b/spec/support/helpers.rb @@ -4,7 +4,7 @@ module Spec module Helpers def mongodb_database - 'steam_test_1_7_x' + 'steam_test_1_8_x' end def mongodb_site_id From f3d92134196c4d503d41bb559d43c9c677841439 Mon Sep 17 00:00:00 2001 From: Didier Lafforgue Date: Mon, 1 Apr 2024 20:09:24 +0200 Subject: [PATCH 2/4] install mongorestore for the CI --- .github/workflows/continuous_integration.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index d15e2715..cc959656 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -31,6 +31,11 @@ jobs: - name: Checkout Repository uses: actions/checkout@v3 + - name: Install MongoDB tools + run: | + wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.9.4.deb + sudo apt install ./mongodb-database-tools-ubuntu2204-x86_64-100.9.4.deb + - name: Setup Ruby uses: ruby/setup-ruby@v1 with: From 97f85e406fb39185dcb41fdafa6ed9e7495b3d38 Mon Sep 17 00:00:00 2001 From: Didier Lafforgue Date: Mon, 1 Apr 2024 20:49:11 +0200 Subject: [PATCH 3/4] use mongostat to get the current number of MongoDB connections --- .github/workflows/continuous_integration.yml | 2 -- Rakefile | 6 ++++-- spec/integration/adapters/mongodb_spec.rb | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index cc959656..49b41f1d 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -17,8 +17,6 @@ jobs: ports: - 27017:27017 env: - # MONGO_INITDB_ROOT_USERNAME: test - # MONGO_INITDB_ROOT_PASSWORD: password MONGO_INITDB_DATABASE: steam_test_1_8_x options: >- --health-cmd "echo 'db.runCommand("ping").ok' | mongosh --quiet" diff --git a/Rakefile b/Rakefile index 2e215e8b..d7a18f76 100755 --- a/Rakefile +++ b/Rakefile @@ -27,8 +27,10 @@ namespace :mongodb do `mv #{dump_path} #{db_path}` end - `mongo steam_test_1_8_x --eval "db.dropDatabase()" #{host}` - `mongorestore -d steam_test_1_8_x #{db_path} #{host}` + # NOTE: command to drop the database + # `mongo steam_test_1_8_x --eval "db.dropDatabase()" #{host}` + + `mongorestore --drop -d steam_test_1_8_x #{db_path} #{host}` puts "Done! Update now the spec/support/helpers.rb file by setting the new id of the site returned by the mongodb_site_id method" end diff --git a/spec/integration/adapters/mongodb_spec.rb b/spec/integration/adapters/mongodb_spec.rb index 9e4ffa65..2f68d314 100644 --- a/spec/integration/adapters/mongodb_spec.rb +++ b/spec/integration/adapters/mongodb_spec.rb @@ -43,7 +43,8 @@ end def current_connections - `mongosh --eval "db.serverStatus().connections.current"`.split("\n").last.to_i + stats = JSON.parse(`mongostat --noheaders -n 1 --json`) + stats.dig('localhost', 'conn')&.to_i end end From 820d95e6199faaa9234690a156bc71af54689af8 Mon Sep 17 00:00:00 2001 From: Didier Lafforgue Date: Mon, 1 Apr 2024 20:56:06 +0200 Subject: [PATCH 4/4] clean the GH actions file --- .github/workflows/continuous_integration.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 49b41f1d..f50886d7 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -1,9 +1,4 @@ -name: Validate Project - -# on: -# push: -# branches-ignore: -# - main +name: Continuous integration on: [push]