From 673b186095e5ecf189380faa93fc20e9bd946a32 Mon Sep 17 00:00:00 2001 From: Nathan Papes Date: Wed, 13 Mar 2024 13:47:57 -0400 Subject: [PATCH 01/13] fix MathJax default zoom menu option --- app/javascript/Case.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/javascript/Case.jsx b/app/javascript/Case.jsx index f142aab0..33b8abea 100644 --- a/app/javascript/Case.jsx +++ b/app/javascript/Case.jsx @@ -132,9 +132,11 @@ class Case extends React.Component<{ render () { const { kicker, basename, needsPretest, hasQuiz, editing } = this.props const mathJaxOptions = { - menuOptions: { - settings: { - zoom: 'Click', + options: { + menuOptions: { + settings: { + zoom: 'Click', + }, }, }, } From c6916e4a10f1250f1fcfaf88b759b43705b54ed4 Mon Sep 17 00:00:00 2001 From: Nathan Papes Date: Wed, 17 Apr 2024 15:24:23 -0400 Subject: [PATCH 02/13] simple docker build and run test suite --- .github/workflows/run_tests.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/run_tests.yml diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml new file mode 100644 index 00000000..591c81bb --- /dev/null +++ b/.github/workflows/run_tests.yml @@ -0,0 +1,20 @@ +name: Run tests +on: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Build docker containers and run tests + run: | + docker compose run -e RAILS_ENV=test web bundle exec rspec --exclude-pattern="**/features/*_spec.rb" + + - if: always() + uses: ouzi-dev/commit-status-updater@v1.1.0 + with: + name: "Run tests" + status: "${{ job.status }}" From 7843f5bc22bf0ceed4e5e6cfd5f82c2d1bbcd94e Mon Sep 17 00:00:00 2001 From: Nathan Papes Date: Wed, 17 Apr 2024 15:31:47 -0400 Subject: [PATCH 03/13] add pull_request trigger to github action --- .github/workflows/run_tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 591c81bb..480ce18b 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -1,5 +1,6 @@ name: Run tests on: + pull_request: workflow_dispatch: jobs: From b3b990c30adec268f04b7cdaaeedbecd4247028d Mon Sep 17 00:00:00 2001 From: Nathan Papes Date: Wed, 17 Apr 2024 15:55:20 -0400 Subject: [PATCH 04/13] modify entrypoint --- .github/workflows/run_tests.yml | 1 + entrypoint.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 480ce18b..65b36bfe 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -15,6 +15,7 @@ jobs: docker compose run -e RAILS_ENV=test web bundle exec rspec --exclude-pattern="**/features/*_spec.rb" - if: always() + name: Commit status uses: ouzi-dev/commit-status-updater@v1.1.0 with: name: "Run tests" diff --git a/entrypoint.sh b/entrypoint.sh index 209f726c..d53720bd 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash -if [ "$RAILS_ENV" = "development" ] && [ -z "$SIDEKIQ_CONCURRENCY" ]; then +if [[ "$RAILS_ENV" == "development" || "$RAILS_ENV" == "test" ]] && [[ -z "$SIDEKIQ_CONCURRENCY" ]]; then count=$(bundle exec rails runner "puts Case.count") if [ "${count//$'\n'/}" -eq 0 ]; then bundle exec rails db:environment:set RAILS_ENV=development From 23721cb4977218a474a32157869aaa8daaa02647 Mon Sep 17 00:00:00 2001 From: Nathan Papes Date: Wed, 17 Apr 2024 18:46:10 -0400 Subject: [PATCH 05/13] try new ruby-docker-technique --- .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..1e75a731 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: ci + +on: + workflow_dispatch: + pull_request: + +jobs: + ci: + name: Build and run tests with containers + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: docker/setup-buildx-action@v3 + + - uses: docker/build-push-action@v5 + with: + context: . + push: false + load: true + cache-from: type=gha + cache-to: type=gha,mode=max + tags: galahq/gala:latest + + - name: Docker Compose up + run: docker-compose up -d + + - name: List running Docker containers + run: docker ps + + - name: Run Tests + run: docker exec -e RAILS_ENV=test app_web_1 bundle exec rspec --exclude-pattern="**/features/*_spec.rb" + + - name: Docker Compose down + run: docker-compose down + + - if: always() + uses: ouzi-dev/commit-status-updater@v1.1.0 + with: + name: Test + status: "${{ job.status }}" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 22ed7cd1..f2fc49b4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3' +version: '3.8' services: web: &web build: ./ From 08b1fde8ad0213818101661bc1213bc73914bd17 Mon Sep 17 00:00:00 2001 From: Nathan Papes Date: Wed, 17 Apr 2024 19:06:23 -0400 Subject: [PATCH 06/13] more trial and error --- .github/workflows/ci.yml | 9 +++++++-- .github/workflows/{run_tests.yml => run_tests.yml.bak} | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) rename .github/workflows/{run_tests.yml => run_tests.yml.bak} (96%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e75a731..45fdda17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,12 @@ jobs: load: true cache-from: type=gha cache-to: type=gha,mode=max - tags: galahq/gala:latest + tags: gala_web + + - name: Docker Compose pull and build + run: | + docker-compose pull --ignore-pull-failures + docker-compose build - name: Docker Compose up run: docker-compose up -d @@ -29,7 +34,7 @@ jobs: run: docker ps - name: Run Tests - run: docker exec -e RAILS_ENV=test app_web_1 bundle exec rspec --exclude-pattern="**/features/*_spec.rb" + run: docker exec -e RAILS_ENV=test gala_web_1 bundle exec rspec --exclude-pattern="**/features/*_spec.rb" - name: Docker Compose down run: docker-compose down diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml.bak similarity index 96% rename from .github/workflows/run_tests.yml rename to .github/workflows/run_tests.yml.bak index 65b36bfe..92215c40 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml.bak @@ -1,6 +1,5 @@ name: Run tests on: - pull_request: workflow_dispatch: jobs: From 932fd2d7e41feaf46b186a35928acf0e8a6cc01a Mon Sep 17 00:00:00 2001 From: Nathan Papes Date: Wed, 17 Apr 2024 19:16:34 -0400 Subject: [PATCH 07/13] trying to leverage the docker layer caching when running docker compose up --- docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index f2fc49b4..122f6c08 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,9 @@ version: '3.8' services: web: &web - build: ./ + build: + context: ./ + image: gala_web stdin_open: true tty: true command: foreman start -f Procfile.dev From 47dd755739b9b67389f09ee782c9321879ebd831 Mon Sep 17 00:00:00 2001 From: Nathan Papes Date: Wed, 17 Apr 2024 19:24:48 -0400 Subject: [PATCH 08/13] add line to prepare test db --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 45fdda17..b14538fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,9 @@ jobs: run: docker ps - name: Run Tests - run: docker exec -e RAILS_ENV=test gala_web_1 bundle exec rspec --exclude-pattern="**/features/*_spec.rb" + run: | + docker exec -e RAILS_ENV=test gala_web_1 bundle exec rails db:test:prepare + docker exec -e RAILS_ENV=test gala_web_1 bundle exec rspec --exclude-pattern="**/features/*_spec.rb" - name: Docker Compose down run: docker-compose down From 346cab5bf33bb71686bcce3d37c6e10996442fc8 Mon Sep 17 00:00:00 2001 From: Nathan Papes Date: Wed, 17 Apr 2024 19:38:50 -0400 Subject: [PATCH 09/13] lets try this again --- .github/workflows/ci.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b14538fa..5fb389f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,20 +13,18 @@ jobs: - uses: docker/setup-buildx-action@v3 + - name: Build Docker image + run: | + DOCKER_BUILDKIT=1 docker build -t gala_web . + - uses: docker/build-push-action@v5 with: context: . push: false - load: true - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=gha,scope=${{ github.repository }} + cache-to: type=gha,mode=max,scope=${{ github.repository }} tags: gala_web - - name: Docker Compose pull and build - run: | - docker-compose pull --ignore-pull-failures - docker-compose build - - name: Docker Compose up run: docker-compose up -d From bb249ef2f923f12b40a2f20b2204910fa79ac2b8 Mon Sep 17 00:00:00 2001 From: Nathan Papes Date: Wed, 17 Apr 2024 19:55:46 -0400 Subject: [PATCH 10/13] try different layer caching tool --- .github/workflows/ci.yml | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5fb389f5..033b43b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,40 +1,29 @@ name: ci - + on: workflow_dispatch: pull_request: - + jobs: ci: name: Build and run tests with containers runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: docker/setup-buildx-action@v3 + - uses: satackey/action-docker-layer-caching@v0.0.11 + # Ignore the failure of a step and avoid terminating the job. + continue-on-error: true - - name: Build Docker image + - name: Build Docker images run: | - DOCKER_BUILDKIT=1 docker build -t gala_web . - - - uses: docker/build-push-action@v5 - with: - context: . - push: false - cache-from: type=gha,scope=${{ github.repository }} - cache-to: type=gha,mode=max,scope=${{ github.repository }} - tags: gala_web + docker-compose build - - name: Docker Compose up + - name: Run with Docker Compose run: docker-compose up -d - - - name: List running Docker containers - run: docker ps - - - name: Run Tests - run: | - docker exec -e RAILS_ENV=test gala_web_1 bundle exec rails db:test:prepare - docker exec -e RAILS_ENV=test gala_web_1 bundle exec rspec --exclude-pattern="**/features/*_spec.rb" + + - name: Run tests + run: docker exec -e RAILS_ENV=test gala_web_1 bundle exec rspec --exclude-pattern="**/features/*_spec.rb" - name: Docker Compose down run: docker-compose down From 7cc8e6fca711272b2e01ebfc17a2251911b6063a Mon Sep 17 00:00:00 2001 From: Nathan Papes Date: Wed, 17 Apr 2024 20:10:51 -0400 Subject: [PATCH 11/13] lets see if caching worked --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 033b43b4..8f1e3d5d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,9 @@ jobs: run: docker-compose up -d - name: Run tests - run: docker exec -e RAILS_ENV=test gala_web_1 bundle exec rspec --exclude-pattern="**/features/*_spec.rb" + run: | + docker exec -e RAILS_ENV=test gala_web_1 bash -c "bundle exec rails db:test:prepare && \ + bundle exec rspec --exclude-pattern=\"**/features/*_spec.rb\"" - name: Docker Compose down run: docker-compose down From 1843a4771ca2b8d20699406d8dcafa296992e103 Mon Sep 17 00:00:00 2001 From: Nathan Papes Date: Wed, 17 Apr 2024 20:23:21 -0400 Subject: [PATCH 12/13] add latest tag to image --- docker-compose.yml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 122f6c08..c3ebcc50 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: web: &web build: context: ./ - image: gala_web + image: gala_web:latest stdin_open: true tty: true command: foreman start -f Procfile.dev @@ -43,14 +43,5 @@ services: image: redis:6 ports: - 6379:6379 - # selenium: - # image: seleniarm/standalone-chromium - # shm_size: 4gb - # environment: - # SE_NODE_MAX_SESSIONS: 1 - # ports: - # - 4444:4444 - # volumes: - # - /dev/shm:/dev/shm volumes: db_data: From 21235027f759ce12872af5ac2b6f731fd3f3da6a Mon Sep 17 00:00:00 2001 From: Nathan Papes Date: Wed, 17 Apr 2024 20:24:15 -0400 Subject: [PATCH 13/13] use latest tag for both web and worker --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index c3ebcc50..d40d5c8f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,7 +23,7 @@ services: - /app/tmp/cache/ worker: <<: *web - image: gala_web + image: gala_web:latest command: bundle exec sidekiq environment: <<: *env