From e983ceabe2f5f775ccac34ecf1bd541c7bfb44d9 Mon Sep 17 00:00:00 2001 From: Mali Oz Date: Tue, 30 Apr 2024 14:53:43 -0300 Subject: [PATCH 1/4] deploy on production optimization --- deploy.sh | 2 +- docker-deploy.sh | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/deploy.sh b/deploy.sh index 78ef426..6e230e0 100755 --- a/deploy.sh +++ b/deploy.sh @@ -3,4 +3,4 @@ git pull docker-compose down docker-compose build docker-compose up -d -docker exec -t notar_app_1 ./docker-deploy.sh +docker exec -t --env-file .env notar_app_1 ./docker-deploy.sh diff --git a/docker-deploy.sh b/docker-deploy.sh index 024b444..25f2588 100755 --- a/docker-deploy.sh +++ b/docker-deploy.sh @@ -1,11 +1,19 @@ #!/bin/sh # Installs and upgrades any new PHP libraries -composer install +if [ "$APP_ENV" == "production" ]; then + composer install --no-dev -o +else + composer install +fi # Makes sure our storage link is set up php artisan storage:link # Clear application and config caches php artisan config:clear php artisan cache:clear +php artisan view:clear # Runs any DB migration php artisan migrate --force +# Setup caches +php artisan config:cache +php artisan view:cache From 0c7a7a6f2abf1c96823d59ec679de96f44f40eef Mon Sep 17 00:00:00 2001 From: Mali Oz Date: Tue, 30 Apr 2024 14:53:58 -0300 Subject: [PATCH 2/4] testing improvements --- README.md | 9 ++++++++- database/seeders/DatabaseSeeder.php | 3 +++ tests/cypress/integration/01_admin_login.cy.js | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a72d550..6e0a03f 100644 --- a/README.md +++ b/README.md @@ -58,11 +58,18 @@ Os testes foram escritos para ajudar no desenvolvimento da plataforma. Todos os Para testar e desenvolver a plataforma, instale o notaR no seu ambiente local para testes, seguindo o guia acima. Além disso, é necessário instalar o `npm`. Com isso, para abrir a interface gráfica do `cypress`, basta executar o seguinte comando: ``` -npx cypress run +npx cypress open ``` Na interface gráfica, selecione **E2E Testing**, e um browser à sua escolha. +Para rodar todos os testes de uma vez, direto do terminal, rode: + +``` +npx cypress run +``` + + Para mais detalhes, consulte a [documentação do Cypress](https://docs.cypress.io/). ## Licença de uso diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 4169dd7..c04c556 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -24,6 +24,9 @@ public function run() $turma = Turma::factory() ->hasAttached($alunos) ->create(); + $turma2 = Turma::factory() + ->hasAttached($alunos) + ->create(); $turma_vazia = Turma::factory()->create(); diff --git a/tests/cypress/integration/01_admin_login.cy.js b/tests/cypress/integration/01_admin_login.cy.js index 936e10c..630a83e 100644 --- a/tests/cypress/integration/01_admin_login.cy.js +++ b/tests/cypress/integration/01_admin_login.cy.js @@ -8,6 +8,7 @@ describe('Login test', () => { // seed a user in the DB that we can control from our tests cy.exec(`${artisan} migrate:fresh`) cy.exec(`${artisan} migrate:admin ${password}`) + cy.exec(`${artisan} db:seed`) }) From 19e88fdca83e586e0eb3c35d3be13ec04bd6ec80 Mon Sep 17 00:00:00 2001 From: Mali Oz Date: Wed, 1 May 2024 14:27:53 -0300 Subject: [PATCH 3/4] clear all caches --- docker-deploy.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docker-deploy.sh b/docker-deploy.sh index 25f2588..7e5d708 100755 --- a/docker-deploy.sh +++ b/docker-deploy.sh @@ -8,12 +8,11 @@ else fi # Makes sure our storage link is set up php artisan storage:link -# Clear application and config caches -php artisan config:clear -php artisan cache:clear -php artisan view:clear # Runs any DB migration php artisan migrate --force -# Setup caches +# Clear and restart caches +php artisan cache:clear php artisan config:cache php artisan view:cache +php artisan route:cache +php artisan event:cache From 65fb62cfd109c8e1dbed63cb124fc2f27168522d Mon Sep 17 00:00:00 2001 From: Mali Oz Date: Wed, 1 May 2024 14:28:00 -0300 Subject: [PATCH 4/4] organize seeder --- database/seeders/DatabaseSeeder.php | 63 ++++++++++++++--------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index c04c556..6782e75 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -9,6 +9,7 @@ use App\Models\Nota; use App\Models\Prazo; use App\Models\Teste; +use Monolog\Handler\SamplingHandler; class DatabaseSeeder extends Seeder { @@ -20,46 +21,42 @@ class DatabaseSeeder extends Seeder public function run() { $ind_user = User::factory()->create(); - $alunos = User::factory()->count(3)->create(); - $turma = Turma::factory() - ->hasAttached($alunos) - ->create(); - $turma2 = Turma::factory() + $alunos = User::factory()->count(30)->create(); + + $turma_vazia = Turma::factory()->create(); + $turmas = Turma::factory()->count(10) ->hasAttached($alunos) ->create(); - $turma_vazia = Turma::factory()->create(); + $exercicios = Exercicio::factory()->count(30) + ->has(Teste::factory()->count(3)) + ->create(); - $exercicios = Exercicio::factory()->count(5) - ->has(Teste::factory()->count(3)) - ->create(); + foreach ($exercicios as $exercicio) { + Nota::factory()->count(2) + ->for($ind_user) + ->for($exercicio) + ->create(); - Prazo::factory() - ->for($turma) - ->for($exercicios[1]) - ->create(); - Prazo::factory() - ->for($turma_vazia) - ->for($exercicios[2]) - ->create(); + Prazo::factory() + ->for($turma_vazia) + ->for($exercicio) + ->create(); - Nota::factory()->count(2) - ->for($ind_user) - ->for($exercicios[1]) - ->create(); - Nota::factory()->count(2) - ->for($ind_user) - ->for($exercicios[2]) - ->create(); - Nota::factory()->count(2) - ->for($alunos[1]) - ->for($exercicios[1]) - ->create(); - Nota::factory()->count(2) - ->for($alunos[2]) - ->for($exercicios[2]) - ->create(); + foreach ($turmas as $turma) { + Prazo::factory() + ->for($turma) + ->for($exercicio) + ->create(); + } + foreach ($alunos as $aluno) { + Nota::factory()->count(5) + ->for($aluno) + ->for($exercicio) + ->create(); + } + } } }