From 1e3b7202218e15f5e9fcfdfd0f5375b59a6b1994 Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Fri, 15 Mar 2024 16:02:38 +0100 Subject: [PATCH 01/20] Bump to Erlang 25 and Elixir 1.16 --- .tool-versions | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.tool-versions b/.tool-versions index c455319d11..53494a3fbe 100644 --- a/.tool-versions +++ b/.tool-versions @@ -7,12 +7,13 @@ # - https://hexdocs.pm/elixir/compatibility-and-deprecations.html # - https://github.com/elixir-lang/elixir/releases # - `asdf list all elixir` -elixir 1.15.5-otp-24 +elixir 1.16.2-otp-25 # See: # - https://github.com/erlang/otp/releases +# - Blog, e.g. https://www.erlang.org/blog/my-otp-25-highlights/ # - https://github.com/erlang/otp/blob/master/otp_versions.table # - `asdf list all erlang` -erlang 24.3.4.13 +erlang 25.3.2.10 nodejs 18.17.1 From f38c9806e5e1ab59a89704304473f635225b2f53 Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Fri, 15 Mar 2024 16:09:08 +0100 Subject: [PATCH 02/20] Add a first version of upgrade documentation --- docs/upgrade_versions.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 docs/upgrade_versions.md diff --git a/docs/upgrade_versions.md b/docs/upgrade_versions.md new file mode 100644 index 0000000000..a434f5cdb6 --- /dev/null +++ b/docs/upgrade_versions.md @@ -0,0 +1,16 @@ +1. faire une branche, mettre à jour tool versions +2. Voir ce qu’il y a dans tool versions => doc sur où sont les versions disponibles, plus deprecations elixir. +3. Soit bump mineur, soit bump majeur. +4. Gaffe à OTP 26 => issue. +5. Allez aussi chercher Erlang compatible +6. Plus Nodejs si possible, mais mieux vaut le faire après. +7. => Le mieux est une image qui bumbe tout, mais dans ma branche y aller par étapes. +8. Vérifier que les tests passent. Le build test va pas passer, c’est normal. Il est possible qu’il y ait des warnings à traiter. Traiter les warnings. Astuce : mix test | tee upgrade.log +9. Possible de créer un ticket, voir https://github.com/etalab/transport-site/issues/3307 +10. On peut faire la MAJ Elixir et pas OTP 26 https://github.com/etalab/transport-site/issues/3315 +11. Si c’est tout smooth et que ça marche bien, cloner transport-ops en local. Voir https://github.com/etalab/transport-ops +12. Github workflow du repository : aller voir les tests pour protéger +13. Donc : une fois branche en local qui marche bien, modifier transport-ops pour faire correspondre, vérifier que tout marche bien, puis faire une release (avec le nom bien formaté). +14. Puis enfin, PR de transport-site à mettre à jour avec l’image. +15. Ne pas tester en local transport-site avec l’image docker : les tests sufiront + prochainement. Il n’y a pas de grosse diff entre passage asdf et docker. +16. Mettre à jour les readme :) => créer une doc sur trnasport-site sur le workflow. From 28c6babdfa939699b6dbac9e86f5776247b1379b Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Fri, 15 Mar 2024 16:23:40 +0100 Subject: [PATCH 03/20] Bump also nodejs version --- .tool-versions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tool-versions b/.tool-versions index 53494a3fbe..cad644c19b 100644 --- a/.tool-versions +++ b/.tool-versions @@ -16,4 +16,4 @@ elixir 1.16.2-otp-25 # - `asdf list all erlang` erlang 25.3.2.10 -nodejs 18.17.1 +nodejs 20.11.1 From 0b51c6ff7dc11ddbe0d7b6c4ac7392cb8dda0ff2 Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Fri, 15 Mar 2024 17:14:27 +0100 Subject: [PATCH 04/20] Point to the right docker image --- .circleci/config.yml | 2 +- Dockerfile | 2 +- Dockerfile.dev | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7566ed9c78..d87c3e7ef6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,7 +12,7 @@ default_docker: &default_docker defaults: &defaults parameters: base_image: - default: ghcr.io/etalab/transport-ops:elixir-1.15.5-erlang-24.3.4.13-ubuntu-focal-20230126-transport-tools-1.0.7 + default: ghcr.io/etalab/transport-ops:elixir-1.16.2-erlang-25.3.2.10-ubuntu-focal-20240123-transport-tools-1.0.7 type: string # useful to invalidate the build cache manually by bumping the version build_cache_key: diff --git a/Dockerfile b/Dockerfile index b4615b274a..81a21454da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/etalab/transport-ops:elixir-1.15.5-erlang-24.3.4.13-ubuntu-focal-20230126-transport-tools-1.0.7 +FROM ghcr.io/etalab/transport-ops:elixir-1.16.2-erlang-25.3.2.10-ubuntu-focal-20240123-transport-tools-1.0.7 RUN mkdir phoenixapp WORKDIR /phoenixapp diff --git a/Dockerfile.dev b/Dockerfile.dev index 966d22ef7e..06ad6b8de7 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM ghcr.io/etalab/transport-ops:elixir-1.15.5-erlang-24.3.4.13-ubuntu-focal-20230126-transport-tools-1.0.7 +FROM ghcr.io/etalab/transport-ops:elixir-1.16.2-erlang-25.3.2.10-ubuntu-focal-20240123-transport-tools-1.0.7 RUN apt-get install -y git inotify-tools postgresql-client>=11 From de7fb35b2f620b5d70dc628531c44f099eb2f95a Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Fri, 15 Mar 2024 18:46:18 +0100 Subject: [PATCH 05/20] improve readme --- docs/upgrade_versions.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/upgrade_versions.md b/docs/upgrade_versions.md index a434f5cdb6..6a74be749f 100644 --- a/docs/upgrade_versions.md +++ b/docs/upgrade_versions.md @@ -1,16 +1,32 @@ +## Gestion des versions et des images Docker + +Le setup standard de développement s’appuie sur ASDF pour la gestion des versions. Cependant, la CI/CD (CircleCI) et la production s’appuient sur Docker. + +Une première image Docker est mise à disposition par le dépôt tranport-ops : elle récupère une image Docker standard sur le hub Docker avec déjà la bonne version de Elixir et Erlang, rajoute Node et les outils annexes (transport-tools), et est publiée sur le dépôt d’images Docker de Github. + +L’application transport-site récupère l’image Docker de transport-ops, et y rajoute uniquement son propre code, le compile, lance le serveur, les migrations, et expose le serveur à l’extérieur. + +CircleCI pour les tests va donc faire ces étapes là de compilation du code Elixir, mais sans devoir reconstruire toute l’image (puisque s’appuyant sur l’image de transport-ops). Quand on pousse sur les serveurs de CleverCloud, un premier serveur va créer l’image Docker finale (mêmes étapes que sur CircleCI, donc un temps de compilation existe) puis déployer l’image résultante. Potentiellement, on pourrait réduire à l’avenir le temps de déploiement en fournissant directement l’image Docker avec l’application précompilée, et que la même image serve pour les tests et pour la production. + +## Processus de mise à jour + +Les versions de ASDF et de Docker doivent être mises à jour dans la même branche de transport-site (sinon des tests ratent). Il faut donc en préalable du merge de la branche qu’une image avec les bonnes versions de Elixir, Erlang/OTP et Node et les outils transport soit déjà présente, donc qu’une branche correspondante sur transport-ops ait été mergée et un package crée. + +Dans les grandes lignes : on teste d’abord avec ASDF que tout va bien, puis on fait le nécessaire sur le repo transport-ops pour créer un package, et on finalise la branche sur transport-site avec la référence de l’image. + 1. faire une branche, mettre à jour tool versions 2. Voir ce qu’il y a dans tool versions => doc sur où sont les versions disponibles, plus deprecations elixir. 3. Soit bump mineur, soit bump majeur. 4. Gaffe à OTP 26 => issue. 5. Allez aussi chercher Erlang compatible -6. Plus Nodejs si possible, mais mieux vaut le faire après. +6. Plus Nodejs si possible, mais mieux vaut le faire après. Prendre la version LTS sur nodejs.org 7. => Le mieux est une image qui bumbe tout, mais dans ma branche y aller par étapes. 8. Vérifier que les tests passent. Le build test va pas passer, c’est normal. Il est possible qu’il y ait des warnings à traiter. Traiter les warnings. Astuce : mix test | tee upgrade.log 9. Possible de créer un ticket, voir https://github.com/etalab/transport-site/issues/3307 10. On peut faire la MAJ Elixir et pas OTP 26 https://github.com/etalab/transport-site/issues/3315 11. Si c’est tout smooth et que ça marche bien, cloner transport-ops en local. Voir https://github.com/etalab/transport-ops 12. Github workflow du repository : aller voir les tests pour protéger -13. Donc : une fois branche en local qui marche bien, modifier transport-ops pour faire correspondre, vérifier que tout marche bien, puis faire une release (avec le nom bien formaté). +13. Donc : une fois branche en local qui marche bien, modifier transport-ops pour faire correspondre, vérifier que tout marche bien, puis faire une release (avec le nom bien formaté). Pour faire une release, voir le readme. 14. Puis enfin, PR de transport-site à mettre à jour avec l’image. 15. Ne pas tester en local transport-site avec l’image docker : les tests sufiront + prochainement. Il n’y a pas de grosse diff entre passage asdf et docker. 16. Mettre à jour les readme :) => créer une doc sur trnasport-site sur le workflow. From b8ee5dbf59fe6a9d9194601e9397d3db7b59f183 Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Fri, 15 Mar 2024 19:17:39 +0100 Subject: [PATCH 06/20] remove compilation warnings --- apps/transport/lib/db/contact.ex | 2 +- apps/transport/lib/transport_web/views/backoffice/page_view.ex | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/transport/lib/db/contact.ex b/apps/transport/lib/db/contact.ex index 9db2687a75..1c6ed07fcd 100644 --- a/apps/transport/lib/db/contact.ex +++ b/apps/transport/lib/db/contact.ex @@ -163,7 +163,7 @@ defmodule DB.Contact do def organization_name(orgs) do certified_orgs = orgs - |> Enum.filter(fn %DB.Organization{badges: badges} -> Enum.any?(badges, &match?(&1, %{"kind" => "certified"})) end) + |> Enum.filter(fn %DB.Organization{badges: badges} -> Enum.any?(badges, &match?(%{"kind" => "certified"}, &1)) end) case certified_orgs do [] -> orgs |> List.first() |> Map.fetch!(:name) diff --git a/apps/transport/lib/transport_web/views/backoffice/page_view.ex b/apps/transport/lib/transport_web/views/backoffice/page_view.ex index 494c5a49b0..3e2e236b9b 100644 --- a/apps/transport/lib/transport_web/views/backoffice/page_view.ex +++ b/apps/transport/lib/transport_web/views/backoffice/page_view.ex @@ -77,7 +77,7 @@ defmodule TransportWeb.Backoffice.PageView do def unaccent(nil), do: "" def unaccent(value) when is_binary(value) do - ~R<\p{Mn}>u + ~r/\p{Mn}/u |> Regex.replace(value |> :unicode.characters_to_nfd_binary(), "") |> :unicode.characters_to_nfc_binary() end From dbf8a57580904fd7292f95c631eb35b1da49209c Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Fri, 15 Mar 2024 19:27:18 +0100 Subject: [PATCH 07/20] remove warnings about match on 0.0 --- .../jobs/dataset_quality_score_test.exs | 22 ++++++++++--------- .../jobs/geo_data/lez_to_geo_data_test.exs | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/transport/test/transport/jobs/dataset_quality_score_test.exs b/apps/transport/test/transport/jobs/dataset_quality_score_test.exs index a854e9229c..c1adf989ec 100644 --- a/apps/transport/test/transport/jobs/dataset_quality_score_test.exs +++ b/apps/transport/test/transport/jobs/dataset_quality_score_test.exs @@ -58,7 +58,7 @@ defmodule Transport.Test.Transport.Jobs.DatasetQualityScoreTest do assert %{ format: "GTFS", - freshness: 0.0, + freshness: +0.0, raw_measure: %{end_date: _, start_date: _}, resource_id: _ } = resource_freshness(resource) @@ -127,7 +127,7 @@ defmodule Transport.Test.Transport.Jobs.DatasetQualityScoreTest do metadata: %{"feed_timestamp_delay" => 1000} ) - assert %{format: "gbfs", freshness: 0.0, raw_measure: 1000, resource_id: _} = resource_freshness(resource) + assert %{format: "gbfs", freshness: +0.0, raw_measure: 1000, resource_id: _} = resource_freshness(resource) end test "GBFS resource without metadata for today" do @@ -178,7 +178,7 @@ defmodule Transport.Test.Transport.Jobs.DatasetQualityScoreTest do insert(:resource_unavailability, start: hours_ago(2), resource: resource) assert %{ - availability: 0.0, + availability: +0.0, raw_measure: (22 / 24 * 100) |> Float.floor(1), resource_id: resource.id } == resource_availability(resource) @@ -240,7 +240,7 @@ defmodule Transport.Test.Transport.Jobs.DatasetQualityScoreTest do details: %{ resources: [ %{availability: 1.0, raw_measure: nil, resource_id: r1.id}, - %{availability: 0.0, raw_measure: 0, resource_id: r2.id} + %{availability: +0.0, raw_measure: 0, resource_id: r2.id} ] }, score: 0.5 @@ -269,7 +269,7 @@ defmodule Transport.Test.Transport.Jobs.DatasetQualityScoreTest do assert [] == dataset |> DB.Repo.preload(:resources) |> Map.fetch!(:resources) - assert %{score: 0.0, details: %{resources: []}} == current_dataset_availability(dataset.id) + assert %{score: +0.0, details: %{resources: []}} == current_dataset_availability(dataset.id) end end @@ -298,7 +298,7 @@ defmodule Transport.Test.Transport.Jobs.DatasetQualityScoreTest do }, %{ format: "gtfs-rt", - freshness: 0.0, + freshness: +0.0, raw_measure: 1000, resource_id: ^resource_id_2 } @@ -319,12 +319,12 @@ defmodule Transport.Test.Transport.Jobs.DatasetQualityScoreTest do # average freshness for only 1 resource with freshness information available assert %{ - score: 0.0, + score: +0.0, details: %{ resources: [ %{ format: "GTFS", - freshness: 0.0, + freshness: +0.0, raw_measure: %{end_date: _, start_date: _}, resource_id: ^resource_id }, @@ -369,7 +369,9 @@ defmodule Transport.Test.Transport.Jobs.DatasetQualityScoreTest do assert %{ score: 0, details: %{ - resources: [%{compliance: 0.0, raw_measure: %{"has_errors" => true}, resource_id: geojson_resource.id}] + resources: [ + %{compliance: +0.0, raw_measure: %{"has_errors" => true}, resource_id: geojson_resource.id} + ] } } == current_dataset_compliance(dataset.id) end @@ -395,7 +397,7 @@ defmodule Transport.Test.Transport.Jobs.DatasetQualityScoreTest do score: 0.5, details: %{ resources: [ - %{compliance: 0.0, raw_measure: %{"max_error" => "Error"}, resource_id: gtfs_1.id}, + %{compliance: +0.0, raw_measure: %{"max_error" => "Error"}, resource_id: gtfs_1.id}, %{compliance: 1.0, raw_measure: %{"max_error" => "Warning"}, resource_id: gtfs_2.id} ] } diff --git a/apps/transport/test/transport/jobs/geo_data/lez_to_geo_data_test.exs b/apps/transport/test/transport/jobs/geo_data/lez_to_geo_data_test.exs index d1fe4bda70..f62603a785 100644 --- a/apps/transport/test/transport/jobs/geo_data/lez_to_geo_data_test.exs +++ b/apps/transport/test/transport/jobs/geo_data/lez_to_geo_data_test.exs @@ -29,7 +29,7 @@ defmodule Transport.Jobs.LowEmissionZonesToGeoDataTest do coordinates: [ [[{102.0, 2.0}, {103.0, 2.0}, {103.0, 3.0}, {102.0, 3.0}, {102.0, 2.0}]], [ - [{100.0, 0.0}, {101.0, 0.0}, {101.0, 1.0}, {100.0, 1.0}, {100.0, 0.0}], + [{100.0, +0.0}, {101.0, +0.0}, {101.0, 1.0}, {100.0, 1.0}, {100.0, +0.0}], [{100.2, 0.2}, {100.2, 0.8}, {100.8, 0.8}, {100.8, 0.2}, {100.2, 0.2}] ] ], From 8f4d8067c27eb932ffb18c1e734753235fbe4416 Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Mon, 18 Mar 2024 12:40:22 +0100 Subject: [PATCH 08/20] Update credo --- .credo.exs | 7 +++---- mix.lock | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.credo.exs b/.credo.exs index 0edcce4878..b82dee0407 100644 --- a/.credo.exs +++ b/.credo.exs @@ -83,7 +83,6 @@ {Credo.Check.Readability.ModuleNames}, {Credo.Check.Readability.ParenthesesOnZeroArityDefs}, {Credo.Check.Readability.ParenthesesInCondition}, - {Credo.Check.Readability.PredicateFunctionNames}, {Credo.Check.Readability.PreferImplicitTry}, {Credo.Check.Readability.RedundantBlankLines}, {Credo.Check.Readability.StringSigils}, @@ -129,10 +128,10 @@ # Deprecated checks (these will be deleted after a grace period) # - {Credo.Check.Readability.Specs, false} + {Credo.Check.Readability.Specs, false}, - # Custom checks can be created using `mix credo.gen.check`. - # + # Allowing for now functions like is_gtfs? + {Credo.Check.Readability.PredicateFunctionNames, false} ] } ] diff --git a/mix.lock b/mix.lock index 561c6eaccd..5ccd409dc5 100644 --- a/mix.lock +++ b/mix.lock @@ -2,7 +2,7 @@ "appsignal": {:hex, :appsignal, "2.8.0", "7d7c0c4a2d57ebbf4aaa9ba50483712feed302d9545f9743eb1c921c8a114997", [:make, :mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:decorator, "~> 1.2.3 or ~> 1.3", [hex: :decorator, repo: "hexpm", optional: false]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d6dfe14553caae7cb38c690ca4a9f5f298df80240c19120f166a9ac30bfb0cce"}, "appsignal_phoenix": {:hex, :appsignal_phoenix, "2.3.4", "c83a8e15a51456db7d722a21bfe9a45e23618b550219caa8fb6d4853f61b5734", [:mix], [{:appsignal, ">= 2.7.6 and < 3.0.0", [hex: :appsignal, repo: "hexpm", optional: false]}, {:appsignal_plug, ">= 2.0.15 and < 3.0.0", [hex: :appsignal_plug, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.11 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_live_view, "~> 0.9", [hex: :phoenix_live_view, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1ca040fbfa653bdda25735031d8b89c81ebb50c475bc35d5ac0e13236e5f6600"}, "appsignal_plug": {:hex, :appsignal_plug, "2.0.15", "758a8a78944878e8461bbc77ca86219121a56f4299c6d79940ab083cf9afea00", [:mix], [{:appsignal, ">= 2.7.6 and < 3.0.0", [hex: :appsignal, repo: "hexpm", optional: false]}, {:plug, ">= 1.1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1c6059049e2081e808aaef04e2b9917e06277f61a35a0e103db860d08cbc41f1"}, - "bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"}, + "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, "bypass": {:hex, :bypass, "2.1.0", "909782781bf8e20ee86a9cabde36b259d44af8b9f38756173e8f5e2e1fabb9b1", [:mix], [{:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "d9b5df8fa5b7a6efa08384e9bbecfe4ce61c77d28a4282f79e02f1ef78d96b80"}, "cachex": {:hex, :cachex, "3.6.0", "14a1bfbeee060dd9bec25a5b6f4e4691e3670ebda28c8ba2884b12fe30b36bf8", [:mix], [{:eternal, "~> 1.2", [hex: :eternal, repo: "hexpm", optional: false]}, {:jumper, "~> 1.0", [hex: :jumper, repo: "hexpm", optional: false]}, {:sleeplocks, "~> 1.1", [hex: :sleeplocks, repo: "hexpm", optional: false]}, {:unsafe, "~> 1.0", [hex: :unsafe, repo: "hexpm", optional: false]}], "hexpm", "ebf24e373883bc8e0c8d894a63bbe102ae13d918f790121f5cfe6e485cc8e2e2"}, "castore": {:hex, :castore, "1.0.5", "9eeebb394cc9a0f3ae56b813459f990abb0a3dedee1be6b27fdb50301930502f", [:mix], [], "hexpm", "8d7c597c3e4a64c395980882d4bca3cebb8d74197c590dc272cfd3b6a6310578"}, @@ -17,7 +17,7 @@ "cowboy": {:hex, :cowboy, "2.10.0", "ff9ffeff91dae4ae270dd975642997afe2a1179d94b1887863e43f681a203e26", [:make, :rebar3], [{:cowlib, "2.12.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "3afdccb7183cc6f143cb14d3cf51fa00e53db9ec80cdcd525482f5e99bc41d6b"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"}, "cowlib": {:hex, :cowlib, "2.12.1", "a9fa9a625f1d2025fe6b462cb865881329b5caff8f1854d1cbc9f9533f00e1e1", [:make, :rebar3], [], "hexpm", "163b73f6367a7341b33c794c4e88e7dbfe6498ac42dcd69ef44c5bc5507c8db0"}, - "credo": {:hex, :credo, "1.7.1", "6e26bbcc9e22eefbff7e43188e69924e78818e2fe6282487d0703652bc20fd62", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "e9871c6095a4c0381c89b6aa98bc6260a8ba6addccf7f6a53da8849c748a58a2"}, + "credo": {:hex, :credo, "1.7.5", "643213503b1c766ec0496d828c90c424471ea54da77c8a168c725686377b9545", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "f799e9b5cd1891577d8c773d245668aa74a2fcd15eb277f51a0131690ebfb3fd"}, "crontab": {:hex, :crontab, "1.1.13", "3bad04f050b9f7f1c237809e42223999c150656a6b2afbbfef597d56df2144c5", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm", "d67441bec989640e3afb94e123f45a2bc42d76e02988c9613885dc3d01cf7085"}, "csv": {:hex, :csv, "3.2.1", "6d401f1ed33acb2627682a9ab6021e96d33ca6c1c6bccc243d8f7e2197d032f5", [:mix], [], "hexpm", "8f55a0524923ae49e97ff2642122a2ce7c61e159e7fe1184670b2ce847aee6c8"}, "db_connection": {:hex, :db_connection, "2.6.0", "77d835c472b5b67fc4f29556dee74bf511bbafecdcaf98c27d27fa5918152086", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c2f992d15725e721ec7fbc1189d4ecdb8afef76648c746a8e1cad35e3b8a35f3"}, From 50894f6fefabfade23185182188923e749d9b3e8 Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Tue, 19 Mar 2024 09:19:00 +0100 Subject: [PATCH 09/20] Fix Dialyxir errors --- apps/shared/lib/hasher.ex | 2 +- mix.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/shared/lib/hasher.ex b/apps/shared/lib/hasher.ex index 763b7f91a1..1b326e1946 100644 --- a/apps/shared/lib/hasher.ex +++ b/apps/shared/lib/hasher.ex @@ -89,7 +89,7 @@ defmodule Hasher do def get_file_hash(file_path) do file_path - |> File.stream!([], 2048) + |> File.stream!(2048) |> compute_checksum(:sha256) end diff --git a/mix.lock b/mix.lock index 5ccd409dc5..3f8e387503 100644 --- a/mix.lock +++ b/mix.lock @@ -35,8 +35,8 @@ "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, "etag_plug": {:hex, :etag_plug, "1.0.0", "2252e16ac5da6bc5367907437bd760740bb209a7e73e821b756f6c9ea808d210", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "fcde90c1f7fa20c624036d4b5e023714f7945031bc8bcf03d1ec43bf462800c1"}, "eternal": {:hex, :eternal, "1.2.2", "d1641c86368de99375b98d183042dd6c2b234262b8d08dfd72b9eeaafc2a1abd", [:mix], [], "hexpm", "2c9fe32b9c3726703ba5e1d43a1d255a4f3f2d8f8f9bc19f094c7cb1a7a9e782"}, - "ex_aws": {:hex, :ex_aws, "2.5.0", "1785e69350b16514c1049330537c7da10039b1a53e1d253bbd703b135174aec3", [:mix], [{:configparser_ex, "~> 4.0", [hex: :configparser_ex, repo: "hexpm", optional: true]}, {:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:jsx, "~> 2.8 or ~> 3.0", [hex: :jsx, repo: "hexpm", optional: true]}, {:mime, "~> 1.2 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:sweet_xml, "~> 0.7", [hex: :sweet_xml, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "971b86e5495fc0ae1c318e35e23f389e74cf322f2c02d34037c6fc6d405006f1"}, - "ex_aws_s3": {:hex, :ex_aws_s3, "2.5.2", "cee302b8e9ee198cc0d89f1de2a7d6a8921e1a556574476cf5590d2156590fe3", [:mix], [{:ex_aws, "~> 2.0", [hex: :ex_aws, repo: "hexpm", optional: false]}, {:sweet_xml, ">= 0.0.0", [hex: :sweet_xml, repo: "hexpm", optional: true]}], "hexpm", "cc5bd945a22a99eece4721d734ae2452d3717e81c357a781c8574663254df4a1"}, + "ex_aws": {:hex, :ex_aws, "2.5.2", "6799647ceda4d9d8bca44655fb812fee5859c7603819bb07d6dfe07f27210ae7", [:mix], [{:configparser_ex, "~> 4.0", [hex: :configparser_ex, repo: "hexpm", optional: true]}, {:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:jsx, "~> 2.8 or ~> 3.0", [hex: :jsx, repo: "hexpm", optional: true]}, {:mime, "~> 1.2 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:sweet_xml, "~> 0.7", [hex: :sweet_xml, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1b708e26027e0fb1e16d21ef201b2142254ab148531a746cbbb38e461733d9fa"}, + "ex_aws_s3": {:hex, :ex_aws_s3, "2.5.3", "422468e5c3e1a4da5298e66c3468b465cfd354b842e512cb1f6fbbe4e2f5bdaf", [:mix], [{:ex_aws, "~> 2.0", [hex: :ex_aws, repo: "hexpm", optional: false]}, {:sweet_xml, ">= 0.0.0", [hex: :sweet_xml, repo: "hexpm", optional: true]}], "hexpm", "4f09dd372cc386550e484808c5ac5027766c8d0cd8271ccc578b82ee6ef4f3b8"}, "ex_cldr": {:hex, :ex_cldr, "2.37.5", "9da6d97334035b961d2c2de167dc6af8cd3e09859301a5b8f49f90bd8b034593", [:mix], [{:cldr_utils, "~> 2.21", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:gettext, "~> 0.19", [hex: :gettext, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: true]}], "hexpm", "74ad5ddff791112ce4156382e171a5f5d3766af9d5c4675e0571f081fe136479"}, "ex_cldr_currencies": {:hex, :ex_cldr_currencies, "2.15.1", "e92ba17c41e7405b7784e0e65f406b5f17cfe313e0e70de9befd653e12854822", [:mix], [{:ex_cldr, "~> 2.34", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "31df8bd37688340f8819bdd770eb17d659652078d34db632b85d4a32864d6a25"}, "ex_cldr_numbers": {:hex, :ex_cldr_numbers, "2.32.3", "b631ff94c982ec518e46bf4736000a30a33d6b58facc085d5f240305f512ad4a", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:digital_token, "~> 0.3 or ~> 1.0", [hex: :digital_token, repo: "hexpm", optional: false]}, {:ex_cldr, "~> 2.37", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_currencies, ">= 2.14.2", [hex: :ex_cldr_currencies, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "7b626ff1e59a0ec9c3c5db5ce9ca91a6995e2ab56426b71f3cbf67181ea225f5"}, From 67e0cee89162674be360a3763fe678dd3abc9db0 Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Tue, 19 Mar 2024 14:34:01 +0100 Subject: [PATCH 10/20] improve documentation --- .tool-versions | 3 +++ docs/upgrade_versions.md | 31 +++++++++++++------------------ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.tool-versions b/.tool-versions index cad644c19b..693ae08b43 100644 --- a/.tool-versions +++ b/.tool-versions @@ -3,6 +3,8 @@ # provides an easy way to ensure local development and test will rely on roughly # the same versions as in production, if one uses the "asdf" version manager. +# Update ASDF and plugins: asdf update && asdf plugin update --all + # See: # - https://hexdocs.pm/elixir/compatibility-and-deprecations.html # - https://github.com/elixir-lang/elixir/releases @@ -16,4 +18,5 @@ elixir 1.16.2-otp-25 # - `asdf list all erlang` erlang 25.3.2.10 +# Take an LTS version on https://nodejs.org/ nodejs 20.11.1 diff --git a/docs/upgrade_versions.md b/docs/upgrade_versions.md index 6a74be749f..91f30e9332 100644 --- a/docs/upgrade_versions.md +++ b/docs/upgrade_versions.md @@ -6,27 +6,22 @@ Une première image Docker est mise à disposition par le dépôt tranport-ops : L’application transport-site récupère l’image Docker de transport-ops, et y rajoute uniquement son propre code, le compile, lance le serveur, les migrations, et expose le serveur à l’extérieur. -CircleCI pour les tests va donc faire ces étapes là de compilation du code Elixir, mais sans devoir reconstruire toute l’image (puisque s’appuyant sur l’image de transport-ops). Quand on pousse sur les serveurs de CleverCloud, un premier serveur va créer l’image Docker finale (mêmes étapes que sur CircleCI, donc un temps de compilation existe) puis déployer l’image résultante. Potentiellement, on pourrait réduire à l’avenir le temps de déploiement en fournissant directement l’image Docker avec l’application précompilée, et que la même image serve pour les tests et pour la production. +CircleCI pour les tests va donc faire ces étapes là de compilation du code Elixir, mais sans devoir reconstruire toute l’image (puisque s’appuyant sur l’image de transport-ops). Quand on pousse sur les serveurs de CleverCloud, un premier serveur va créer l’image Docker finale (mêmes étapes que sur CircleCI, donc un temps de compilation existe) puis déployer l’image résultante sur un autre serveur. Potentiellement, on pourrait réduire à l’avenir le temps de déploiement en fournissant directement l’image Docker avec l’application précompilée, et que la même image serve pour les tests et pour la production. ## Processus de mise à jour -Les versions de ASDF et de Docker doivent être mises à jour dans la même branche de transport-site (sinon des tests ratent). Il faut donc en préalable du merge de la branche qu’une image avec les bonnes versions de Elixir, Erlang/OTP et Node et les outils transport soit déjà présente, donc qu’une branche correspondante sur transport-ops ait été mergée et un package crée. +Les versions de ASDF et de Docker doivent être mises à jour dans la même branche de transport-site (sinon des tests ratent). Il faut donc en préalable du merge de la branche qu’une image Docker avec les bonnes versions de Elixir, Erlang/OTP et Node et les outils transport existe, donc qu’une branche correspondante sur transport-ops ait été mergée et un package crée. Dans les grandes lignes : on teste d’abord avec ASDF que tout va bien, puis on fait le nécessaire sur le repo transport-ops pour créer un package, et on finalise la branche sur transport-site avec la référence de l’image. -1. faire une branche, mettre à jour tool versions -2. Voir ce qu’il y a dans tool versions => doc sur où sont les versions disponibles, plus deprecations elixir. -3. Soit bump mineur, soit bump majeur. -4. Gaffe à OTP 26 => issue. -5. Allez aussi chercher Erlang compatible -6. Plus Nodejs si possible, mais mieux vaut le faire après. Prendre la version LTS sur nodejs.org -7. => Le mieux est une image qui bumbe tout, mais dans ma branche y aller par étapes. -8. Vérifier que les tests passent. Le build test va pas passer, c’est normal. Il est possible qu’il y ait des warnings à traiter. Traiter les warnings. Astuce : mix test | tee upgrade.log -9. Possible de créer un ticket, voir https://github.com/etalab/transport-site/issues/3307 -10. On peut faire la MAJ Elixir et pas OTP 26 https://github.com/etalab/transport-site/issues/3315 -11. Si c’est tout smooth et que ça marche bien, cloner transport-ops en local. Voir https://github.com/etalab/transport-ops -12. Github workflow du repository : aller voir les tests pour protéger -13. Donc : une fois branche en local qui marche bien, modifier transport-ops pour faire correspondre, vérifier que tout marche bien, puis faire une release (avec le nom bien formaté). Pour faire une release, voir le readme. -14. Puis enfin, PR de transport-site à mettre à jour avec l’image. -15. Ne pas tester en local transport-site avec l’image docker : les tests sufiront + prochainement. Il n’y a pas de grosse diff entre passage asdf et docker. -16. Mettre à jour les readme :) => créer une doc sur trnasport-site sur le workflow. +1. Créer une branche +2. Mettre à jour `.tool_versions`. Le fichier contient un peu de documentation sur les commandes ASDF, et où trouver les versions disponibles, la compatibilité Elixir/Erlang et les notes de versions. +3. Vérifier que : + 1. Ça compile + 2. Les tests passent (il y aura forcément une erreur liée à la différence de version avec Docker) + 3. Credo et Dialyxir n’aient pas de warning. +4. Noter tous les warnings, qui serviront soit dans une issue pour un traitement postérieur, soit seront mis dans la pull request. Exemple : https://github.com/etalab/transport-site/issues/3307 +5. Créer un package Docker correspondant dans le dépôt https://github.com/etalab/transport-ops On peut pousser sur une branche pour faire tourner la CI Github Workflow, pas besoin d’avoir Docker en local. Lire le README de transport-ops pour le détail. +6. Modifier transport-site avec la bonne image Docker. Il n’est pas nécessaire de tester en local transport-site avec l’image Docker : les tests sufiront + prochainement. Il n’y a pas de grosse diff entre passage asdf et docker. +7. Créer une pull request en draft pour faire tourner Circle CI. +8. Tester le plus possible : en local et sur le serveur de staging (`git push origin ma_branche:prochainement`) From f583cd26cd39436d44a528e4df701b1dc0c20a1c Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Tue, 19 Mar 2024 15:07:17 +0100 Subject: [PATCH 11/20] =?UTF-8?q?Update=20to=20OTP=E2=80=AF26=20in=20.tool?= =?UTF-8?q?=5Fversions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .tool-versions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tool-versions b/.tool-versions index 693ae08b43..33a1d9a463 100644 --- a/.tool-versions +++ b/.tool-versions @@ -9,14 +9,14 @@ # - https://hexdocs.pm/elixir/compatibility-and-deprecations.html # - https://github.com/elixir-lang/elixir/releases # - `asdf list all elixir` -elixir 1.16.2-otp-25 +elixir 1.16.2-otp-26 # See: # - https://github.com/erlang/otp/releases # - Blog, e.g. https://www.erlang.org/blog/my-otp-25-highlights/ # - https://github.com/erlang/otp/blob/master/otp_versions.table # - `asdf list all erlang` -erlang 25.3.2.10 +erlang 26.2.3 # Take an LTS version on https://nodejs.org/ nodejs 20.11.1 From b68c1c1c7e5b4c021aced65169f4bfaf9887c831 Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Tue, 19 Mar 2024 15:41:37 +0100 Subject: [PATCH 12/20] Order of map operations changed in OTP26 --- .../test/datagouvfr/client/discussions_test.exs | 2 +- apps/shared/test/validation/gbfs_validator_test.exs | 2 +- apps/transport/lib/jobs/gtfs_rt_metadata.ex | 10 ++++++++-- .../controllers/dataset_controller_test.exs | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/datagouvfr/test/datagouvfr/client/discussions_test.exs b/apps/datagouvfr/test/datagouvfr/client/discussions_test.exs index 894a2435e2..14e17325e7 100644 --- a/apps/datagouvfr/test/datagouvfr/client/discussions_test.exs +++ b/apps/datagouvfr/test/datagouvfr/client/discussions_test.exs @@ -21,7 +21,7 @@ defmodule Datagouvfr.Client.DiscussionTest do {"content-type", "application/json"} ] - assert body == ~s({"comment":"#{comment}","subject":{"class":"Dataset","id":"#{datagouv_id}"},"title":"#{title}"}) + assert body == ~s({"title":"#{title}","comment":"#{comment}","subject":{"id":"#{datagouv_id}","class":"Dataset"}}) json(%{"title" => title, "discussion" => [%{"content" => comment}]}, status: 201) end) diff --git a/apps/shared/test/validation/gbfs_validator_test.exs b/apps/shared/test/validation/gbfs_validator_test.exs index 0c366ff9ab..f2245077ca 100644 --- a/apps/shared/test/validation/gbfs_validator_test.exs +++ b/apps/shared/test/validation/gbfs_validator_test.exs @@ -55,7 +55,7 @@ defmodule GBFSValidatorTest do test "can encode summary" do assert """ - {"errors_count":0,"has_errors":false,"validator":"validator_module","validator_version":"31c5325","version_detected":"1.1","version_validated":"1.1"}\ + {"validator":"validator_module","errors_count":0,"has_errors":false,"version_detected":"1.1","version_validated":"1.1","validator_version":"31c5325"}\ """ == Jason.encode!(%Summary{ errors_count: 0, diff --git a/apps/transport/lib/jobs/gtfs_rt_metadata.ex b/apps/transport/lib/jobs/gtfs_rt_metadata.ex index fd2904a3b1..6a4571a7b6 100644 --- a/apps/transport/lib/jobs/gtfs_rt_metadata.ex +++ b/apps/transport/lib/jobs/gtfs_rt_metadata.ex @@ -69,10 +69,16 @@ defmodule Transport.Jobs.GTFSRTMetadataJob do iex> present_entities(%{service_alerts: 0, vehicle_positions: 1}) ["vehicle_positions"] iex> present_entities(%{service_alerts: 2, vehicle_positions: 1}) - ["service_alerts", "vehicle_positions"] + ["vehicle_positions", "service_alerts"] """ def present_entities(count_entities) do - count_entities |> Map.filter(fn {_, v} -> v > 0 end) |> Enum.map(fn {k, _} -> Atom.to_string(k) end) + Enum.flat_map(count_entities, fn {k, v} -> + if v > 0 do + [Atom.to_string(k)] + else + [] + end + end) end @spec process_feed({:error, any} | {:ok, TransitRealtime.FeedMessage.t()}, DB.Resource.t()) :: any diff --git a/apps/transport/test/transport_web/controllers/dataset_controller_test.exs b/apps/transport/test/transport_web/controllers/dataset_controller_test.exs index 3777b75da3..75ea15cfd2 100644 --- a/apps/transport/test/transport_web/controllers/dataset_controller_test.exs +++ b/apps/transport/test/transport_web/controllers/dataset_controller_test.exs @@ -434,8 +434,8 @@ defmodule TransportWeb.DatasetControllerTest do assert [ {"table", [{"class", "table"}], [ - {"tr", [], [{"th", [], ["Conformité"]}, {"th", [], ["Fraicheur"]}]}, - {"tr", [], [{"td", [], ["80%"]}, {"td", [], ["55%"]}]} + {"tr", [], [{"th", [], ["Fraicheur"]}, {"th", [], ["Conformité"]}]}, + {"tr", [], [{"td", [], ["55%"]}, {"td", [], ["80%"]}]} ]} ] == content |> Floki.find("#quality-indicators table") end From d771a9e115d29e6939421d0ed9b8571264823488 Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Tue, 19 Mar 2024 16:16:56 +0100 Subject: [PATCH 13/20] Temporary OTP26 dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 81a21454da..035977e929 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/etalab/transport-ops:elixir-1.16.2-erlang-25.3.2.10-ubuntu-focal-20240123-transport-tools-1.0.7 +FROM ghcr.io/etalab/transport-ops:pr-57 RUN mkdir phoenixapp WORKDIR /phoenixapp From 7e749292428ec538eb081b3a493c3fd4270aef9b Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Tue, 19 Mar 2024 16:32:55 +0100 Subject: [PATCH 14/20] =?UTF-8?q?Revert=20"Update=20to=20OTP=E2=80=AF26=20?= =?UTF-8?q?in=20.tool=5Fversions"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f583cd26cd39436d44a528e4df701b1dc0c20a1c. --- .tool-versions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tool-versions b/.tool-versions index 33a1d9a463..693ae08b43 100644 --- a/.tool-versions +++ b/.tool-versions @@ -9,14 +9,14 @@ # - https://hexdocs.pm/elixir/compatibility-and-deprecations.html # - https://github.com/elixir-lang/elixir/releases # - `asdf list all elixir` -elixir 1.16.2-otp-26 +elixir 1.16.2-otp-25 # See: # - https://github.com/erlang/otp/releases # - Blog, e.g. https://www.erlang.org/blog/my-otp-25-highlights/ # - https://github.com/erlang/otp/blob/master/otp_versions.table # - `asdf list all erlang` -erlang 26.2.3 +erlang 25.3.2.10 # Take an LTS version on https://nodejs.org/ nodejs 20.11.1 From a9c546051d4f40db43abc8f9814c6b1dca5fc03c Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Tue, 19 Mar 2024 16:33:04 +0100 Subject: [PATCH 15/20] Revert "Order of map operations changed in OTP26" This reverts commit b68c1c1c7e5b4c021aced65169f4bfaf9887c831. --- .../test/datagouvfr/client/discussions_test.exs | 2 +- apps/shared/test/validation/gbfs_validator_test.exs | 2 +- apps/transport/lib/jobs/gtfs_rt_metadata.ex | 10 ++-------- .../controllers/dataset_controller_test.exs | 4 ++-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/apps/datagouvfr/test/datagouvfr/client/discussions_test.exs b/apps/datagouvfr/test/datagouvfr/client/discussions_test.exs index 14e17325e7..894a2435e2 100644 --- a/apps/datagouvfr/test/datagouvfr/client/discussions_test.exs +++ b/apps/datagouvfr/test/datagouvfr/client/discussions_test.exs @@ -21,7 +21,7 @@ defmodule Datagouvfr.Client.DiscussionTest do {"content-type", "application/json"} ] - assert body == ~s({"title":"#{title}","comment":"#{comment}","subject":{"id":"#{datagouv_id}","class":"Dataset"}}) + assert body == ~s({"comment":"#{comment}","subject":{"class":"Dataset","id":"#{datagouv_id}"},"title":"#{title}"}) json(%{"title" => title, "discussion" => [%{"content" => comment}]}, status: 201) end) diff --git a/apps/shared/test/validation/gbfs_validator_test.exs b/apps/shared/test/validation/gbfs_validator_test.exs index f2245077ca..0c366ff9ab 100644 --- a/apps/shared/test/validation/gbfs_validator_test.exs +++ b/apps/shared/test/validation/gbfs_validator_test.exs @@ -55,7 +55,7 @@ defmodule GBFSValidatorTest do test "can encode summary" do assert """ - {"validator":"validator_module","errors_count":0,"has_errors":false,"version_detected":"1.1","version_validated":"1.1","validator_version":"31c5325"}\ + {"errors_count":0,"has_errors":false,"validator":"validator_module","validator_version":"31c5325","version_detected":"1.1","version_validated":"1.1"}\ """ == Jason.encode!(%Summary{ errors_count: 0, diff --git a/apps/transport/lib/jobs/gtfs_rt_metadata.ex b/apps/transport/lib/jobs/gtfs_rt_metadata.ex index 6a4571a7b6..fd2904a3b1 100644 --- a/apps/transport/lib/jobs/gtfs_rt_metadata.ex +++ b/apps/transport/lib/jobs/gtfs_rt_metadata.ex @@ -69,16 +69,10 @@ defmodule Transport.Jobs.GTFSRTMetadataJob do iex> present_entities(%{service_alerts: 0, vehicle_positions: 1}) ["vehicle_positions"] iex> present_entities(%{service_alerts: 2, vehicle_positions: 1}) - ["vehicle_positions", "service_alerts"] + ["service_alerts", "vehicle_positions"] """ def present_entities(count_entities) do - Enum.flat_map(count_entities, fn {k, v} -> - if v > 0 do - [Atom.to_string(k)] - else - [] - end - end) + count_entities |> Map.filter(fn {_, v} -> v > 0 end) |> Enum.map(fn {k, _} -> Atom.to_string(k) end) end @spec process_feed({:error, any} | {:ok, TransitRealtime.FeedMessage.t()}, DB.Resource.t()) :: any diff --git a/apps/transport/test/transport_web/controllers/dataset_controller_test.exs b/apps/transport/test/transport_web/controllers/dataset_controller_test.exs index 75ea15cfd2..3777b75da3 100644 --- a/apps/transport/test/transport_web/controllers/dataset_controller_test.exs +++ b/apps/transport/test/transport_web/controllers/dataset_controller_test.exs @@ -434,8 +434,8 @@ defmodule TransportWeb.DatasetControllerTest do assert [ {"table", [{"class", "table"}], [ - {"tr", [], [{"th", [], ["Fraicheur"]}, {"th", [], ["Conformité"]}]}, - {"tr", [], [{"td", [], ["55%"]}, {"td", [], ["80%"]}]} + {"tr", [], [{"th", [], ["Conformité"]}, {"th", [], ["Fraicheur"]}]}, + {"tr", [], [{"td", [], ["80%"]}, {"td", [], ["55%"]}]} ]} ] == content |> Floki.find("#quality-indicators table") end From f07acc992960aef6974a36ca437b6aa6a2802ad7 Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Tue, 19 Mar 2024 16:33:06 +0100 Subject: [PATCH 16/20] Revert "Temporary OTP26 dockerfile" This reverts commit d771a9e115d29e6939421d0ed9b8571264823488. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 035977e929..81a21454da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/etalab/transport-ops:pr-57 +FROM ghcr.io/etalab/transport-ops:elixir-1.16.2-erlang-25.3.2.10-ubuntu-focal-20240123-transport-tools-1.0.7 RUN mkdir phoenixapp WORKDIR /phoenixapp From 72e16fd25abdbee942296217c0c1be51dd0ca183 Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Thu, 21 Mar 2024 09:14:08 +0100 Subject: [PATCH 17/20] Update comment in credo config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Thibaut Barrère --- .credo.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/.credo.exs b/.credo.exs index b82dee0407..2f8a2d5975 100644 --- a/.credo.exs +++ b/.credo.exs @@ -131,6 +131,7 @@ {Credo.Check.Readability.Specs, false}, # Allowing for now functions like is_gtfs? + # See https://github.com/etalab/transport-site/issues/3822 {Credo.Check.Readability.PredicateFunctionNames, false} ] } From 8c8ed749c0b097d3afb328e38c73618de2610169 Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Mon, 25 Mar 2024 16:16:57 +0100 Subject: [PATCH 18/20] Improve badges code in organizations --- apps/transport/lib/db/contact.ex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/transport/lib/db/contact.ex b/apps/transport/lib/db/contact.ex index 1124a85ccf..4393a844f5 100644 --- a/apps/transport/lib/db/contact.ex +++ b/apps/transport/lib/db/contact.ex @@ -162,8 +162,7 @@ defmodule DB.Contact do def organization_name(orgs) do certified_orgs = - orgs - |> Enum.filter(fn %DB.Organization{badges: badges} -> Enum.any?(badges, &match?(%{"kind" => "certified"}, &1)) end) + Enum.filter(orgs, fn %DB.Organization{badges: badges} -> %{"kind" => "certified"} in badges end) case certified_orgs do [] -> orgs |> List.first() |> Map.fetch!(:name) From a34566e7c28c2b9960c1c188765dd3babff003ed Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Mon, 25 Mar 2024 16:25:15 +0100 Subject: [PATCH 19/20] Revert credo config --- .credo.exs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.credo.exs b/.credo.exs index 2f8a2d5975..0edcce4878 100644 --- a/.credo.exs +++ b/.credo.exs @@ -83,6 +83,7 @@ {Credo.Check.Readability.ModuleNames}, {Credo.Check.Readability.ParenthesesOnZeroArityDefs}, {Credo.Check.Readability.ParenthesesInCondition}, + {Credo.Check.Readability.PredicateFunctionNames}, {Credo.Check.Readability.PreferImplicitTry}, {Credo.Check.Readability.RedundantBlankLines}, {Credo.Check.Readability.StringSigils}, @@ -128,11 +129,10 @@ # Deprecated checks (these will be deleted after a grace period) # - {Credo.Check.Readability.Specs, false}, + {Credo.Check.Readability.Specs, false} - # Allowing for now functions like is_gtfs? - # See https://github.com/etalab/transport-site/issues/3822 - {Credo.Check.Readability.PredicateFunctionNames, false} + # Custom checks can be created using `mix credo.gen.check`. + # ] } ] From 1864fa2428e405976d4ab79c8e522e43c71a33e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Mon, 8 Apr 2024 11:27:15 +0200 Subject: [PATCH 20/20] Bump OS to latest Ref: https://github.com/etalab/transport-ops/releases/tag/elixir-1.16.2-erlang-25.3.2.10-ubuntu-focal-20240216-transport-tools-1.0.7 --- .circleci/config.yml | 2 +- Dockerfile | 2 +- Dockerfile.dev | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d87c3e7ef6..86de651ea4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,7 +12,7 @@ default_docker: &default_docker defaults: &defaults parameters: base_image: - default: ghcr.io/etalab/transport-ops:elixir-1.16.2-erlang-25.3.2.10-ubuntu-focal-20240123-transport-tools-1.0.7 + default: ghcr.io/etalab/transport-ops:elixir-1.16.2-erlang-25.3.2.10-ubuntu-focal-20240216-transport-tools-1.0.7 type: string # useful to invalidate the build cache manually by bumping the version build_cache_key: diff --git a/Dockerfile b/Dockerfile index 81a21454da..e1ca670fdf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/etalab/transport-ops:elixir-1.16.2-erlang-25.3.2.10-ubuntu-focal-20240123-transport-tools-1.0.7 +FROM ghcr.io/etalab/transport-ops:elixir-1.16.2-erlang-25.3.2.10-ubuntu-focal-20240216-transport-tools-1.0.7 RUN mkdir phoenixapp WORKDIR /phoenixapp diff --git a/Dockerfile.dev b/Dockerfile.dev index 06ad6b8de7..670d386c86 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM ghcr.io/etalab/transport-ops:elixir-1.16.2-erlang-25.3.2.10-ubuntu-focal-20240123-transport-tools-1.0.7 +FROM ghcr.io/etalab/transport-ops:elixir-1.16.2-erlang-25.3.2.10-ubuntu-focal-20240216-transport-tools-1.0.7 RUN apt-get install -y git inotify-tools postgresql-client>=11