Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] S'assurer que les images de Modules de prod respectent les contraintes tech (PIX-17215) #11842

Merged
merged 4 commits into from
Mar 26, 2025

Conversation

yannbertrand
Copy link
Member

@yannbertrand yannbertrand commented Mar 25, 2025

🌸 Problème

Dans les modules il est possible d'utiliser des images temporaires hébergées un peu n'importe où pour garder en flexibilité lors de la conception des contenus de modules. Une fois le module validé on souhaite contrôler où sont hébergées nos images.

🌳 Proposition

Ajouter une couche de validation automatisée sur les modules prêts à la production (isBeta === false), pour le moment pour s'assurer que les images respectent nos critères d'hébergement.

En terme de contenu, les 8 modules "en prod" sont concernés par cette erreur. On propose :

  • déplacer les assets du module jeu-video-enfant depuis images.pix.fr vers assets.pix.org.
  • repasser les 7 autres modules en béta le temps de migrer.

Aussi, ajout d'un check que l'URL est valide (même si déjà fait côté schéma Joi) pour s'éviter d'autres erreurs techniques...

🐝 Remarques

C'est un POC d'aprem tech.

🤧 Pour tester

Voir que la CI en l'état jette des erreurs pour toute image non hébergée sur assets.pix.org.

Copy link
Contributor

Les tests Modulix ont échoué. Voici les détails :


> pix-api@5.71.0 modulix:test
> npm run test:api:path -- 'tests/devcomp/unit/infrastructure/datasources/learning-content/module-datasource_test.js' 'tests/devcomp/acceptance/module-instantiation_test.js' 'tests/devcomp/unit/infrastructure/datasources/learning-content/validation/module-validation_test.js' 'tests/devcomp/integration/repositories/module-repository_test.js'


> pix-api@5.71.0 test:api:path
> NODE_ENV=test mocha --exit --recursive --reporter=${MOCHA_REPORTER:-dot} tests/devcomp/unit/infrastructure/datasources/learning-content/module-datasource_test.js tests/devcomp/acceptance/module-instantiation_test.js tests/devcomp/unit/infrastructure/datasources/learning-content/validation/module-validation_test.js tests/devcomp/integration/repositories/module-repository_test.js



  .......................!!........!..!!!!................
  .....

  54 passing (11s)
  7 failing

  1) Acceptance | Modules
       Verify modules
         module bases-clavier-1 should respect the domain:
     AssertionError: The image URL must be from "assets.pix.org" when module is production ready
      at Context.<anonymous> (file:///home/runner/work/pix/pix/api/tests/devcomp/acceptance/module-instantiation_test.js:22:18)
      at Runnable.run (file:///home/runner/work/pix/pix/api/tests/tooling/mocha-tools.js:8:29)
      at process.processImmediate (node:internal/timers:491:21)

  2) Acceptance | Modules
       Verify modules
         module bases-clavier-2 should respect the domain:
     AssertionError: The image URL must be from "assets.pix.org" when module is production ready
      at Context.<anonymous> (file:///home/runner/work/pix/pix/api/tests/devcomp/acceptance/module-instantiation_test.js:22:18)
      at Runnable.run (file:///home/runner/work/pix/pix/api/tests/tooling/mocha-tools.js:8:29)
      at process.processImmediate (node:internal/timers:491:21)

  3) Acceptance | Modules
       Verify modules
         module ports-connexions-essentiels should respect the domain:
     AssertionError: The image URL must be from "assets.pix.org" when module is production ready
      at Context.<anonymous> (file:///home/runner/work/pix/pix/api/tests/devcomp/acceptance/module-instantiation_test.js:22:18)
      at Runnable.run (file:///home/runner/work/pix/pix/api/tests/tooling/mocha-tools.js:8:29)
      at process.processImmediate (node:internal/timers:491:21)

  4) Acceptance | Modules
       Verify modules
         module tmp08ef should respect the domain:
     AssertionError: The image URL must be from "assets.pix.org" when module is production ready
      at Context.<anonymous> (file:///home/runner/work/pix/pix/api/tests/devcomp/acceptance/module-instantiation_test.js:22:18)
      at Runnable.run (file:///home/runner/work/pix/pix/api/tests/tooling/mocha-tools.js:8:29)
      at process.processImmediate (node:internal/timers:491:21)

  5) Acceptance | Modules
       Verify modules
         module tri-multicritere-tableau should respect the domain:
     AssertionError: The image URL must be from "assets.pix.org" when module is production ready
      at Context.<anonymous> (file:///home/runner/work/pix/pix/api/tests/devcomp/acceptance/module-instantiation_test.js:22:18)
      at Runnable.run (file:///home/runner/work/pix/pix/api/tests/tooling/mocha-tools.js:8:29)
      at process.processImmediate (node:internal/timers:491:21)

  6) Acceptance | Modules
       Verify modules
         module utiliser-souris-ordinateur-1 should respect the domain:
     AssertionError: The image URL must be from "assets.pix.org" when module is production ready
      at Context.<anonymous> (file:///home/runner/work/pix/pix/api/tests/devcomp/acceptance/module-instantiation_test.js:22:18)
      at Runnable.run (file:///home/runner/work/pix/pix/api/tests/tooling/mocha-tools.js:8:29)
      at process.processImmediate (node:internal/timers:491:21)

  7) Acceptance | Modules
       Verify modules
         module utiliser-souris-ordinateur-2 should respect the domain:
     AssertionError: The image URL must be from "assets.pix.org" when module is production ready
      at Context.<anonymous> (file:///home/runner/work/pix/pix/api/tests/devcomp/acceptance/module-instantiation_test.js:22:18)
      at Runnable.run (file:///home/runner/work/pix/pix/api/tests/tooling/mocha-tools.js:8:29)
      at process.processImmediate (node:internal/timers:491:21)



@pix-bot-github
Copy link

Une fois les applications déployées, elles seront accessibles via les liens suivants :

Les variables d'environnement seront accessibles via les liens suivants :

@yannbertrand yannbertrand force-pushed the tech-test-image-production-readiness branch 2 times, most recently from db7c65b to 19b55fe Compare March 25, 2025 16:58
@yannbertrand yannbertrand changed the title [FEATURE] S'assurer que les images de Modules de prod respectent les contraintes tech [FEATURE] S'assurer que les images de Modules de prod respectent les contraintes tech (PIX-17215) Mar 26, 2025
import { assertNotNullOrUndefined } from '../../../../shared/domain/models/asserts.js';
import { Element } from './Element.js';

class Image extends Element {
static #VALID_PRODUCTION_HOSTNAME = 'assets.pix.org';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion : variabiliser le hostname pour éviter que ce soit trop en clair dans le repo ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discuté ensemble, ça reste hautement expérimental et temporaire, on ne s'embête pas à le variabiliser pour le moment

@@ -62,11 +74,35 @@ describe('Unit | Devcomp | Domain | Models | Element | Image', function () {
describe('An image without an alternative text', function () {
it('should throw an error', function () {
// when
const error = catchErrSync(() => new Image({ id: 'id', url: 'url', alt: 'alt' }))();
const error = catchErrSync(() => new Image({ id: 'id', url: 'https://images.pix.fr/coolcat.jpg', alt: 'alt' }))();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coolman qui choisit l'image Coolcat .. La Brigade du cool a encore frappé

@yannbertrand yannbertrand force-pushed the tech-test-image-production-readiness branch 2 times, most recently from cdf2940 to 5b816f1 Compare March 26, 2025 15:00
@yannbertrand yannbertrand force-pushed the tech-test-image-production-readiness branch from 5b816f1 to a706046 Compare March 26, 2025 15:21
@pix-service-auto-merge pix-service-auto-merge merged commit eea0294 into dev Mar 26, 2025
7 of 11 checks passed
@pix-service-auto-merge pix-service-auto-merge deleted the tech-test-image-production-readiness branch March 26, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants