From ebdd2e51338f65df15676f84db1e89ace4a02b82 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Fri, 3 Feb 2023 13:39:11 +0700 Subject: [PATCH 01/19] Replace ::set-output with >> $GITHUB_OUTPUT and update actions --- .github/workflows/test_production_build.yml | 4 ++-- .github/workflows/test_variants.yml | 4 ++-- .../addons/github/.github/workflows/deploy_heroku.yml.tt | 2 +- .template/addons/github/.github/workflows/test.yml.tt | 6 +++--- .../github/.github/workflows/test_production_build.yml.tt | 2 +- README.md.tt | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test_production_build.yml b/.github/workflows/test_production_build.yml index e0d999ec..39a68075 100644 --- a/.github/workflows/test_production_build.yml +++ b/.github/workflows/test_production_build.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@v2.3.4 - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@v1.2 + uses: nimblehq/branch-tag-action@1.3.0 - name: Setup Ruby uses: ruby/setup-ruby@v1 @@ -53,7 +53,7 @@ jobs: - name: Get yarn cache directory path if: ${{ matrix.variant == 'web' }} id: yarn-cache-dir-path - run: echo "::set-output name=yarn_cache_dir::$(yarn cache dir)" + run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - name: Cache npm packages if: ${{ matrix.variant == 'web' }} diff --git a/.github/workflows/test_variants.yml b/.github/workflows/test_variants.yml index cbd7ac61..42e5d7cb 100644 --- a/.github/workflows/test_variants.yml +++ b/.github/workflows/test_variants.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v2.3.4 - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@v1.2 + uses: nimblehq/branch-tag-action@1.3.0 - name: Setup Ruby uses: ruby/setup-ruby@v1 @@ -56,7 +56,7 @@ jobs: - name: Get yarn cache directory path if: ${{ matrix.variant == 'web' }} id: yarn-cache-dir-path - run: echo "::set-output name=yarn_cache_dir::$(yarn cache dir)" + run: echo "yarn_cache_dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - name: Cache npm packages if: ${{ matrix.variant == 'web' }} diff --git a/.template/addons/github/.github/workflows/deploy_heroku.yml.tt b/.template/addons/github/.github/workflows/deploy_heroku.yml.tt index 802c44b7..6aafcf86 100644 --- a/.template/addons/github/.github/workflows/deploy_heroku.yml.tt +++ b/.template/addons/github/.github/workflows/deploy_heroku.yml.tt @@ -34,7 +34,7 @@ jobs: ref: ${{ github.event.workflow_run.head_branch || github.ref }} - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@v1.2 + uses: nimblehq/branch-tag-action@1.3.0 with: ref: ${{ github.event.workflow_run.head_branch || github.ref }} diff --git a/.template/addons/github/.github/workflows/test.yml.tt b/.template/addons/github/.github/workflows/test.yml.tt index 3894e396..3e511cc1 100644 --- a/.template/addons/github/.github/workflows/test.yml.tt +++ b/.template/addons/github/.github/workflows/test.yml.tt @@ -31,7 +31,7 @@ jobs: - uses: actions/checkout@v3 - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@v1.2 + uses: nimblehq/branch-tag-action@1.3.0 - name: Login to Docker registry uses: docker/login-action@v1.6.0 @@ -58,7 +58,7 @@ jobs: - uses: actions/checkout@v3 - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@v1.2 + uses: nimblehq/branch-tag-action@1.3.0 - name: Login to Docker registry uses: docker/login-action@v1.6.0 @@ -87,7 +87,7 @@ jobs: - uses: actions/checkout@v3 - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@v1.2 + uses: nimblehq/branch-tag-action@1.3.0 - name: Login to Docker registry uses: docker/login-action@v1.6.0 diff --git a/.template/addons/github/.github/workflows/test_production_build.yml.tt b/.template/addons/github/.github/workflows/test_production_build.yml.tt index 1b7dd1ba..6882dc7f 100644 --- a/.template/addons/github/.github/workflows/test_production_build.yml.tt +++ b/.template/addons/github/.github/workflows/test_production_build.yml.tt @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v2.3.4 - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@v1.2 + uses: nimblehq/branch-tag-action@1.3.0 - name: Build Docker image run: bin/docker-prepare && docker compose build diff --git a/README.md.tt b/README.md.tt index 88a215ff..f7298ffa 100644 --- a/README.md.tt +++ b/README.md.tt @@ -50,7 +50,7 @@ Add the following build settings to run the tests in the Docker environment via ```sh # a unique `BRANCH_TAG` value to tag the Docker image # e.g $SEMAPHORE_BRANCH_ID or using the -# or using nimblehq/branch-tag-action@v1.2 Github action +# or using nimblehq/branch-tag-action@1.3.0 Github action export BRANCH_TAG= # unique value for tagging Docker image ``` From 668f6a8442cb038cb12e21f36e8e72394136b0e8 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Fri, 3 Feb 2023 13:47:04 +0700 Subject: [PATCH 02/19] Update other GitHub actions versions to latest stable --- .github/workflows/test_production_build.yml | 8 ++++---- .github/workflows/test_template.yml | 4 ++-- .github/workflows/test_variants.yml | 10 +++++----- .../github/.github/workflows/deploy_heroku.yml.tt | 4 ++-- .template/addons/github/.github/workflows/test.yml.tt | 6 +++--- .../.github/workflows/test_production_build.yml.tt | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test_production_build.yml b/.github/workflows/test_production_build.yml index 39a68075..a6d3e9fe 100644 --- a/.github/workflows/test_production_build.yml +++ b/.github/workflows/test_production_build.yml @@ -23,7 +23,7 @@ jobs: with: access_token: ${{ github.token }} - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@v3 - name: Set env BRANCH_TAG uses: nimblehq/branch-tag-action@1.3.0 @@ -35,12 +35,12 @@ jobs: bundler-cache: true - name: Setup Node.js environment - uses: actions/setup-node@v2.1.4 + uses: actions/setup-node@v3 with: node-version: ${{ env.NODE_VERSION }} - name: Cache gems - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: /home/runner/.rubies/ruby-${{ env.RUBY_VERSION }} key: ${{ runner.os }}-gems-${{ env.RUBY_VERSION }}-${{ hashFiles('**/Gemfile.lock') }} @@ -57,7 +57,7 @@ jobs: - name: Cache npm packages if: ${{ matrix.variant == 'web' }} - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ${{ steps.yarn-cache-dir-path.outputs.yarn_cache_dir }} diff --git a/.github/workflows/test_template.yml b/.github/workflows/test_template.yml index 20ae608a..82f694bd 100644 --- a/.github/workflows/test_template.yml +++ b/.github/workflows/test_template.yml @@ -17,7 +17,7 @@ jobs: access_token: ${{ github.token }} - name: Checkout Repository - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v3 - name: Setup Ruby uses: ruby/setup-ruby@v1 @@ -26,7 +26,7 @@ jobs: bundler-cache: true - name: Cache gems - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: vendor/bundle key: ${{ runner.os }}-template-${{ env.RUBY_VERSION }}-${{ hashFiles('**/Gemfile.lock') }} diff --git a/.github/workflows/test_variants.yml b/.github/workflows/test_variants.yml index 42e5d7cb..91c83b4b 100644 --- a/.github/workflows/test_variants.yml +++ b/.github/workflows/test_variants.yml @@ -26,7 +26,7 @@ jobs: with: access_token: ${{ github.token }} - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@v3 - name: Set env BRANCH_TAG uses: nimblehq/branch-tag-action@1.3.0 @@ -38,12 +38,12 @@ jobs: bundler-cache: true - name: Setup Node.js environment - uses: actions/setup-node@v2.1.4 + uses: actions/setup-node@v3 with: node-version: ${{ env.NODE_VERSION }} - name: Cache gems - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: /home/runner/.rubies/ruby-${{ env.RUBY_VERSION }} key: ${{ runner.os }}-gems-${{ env.RUBY_VERSION }}-${{ hashFiles('**/Gemfile.lock') }} @@ -60,7 +60,7 @@ jobs: - name: Cache npm packages if: ${{ matrix.variant == 'web' }} - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ${{ steps.yarn-cache-dir-path.outputs.yarn_cache_dir }} @@ -76,7 +76,7 @@ jobs: make create_${{ matrix.variant }} - name: Login to docker registry - uses: docker/login-action@v1.6.0 + uses: docker/login-action@v2 with: registry: ${{ env.DOCKER_REGISTRY_HOST }} username: ${{ env.DOCKER_REGISTRY_USERNAME }} diff --git a/.template/addons/github/.github/workflows/deploy_heroku.yml.tt b/.template/addons/github/.github/workflows/deploy_heroku.yml.tt index 6aafcf86..3efebca5 100644 --- a/.template/addons/github/.github/workflows/deploy_heroku.yml.tt +++ b/.template/addons/github/.github/workflows/deploy_heroku.yml.tt @@ -29,7 +29,7 @@ jobs: with: access_token: ${{ github.token }} - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@v3 with: ref: ${{ github.event.workflow_run.head_branch || github.ref }} @@ -48,7 +48,7 @@ jobs: fi - name: Login to Docker registry - uses: docker/login-action@v1.6.0 + uses: docker/login-action@v2 with: registry: ${{ env.DOCKER_REGISTRY_HOST }} username: ${{ env.DOCKER_REGISTRY_USERNAME }} diff --git a/.template/addons/github/.github/workflows/test.yml.tt b/.template/addons/github/.github/workflows/test.yml.tt index 3e511cc1..ae57c371 100644 --- a/.template/addons/github/.github/workflows/test.yml.tt +++ b/.template/addons/github/.github/workflows/test.yml.tt @@ -34,7 +34,7 @@ jobs: uses: nimblehq/branch-tag-action@1.3.0 - name: Login to Docker registry - uses: docker/login-action@v1.6.0 + uses: docker/login-action@v2 with: registry: ${{ env.DOCKER_REGISTRY_HOST }} username: ${{ env.DOCKER_REGISTRY_USERNAME }} @@ -61,7 +61,7 @@ jobs: uses: nimblehq/branch-tag-action@1.3.0 - name: Login to Docker registry - uses: docker/login-action@v1.6.0 + uses: docker/login-action@v2 with: registry: ${{ env.DOCKER_REGISTRY_HOST }} username: ${{ env.DOCKER_REGISTRY_USERNAME }} @@ -90,7 +90,7 @@ jobs: uses: nimblehq/branch-tag-action@1.3.0 - name: Login to Docker registry - uses: docker/login-action@v1.6.0 + uses: docker/login-action@v2 with: registry: ${{ env.DOCKER_REGISTRY_HOST }} username: ${{ env.DOCKER_REGISTRY_USERNAME }} diff --git a/.template/addons/github/.github/workflows/test_production_build.yml.tt b/.template/addons/github/.github/workflows/test_production_build.yml.tt index 6882dc7f..5d3401a3 100644 --- a/.template/addons/github/.github/workflows/test_production_build.yml.tt +++ b/.template/addons/github/.github/workflows/test_production_build.yml.tt @@ -21,7 +21,7 @@ jobs: with: access_token: ${{ github.token }} - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@v3 - name: Set env BRANCH_TAG uses: nimblehq/branch-tag-action@1.3.0 From b0b3ce8a0e7e70cbda811b753c27de77a746c5ee Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Fri, 14 Oct 2022 14:31:22 +0700 Subject: [PATCH 03/19] [#362] Add rubocop rules to allow 10 excpectations and 5 nested blocks --- .rubocop.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index db34c042..47d2d3f9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -44,3 +44,9 @@ RSpec/ContextWording: Prefixes: - when - given + +RSpec/NestedGroups: + Max: 5 + +RSpec/MultipleExpectations: + Max: 10 From 8d5da756e40b9b9371a16bd717a05deab4321a34 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 7 Feb 2023 13:58:13 +0700 Subject: [PATCH 04/19] Fix to use major version of branch-tag-action --- .github/workflows/test_production_build.yml | 2 +- .github/workflows/test_variants.yml | 2 +- .../addons/github/.github/workflows/deploy_heroku.yml.tt | 2 +- .template/addons/github/.github/workflows/test.yml.tt | 6 +++--- .../github/.github/workflows/test_production_build.yml.tt | 2 +- README.md.tt | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_production_build.yml b/.github/workflows/test_production_build.yml index a6d3e9fe..e5082d59 100644 --- a/.github/workflows/test_production_build.yml +++ b/.github/workflows/test_production_build.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@v3 - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@1.3.0 + uses: nimblehq/branch-tag-action@1 - name: Setup Ruby uses: ruby/setup-ruby@v1 diff --git a/.github/workflows/test_variants.yml b/.github/workflows/test_variants.yml index 91c83b4b..fcef09b4 100644 --- a/.github/workflows/test_variants.yml +++ b/.github/workflows/test_variants.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v3 - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@1.3.0 + uses: nimblehq/branch-tag-action@1 - name: Setup Ruby uses: ruby/setup-ruby@v1 diff --git a/.template/addons/github/.github/workflows/deploy_heroku.yml.tt b/.template/addons/github/.github/workflows/deploy_heroku.yml.tt index 3efebca5..0b9cf4b6 100644 --- a/.template/addons/github/.github/workflows/deploy_heroku.yml.tt +++ b/.template/addons/github/.github/workflows/deploy_heroku.yml.tt @@ -34,7 +34,7 @@ jobs: ref: ${{ github.event.workflow_run.head_branch || github.ref }} - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@1.3.0 + uses: nimblehq/branch-tag-action@1 with: ref: ${{ github.event.workflow_run.head_branch || github.ref }} diff --git a/.template/addons/github/.github/workflows/test.yml.tt b/.template/addons/github/.github/workflows/test.yml.tt index ae57c371..86f7c026 100644 --- a/.template/addons/github/.github/workflows/test.yml.tt +++ b/.template/addons/github/.github/workflows/test.yml.tt @@ -31,7 +31,7 @@ jobs: - uses: actions/checkout@v3 - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@1.3.0 + uses: nimblehq/branch-tag-action@1 - name: Login to Docker registry uses: docker/login-action@v2 @@ -58,7 +58,7 @@ jobs: - uses: actions/checkout@v3 - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@1.3.0 + uses: nimblehq/branch-tag-action@1 - name: Login to Docker registry uses: docker/login-action@v2 @@ -87,7 +87,7 @@ jobs: - uses: actions/checkout@v3 - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@1.3.0 + uses: nimblehq/branch-tag-action@1 - name: Login to Docker registry uses: docker/login-action@v2 diff --git a/.template/addons/github/.github/workflows/test_production_build.yml.tt b/.template/addons/github/.github/workflows/test_production_build.yml.tt index 5d3401a3..a5abc761 100644 --- a/.template/addons/github/.github/workflows/test_production_build.yml.tt +++ b/.template/addons/github/.github/workflows/test_production_build.yml.tt @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v3 - name: Set env BRANCH_TAG - uses: nimblehq/branch-tag-action@1.3.0 + uses: nimblehq/branch-tag-action@1 - name: Build Docker image run: bin/docker-prepare && docker compose build diff --git a/README.md.tt b/README.md.tt index f7298ffa..119bfc0e 100644 --- a/README.md.tt +++ b/README.md.tt @@ -50,7 +50,7 @@ Add the following build settings to run the tests in the Docker environment via ```sh # a unique `BRANCH_TAG` value to tag the Docker image # e.g $SEMAPHORE_BRANCH_ID or using the -# or using nimblehq/branch-tag-action@1.3.0 Github action +# or using nimblehq/branch-tag-action@1 Github action export BRANCH_TAG= # unique value for tagging Docker image ``` From 6c5ecde72290cb54d0f88d9fb0d1f0b0d8aea08b Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Thu, 9 Feb 2023 15:58:27 +0700 Subject: [PATCH 05/19] Update CODEOWNERS --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2d50d9e5..aff1fe32 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,6 +1,6 @@ # Team # @malparty is the Team Lead and the others are team members -* @rosle @andyduong1920 @bterone @byhbt @carryall @hanam1ni @hoangmirs @junan @Lahphim @longnd @malparty @tyrro +* @rosle @andyduong1920 @bterone @byhbt @carryall @hanam1ni @hoangmirs @longnd @malparty @tyrro @sanG-github # Engineering Leads CODEOWNERS @nimblehq/engineering-leads From adf3a6f6d9d8be85f80766d3237814da40f313d8 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Tue, 14 Feb 2023 14:19:07 +0700 Subject: [PATCH 06/19] Update bootstrap 5.1.3 to 5.2.3 --- .template/addons/bootstrap/package.json.rb | 2 +- .template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.template/addons/bootstrap/package.json.rb b/.template/addons/bootstrap/package.json.rb index baefb76f..d2a0e8d6 100644 --- a/.template/addons/bootstrap/package.json.rb +++ b/.template/addons/bootstrap/package.json.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -run 'yarn add bootstrap@5.1.3' +run 'yarn add bootstrap@5.2.3' run 'yarn add @popperjs/core@2.11.2' diff --git a/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss b/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss index aabbe2e8..d97f76c2 100644 --- a/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss +++ b/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss @@ -5,7 +5,10 @@ // Configuration @import 'bootstrap/scss/functions'; +// @import 'variables'; // Optional variable overrides here @import 'bootstrap/scss/variables'; +@import 'bootstrap/scss/maps'; +// @import 'sass_maps'; // Optional Sass map overrides here @import 'bootstrap/scss/mixins'; @import 'bootstrap/scss/utilities'; From bb3d4809bc4fb171cb079889e0f174fc16dd92d4 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Fri, 17 Feb 2023 11:21:22 +0700 Subject: [PATCH 07/19] [gh391] Enable TEST_RETRY on Github CI --- .template/addons/docker/.env.tt | 2 +- .template/addons/github/.github/workflows/test.yml.tt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.template/addons/docker/.env.tt b/.template/addons/docker/.env.tt index e41c95c4..7be3e1c5 100644 --- a/.template/addons/docker/.env.tt +++ b/.template/addons/docker/.env.tt @@ -3,4 +3,4 @@ DOCKER_IMAGE=<%= DOCKER_IMAGE %> BRANCH_TAG=latest PORT=80 CI=false -TEST_RETRY=true +TEST_RETRY=0 diff --git a/.template/addons/github/.github/workflows/test.yml.tt b/.template/addons/github/.github/workflows/test.yml.tt index 86f7c026..4abd41b8 100644 --- a/.template/addons/github/.github/workflows/test.yml.tt +++ b/.template/addons/github/.github/workflows/test.yml.tt @@ -83,6 +83,8 @@ jobs: name: System tests runs-on: ubuntu-latest needs: build + env: + TEST_RETRY: 2 steps: - uses: actions/checkout@v3 From 00b3f7f5b67cab71be08de200d6e60d303e16b35 Mon Sep 17 00:00:00 2001 From: Xavier MALPARTY Date: Fri, 17 Feb 2023 11:58:33 +0700 Subject: [PATCH 08/19] Remove custom variable import and add comments for sass map overrides --- .../addons/bootstrap/stylesheets/vendor/_bootstrap.scss | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss b/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss index d97f76c2..dababadc 100644 --- a/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss +++ b/.template/addons/bootstrap/stylesheets/vendor/_bootstrap.scss @@ -5,10 +5,11 @@ // Configuration @import 'bootstrap/scss/functions'; -// @import 'variables'; // Optional variable overrides here @import 'bootstrap/scss/variables'; @import 'bootstrap/scss/maps'; -// @import 'sass_maps'; // Optional Sass map overrides here +// @import 'sass_maps'; // Optional Sass map overrides here (See: https://getbootstrap.com/docs/5.2/migration/#new-_mapsscss) +// e.g., $theme-colors: map-merge($theme-colors, $custom-theme-colors); + @import 'bootstrap/scss/mixins'; @import 'bootstrap/scss/utilities'; From e639f193f0199553b421be1a40c8c006ae217240 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Wed, 1 Feb 2023 10:41:37 +0700 Subject: [PATCH 09/19] [gh376] Separate the linting job --- .../github/.github/workflows/test.yml.tt | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/.template/addons/github/.github/workflows/test.yml.tt b/.template/addons/github/.github/workflows/test.yml.tt index 4abd41b8..acaca5c6 100644 --- a/.template/addons/github/.github/workflows/test.yml.tt +++ b/.template/addons/github/.github/workflows/test.yml.tt @@ -50,10 +50,35 @@ jobs: - name: Push Docker image run: docker-compose push test + linting: + name: Linting + runs-on: ubuntu-latest + needs: build + timeout-minutes: 5 + steps: + - uses: actions/checkout@v3 + + - name: Set env BRANCH_TAG + uses: nimblehq/branch-tag-action@v1.2 + + - name: Login to Docker registry + uses: docker/login-action@v2 + with: + registry: ${{ env.DOCKER_REGISTRY_HOST }} + username: ${{ env.DOCKER_REGISTRY_USERNAME }} + password: ${{ env.DOCKER_REGISTRY_TOKEN }} + + - name: Pull Docker image + run: docker-compose pull test || true + + - name: Run codebase test + run: docker-compose run test bundle exec rspec spec/codebase/codebase_spec.rb --format progress + unit_tests: name: Unit tests runs-on: ubuntu-latest - needs: build + needs: linting + timeout-minutes: 15 steps: - uses: actions/checkout@v3 @@ -71,7 +96,7 @@ jobs: run: docker-compose pull test || true - name: Run unit tests - run: docker-compose run test bundle exec rspec --exclude-pattern "spec/systems/**/*_spec.rb" --profile --format progress + run: docker-compose run test bundle exec rspec --exclude-pattern "spec/systems/**/*_spec.rb, spec/codebase/codebase_spec.rb" --profile --format progress - name: Upload tests coverage artifact uses: actions/upload-artifact@v3 @@ -82,7 +107,8 @@ jobs: system_tests: name: System tests runs-on: ubuntu-latest - needs: build + needs: linting + timeout-minutes: 15 env: TEST_RETRY: 2 steps: From 7a940f28ab4c1de3d4c6e2adf25c826966044203 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Wed, 15 Feb 2023 17:31:28 +0700 Subject: [PATCH 10/19] [gh376] Make the unit test does not rely on the linting step --- .template/addons/github/.github/workflows/test.yml.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.template/addons/github/.github/workflows/test.yml.tt b/.template/addons/github/.github/workflows/test.yml.tt index acaca5c6..478036bc 100644 --- a/.template/addons/github/.github/workflows/test.yml.tt +++ b/.template/addons/github/.github/workflows/test.yml.tt @@ -77,7 +77,7 @@ jobs: unit_tests: name: Unit tests runs-on: ubuntu-latest - needs: linting + needs: build timeout-minutes: 15 steps: - uses: actions/checkout@v3 From 10ed0e7a5596084edca4bbfa75a22b1873519555 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Wed, 15 Feb 2023 17:32:04 +0700 Subject: [PATCH 11/19] [gh376] Make the system test does not rely on the linting step --- .template/addons/github/.github/workflows/test.yml.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.template/addons/github/.github/workflows/test.yml.tt b/.template/addons/github/.github/workflows/test.yml.tt index 478036bc..e6a8f890 100644 --- a/.template/addons/github/.github/workflows/test.yml.tt +++ b/.template/addons/github/.github/workflows/test.yml.tt @@ -107,7 +107,7 @@ jobs: system_tests: name: System tests runs-on: ubuntu-latest - needs: linting + needs: build timeout-minutes: 15 env: TEST_RETRY: 2 From 005b7834514d1aecb0d2da8da265107f624e2651 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Thu, 9 Feb 2023 13:58:22 +0700 Subject: [PATCH 12/19] [gh387] Tweak the Request test, eager load the app on CI --- .template/addons/devise/spec_support.rb | 1 + .template/addons/github/.github/workflows/test.yml.tt | 3 +++ .template/spec/variants/web/config/environments/test_spec.rb | 4 ++++ Gemfile.tt | 2 +- spec/support/request_helpers.rb | 1 - 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.template/addons/devise/spec_support.rb b/.template/addons/devise/spec_support.rb index 344129dc..1ed82eba 100644 --- a/.template/addons/devise/spec_support.rb +++ b/.template/addons/devise/spec_support.rb @@ -4,5 +4,6 @@ RSpec.configure do |config| config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::Test::ControllerHelpers, type: :view + config.include Devise::Test::IntegrationHelpers, type: :request end RUBY diff --git a/.template/addons/github/.github/workflows/test.yml.tt b/.template/addons/github/.github/workflows/test.yml.tt index e6a8f890..9f13fbb4 100644 --- a/.template/addons/github/.github/workflows/test.yml.tt +++ b/.template/addons/github/.github/workflows/test.yml.tt @@ -18,6 +18,9 @@ env: # Set the default docker-compose file COMPOSE_FILE: docker-compose.test.yml + # Set the default CI value despite the Github Action default value + CI: true + jobs: build: name: Build Docker image diff --git a/.template/spec/variants/web/config/environments/test_spec.rb b/.template/spec/variants/web/config/environments/test_spec.rb index dcf10690..890c0127 100644 --- a/.template/spec/variants/web/config/environments/test_spec.rb +++ b/.template/spec/variants/web/config/environments/test_spec.rb @@ -14,4 +14,8 @@ it 'configures the assets to not compile when asset is missing' do expect(subject).to contain('config.assets.compile = false') end + + it 'eager load on CI' do + expect(subject).to contain('config.eager_load = ENV[\'C\'].present?') + end end diff --git a/Gemfile.tt b/Gemfile.tt index b76f6cdd..4aee0ebd 100644 --- a/Gemfile.tt +++ b/Gemfile.tt @@ -47,7 +47,7 @@ group :development, :test do gem 'fabrication' # Fabrication generates objects in Ruby. Fabricators are schematics for your objects, and can be created as needed anywhere in your app or specs # Testing - gem 'rspec-rails', '~> 5.0.2' # Rails testing engine + gem 'rspec-rails', '~> 6.0' # Rails testing engine # Code Analysis gem 'bullet' # help to kill N+1 queries and unused eager loading diff --git a/spec/support/request_helpers.rb b/spec/support/request_helpers.rb index 589bacd4..d737f7f6 100644 --- a/spec/support/request_helpers.rb +++ b/spec/support/request_helpers.rb @@ -9,6 +9,5 @@ def json_response end RSpec.configure do |config| - config.include RSpec::Rails::ControllerExampleGroup, type: :request # required to have access to routes block config.include Request::JsonHelpers, type: :request end From d5a040d1af544a5e783aeaa430b55853ff2696b4 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Thu, 9 Feb 2023 14:08:31 +0700 Subject: [PATCH 13/19] [gh387] Update the test and github template --- .github/ISSUE_TEMPLATE/bug_template.md | 10 +++++----- .github/ISSUE_TEMPLATE/feature_template.md | 4 ++-- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .../spec/variants/web/config/environments/test_spec.rb | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_template.md b/.github/ISSUE_TEMPLATE/bug_template.md index 5eb84c37..4da7909c 100644 --- a/.github/ISSUE_TEMPLATE/bug_template.md +++ b/.github/ISSUE_TEMPLATE/bug_template.md @@ -8,13 +8,13 @@ labels: "type : bug" ## Issue Describe the issue you are facing. Show us the implementation: screenshots, gif, etc. - + ## Expected Describe what should be the correct behaviour. - + ## Steps to reproduce -1. -2. -3. +1. +2. +3. diff --git a/.github/ISSUE_TEMPLATE/feature_template.md b/.github/ISSUE_TEMPLATE/feature_template.md index 5a26eb96..4ad1fb45 100644 --- a/.github/ISSUE_TEMPLATE/feature_template.md +++ b/.github/ISSUE_TEMPLATE/feature_template.md @@ -7,8 +7,8 @@ labels: "type : feature" ## Why -Describe the big picture of the feature and why it's needed. - +Describe the big picture of the feature and why it's needed. + ## Who Benefits? Describe who will be the beneficiaries e.g. everyone, specific chapters, clients... diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index df1182a5..07f12ab3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ -https://github.com/nimblehq/rails-templates/issues/?? +Close https://github.com/nimblehq/rails-templates/issues/?? ## What happened 👀 diff --git a/.template/spec/variants/web/config/environments/test_spec.rb b/.template/spec/variants/web/config/environments/test_spec.rb index 890c0127..fb66e3c2 100644 --- a/.template/spec/variants/web/config/environments/test_spec.rb +++ b/.template/spec/variants/web/config/environments/test_spec.rb @@ -16,6 +16,6 @@ end it 'eager load on CI' do - expect(subject).to contain('config.eager_load = ENV[\'C\'].present?') + expect(subject).to contain('config.eager_load = ENV["C"].present?') end end From d0129ec7dc71f8edd2e2e2380cb1a8b79be31280 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Thu, 9 Feb 2023 14:15:20 +0700 Subject: [PATCH 14/19] [gh387] Move the test to the base --- .template/spec/base/config/environments/test_spec.rb | 4 ++++ .template/spec/variants/web/config/environments/test_spec.rb | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.template/spec/base/config/environments/test_spec.rb b/.template/spec/base/config/environments/test_spec.rb index 37b9970d..59765325 100644 --- a/.template/spec/base/config/environments/test_spec.rb +++ b/.template/spec/base/config/environments/test_spec.rb @@ -11,6 +11,10 @@ expect(subject).to contain(bullet_config) end + it 'eager load on CI' do + expect(subject).to contain('config.eager_load = ENV["C"].present?') + end + private def mailer_default_url_config diff --git a/.template/spec/variants/web/config/environments/test_spec.rb b/.template/spec/variants/web/config/environments/test_spec.rb index fb66e3c2..dcf10690 100644 --- a/.template/spec/variants/web/config/environments/test_spec.rb +++ b/.template/spec/variants/web/config/environments/test_spec.rb @@ -14,8 +14,4 @@ it 'configures the assets to not compile when asset is missing' do expect(subject).to contain('config.assets.compile = false') end - - it 'eager load on CI' do - expect(subject).to contain('config.eager_load = ENV["C"].present?') - end end From a324f2c7e0bef555862cd15347312ea1a2a111bf Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Thu, 9 Feb 2023 14:18:14 +0700 Subject: [PATCH 15/19] [gh387] Add --format progress into the test --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0debdfdc..439ae33c 100644 --- a/Makefile +++ b/Makefile @@ -46,9 +46,9 @@ test_template: cd ../.template && \ bundle install; \ if [ $(VARIANT) = web ]; then \ - bundle exec rspec --pattern="${base_spec}, ${web_spec}, ${base_addon_spec}, ${web_addon_spec}"; \ + bundle exec rspec --pattern="${base_spec}, ${web_spec}, ${base_addon_spec}, ${web_addon_spec}" --format progress; \ elif [ $(VARIANT) = api ]; then \ - bundle exec rspec --pattern="${base_spec}, ${api_spec}, ${base_addon_spec}, ${api_addon_spec}"; \ + bundle exec rspec --pattern="${base_spec}, ${api_spec}, ${base_addon_spec}, ${api_addon_spec}" --format progress; \ fi; cleanup: From 24fd152145734273d164b0af9d17158e2d9e8c06 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Thu, 9 Feb 2023 14:42:36 +0700 Subject: [PATCH 16/19] [gh387] Refactor the workflow naming --- .../{test_variants.yml => test_generated_app.yml} | 8 ++++---- .github/workflows/test_production_build.yml | 4 ++-- .github/workflows/test_template.yml | 4 ++-- .template/spec/base/config/environments/test_spec.rb | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) rename .github/workflows/{test_variants.yml => test_generated_app.yml} (95%) diff --git a/.github/workflows/test_variants.yml b/.github/workflows/test_generated_app.yml similarity index 95% rename from .github/workflows/test_variants.yml rename to .github/workflows/test_generated_app.yml index fcef09b4..6b833270 100644 --- a/.github/workflows/test_variants.yml +++ b/.github/workflows/test_generated_app.yml @@ -1,4 +1,4 @@ -name: Test Variants +name: Test Generated App on: push @@ -15,7 +15,7 @@ env: jobs: test: - name: Test ${{ matrix.variant }} variant + name: ${{ matrix.variant }} variant runs-on: ubuntu-latest strategy: matrix: @@ -100,12 +100,12 @@ jobs: cd $APP_NAME docker-compose push test - - name: Test template + - name: Test the structure that generated by the template run: | export BRANCH_TAG=${{ env.BRANCH_TAG }}-${{ matrix.variant }} make test_template VARIANT=${{ matrix.variant }} - - name: Test variants + - name: Test the generated app run: | export BRANCH_TAG=${{ env.BRANCH_TAG }}-${{ matrix.variant }} make test_variant_app diff --git a/.github/workflows/test_production_build.yml b/.github/workflows/test_production_build.yml index e5082d59..1f9c0cf3 100644 --- a/.github/workflows/test_production_build.yml +++ b/.github/workflows/test_production_build.yml @@ -1,4 +1,4 @@ -name: Test production build +name: Test Production Docker Build on: push @@ -12,7 +12,7 @@ env: jobs: build_production: - name: Build docker production image for ${{ matrix.variant }} variant + name: ${{ matrix.variant }} variant runs-on: ubuntu-latest strategy: matrix: diff --git a/.github/workflows/test_template.yml b/.github/workflows/test_template.yml index 82f694bd..aef35c7f 100644 --- a/.github/workflows/test_template.yml +++ b/.github/workflows/test_template.yml @@ -1,4 +1,4 @@ -name: Test Template +name: Test Template's codebase on: push @@ -7,7 +7,7 @@ env: jobs: test: - name: Test template + name: Installation and linting runs-on: ubuntu-latest steps: diff --git a/.template/spec/base/config/environments/test_spec.rb b/.template/spec/base/config/environments/test_spec.rb index 59765325..3791b197 100644 --- a/.template/spec/base/config/environments/test_spec.rb +++ b/.template/spec/base/config/environments/test_spec.rb @@ -12,7 +12,7 @@ end it 'eager load on CI' do - expect(subject).to contain('config.eager_load = ENV["C"].present?') + expect(subject).to contain('config.eager_load = ENV["CI"].present?') end private From 543fa848e4263fdbca269c984e3a4adc8c764b7f Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Fri, 17 Feb 2023 09:12:11 +0700 Subject: [PATCH 17/19] [gh387] Bring the space back, modify the workflow naming --- .github/ISSUE_TEMPLATE/bug_template.md | 6 +++--- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .github/workflows/test_generated_app.yml | 2 +- .github/workflows/test_template.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_template.md b/.github/ISSUE_TEMPLATE/bug_template.md index 4da7909c..eeddfcc1 100644 --- a/.github/ISSUE_TEMPLATE/bug_template.md +++ b/.github/ISSUE_TEMPLATE/bug_template.md @@ -15,6 +15,6 @@ Describe what should be the correct behaviour. ## Steps to reproduce -1. -2. -3. +1. +2. +3. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 07f12ab3..b468e4d6 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ -Close https://github.com/nimblehq/rails-templates/issues/?? +close # ## What happened 👀 diff --git a/.github/workflows/test_generated_app.yml b/.github/workflows/test_generated_app.yml index 6b833270..16874b8b 100644 --- a/.github/workflows/test_generated_app.yml +++ b/.github/workflows/test_generated_app.yml @@ -100,7 +100,7 @@ jobs: cd $APP_NAME docker-compose push test - - name: Test the structure that generated by the template + - name: Test the structure that is generated by the template run: | export BRANCH_TAG=${{ env.BRANCH_TAG }}-${{ matrix.variant }} make test_template VARIANT=${{ matrix.variant }} diff --git a/.github/workflows/test_template.yml b/.github/workflows/test_template.yml index aef35c7f..5d071269 100644 --- a/.github/workflows/test_template.yml +++ b/.github/workflows/test_template.yml @@ -1,4 +1,4 @@ -name: Test Template's codebase +name: Test the codebase of the template on: push From 023ed000f2ba888b9ab8f274ed49f18fe0e35308 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 13 Mar 2023 16:17:34 +0700 Subject: [PATCH 18/19] [gh1183] Remove the request support --- .template/addons/devise/spec_support.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/.template/addons/devise/spec_support.rb b/.template/addons/devise/spec_support.rb index 1ed82eba..344129dc 100644 --- a/.template/addons/devise/spec_support.rb +++ b/.template/addons/devise/spec_support.rb @@ -4,6 +4,5 @@ RSpec.configure do |config| config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::Test::ControllerHelpers, type: :view - config.include Devise::Test::IntegrationHelpers, type: :request end RUBY From 8374b5df573702b4efc6f3d7fe184e9298fb77b1 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Mon, 13 Mar 2023 16:21:26 +0700 Subject: [PATCH 19/19] [gh395] Support request test --- .template/addons/devise/spec_support.rb | 1 + .template/variants/web/spec/support/assets.rb | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.template/addons/devise/spec_support.rb b/.template/addons/devise/spec_support.rb index 344129dc..1ed82eba 100644 --- a/.template/addons/devise/spec_support.rb +++ b/.template/addons/devise/spec_support.rb @@ -4,5 +4,6 @@ RSpec.configure do |config| config.include Devise::Test::ControllerHelpers, type: :controller config.include Devise::Test::ControllerHelpers, type: :view + config.include Devise::Test::IntegrationHelpers, type: :request end RUBY diff --git a/.template/variants/web/spec/support/assets.rb b/.template/variants/web/spec/support/assets.rb index 85f0ba24..65fadbca 100644 --- a/.template/variants/web/spec/support/assets.rb +++ b/.template/variants/web/spec/support/assets.rb @@ -4,6 +4,18 @@ config.when_first_matching_example_defined(type: :system) do # On CI we use Docker and the assets are precompiled (in the Dockerfile) already # On local, usually we run the test on the host machine so have to precompile the assets before running the test - `bundle exec rails assets:precompile RAILS_ENV=test NODE_ENV=test` unless ENV['CI'] + precompile_assets unless ENV['CI'] end + + config.when_first_matching_example_defined(type: :request) do + # On CI we use Docker and the assets are precompiled (in the Dockerfile) already + # On local, usually we run the test on the host machine so have to precompile the assets before running the test + precompile_assets unless ENV['CI'] + end +end + +private + +def precompile_assets + `bundle exec rails assets:precompile RAILS_ENV=test NODE_ENV=test` end