From a7a3a05e5869e3861abf60b1bf2dcb678bc7212e Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 17:51:04 +0100 Subject: [PATCH 01/51] [docker] premier test dev/main --- .gitlab-ci.yml | 43 +++++++++++++++++++++++++++++++++---------- R/test_BDD.R | 2 +- README.md | 10 +++++----- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 92f3268..79872ee 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,6 +7,7 @@ stages: # - test_r variables: + tag_dev: "dev" imagedb_name: "stacomi_db" db_version: "0.6.0" postgres_version: "14" @@ -14,16 +15,38 @@ variables: imager_name: "environnement_test_r" r_version: "0.1" POSTGRES_PASSWORD: postgres - -services: - - name: $CI_REGISTRY_IMAGE/$imagedb_name - alias: db - -build_db: + +default: + services: + - name: $CI_REGISTRY_IMAGE/$imagedb_name + alias: host_db + +########################### +# jobs for any development branch # +########################### + +build_db-dev: image: docker:latest stage: build_db services: - docker:dind + rules: + - if: '$CI_COMMIT_BRANCH != "main"' # only if there is changes in branch other than main +# changes: # and there is changes in Dockerfile +# - db.dockerfile + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version-$tag_dev -f db.dockerfile . + - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name + +build_db-prod: + image: docker:latest + stage: build_db + services: + - docker:dind + rules: + - if: '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch + when: manual script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version -f db.dockerfile . @@ -41,7 +64,7 @@ build_db: # - docker tag $CI_REGISTRY_IMAGE/$imager_name:$r_version $CI_REGISTRY_IMAGE/$imager_name:latest # - docker push --all-tags $CI_REGISTRY_IMAGE/$imager_name -test_psql: +test_psql-dev: image: ubuntu stage: test_psql script: @@ -49,10 +72,10 @@ test_psql: - apt install -y postgresql-client - psql --version - export PGPASSWORD=$POSTGRES_PASSWORD - - psql -U postgres -h db -c "SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';" - - psql -U postgres -h db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat - + - psql -U postgres -h host_db -c "SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';" + - psql -U postgres -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat + #test_r: # image: rocker/tidyverse # stage: test_r diff --git a/R/test_BDD.R b/R/test_BDD.R index 1f0c047..485233b 100644 --- a/R/test_BDD.R +++ b/R/test_BDD.R @@ -20,7 +20,7 @@ require("sqldf") options(sqldf.RPostgreSQL.user = "iav", sqldf.RPostgreSQL.password = "iav", sqldf.RPostgreSQL.dbname = "bd_contmig_nat", - sqldf.RPostgreSQL.host = "db", + sqldf.RPostgreSQL.host = "host_db", sqldf.RPostgreSQL.port = 5432) cat("###################") diff --git a/README.md b/README.md index c7d2b13..6c107ff 100644 --- a/README.md +++ b/README.md @@ -7,20 +7,20 @@ Scripts related with database development in stacomi. ## Docker -This repository also serves to build [docker](https://www.docker.com/) images with an expample database. -These images are on [this gitalbarepository](https://forgemia.inra.fr/stacomi/stacomi_db/container_registry/368). +This repository also serves to build [docker](https://www.docker.com/) images with an example database. +These images are on [this gitlab repository](https://forgemia.inra.fr/stacomi/stacomi_db/container_registry/368). Tags are given as follows: - a database version ; - a postgresql version ; -- a postgis version. +- a postgis version ; +- an optional `dev` tag. Any image with this tag is aimed to be used in a development context and **should not be used** in a production environment. This the tag `0.6.0-pg9.6-ps3.4` means that the database version is `0.6.0`, the postgresql version is `9.6` and the postgis version is `3.4`. The image is build on a [postgis docker](https://registry.hub.docker.com/r/postgis/postgis/). -Les arguments (`ARG`ou lorsque que l'on fait un build `--build-arg`) `postgresql_version` et `postgis_version` -permettent de cibler la bonne [version du docker postgis](https://hub.docker.com/r/postgis/postgis/tags). +The arguments (`ARG`or when building the image `--build-arg`) `postgresql_version` and `postgis_version` allow to use the right [version of docker postgis image](https://hub.docker.com/r/postgis/postgis/tags). ### How to use the image -- GitLab From 271965721c850d0207cbb3a5cd6d550ad20446f2 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 18:00:40 +0100 Subject: [PATCH 02/51] [gitlab-ci] split files --- .gitlab-ci.yml | 34 +++------------------------------- gitlab-ci/dev.gitlab-ci.yml | 15 +++++++++++++++ gitlab-ci/main.gitlab-ci.yml | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 gitlab-ci/dev.gitlab-ci.yml create mode 100644 gitlab-ci/main.gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 79872ee..a040daa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,38 +21,10 @@ default: - name: $CI_REGISTRY_IMAGE/$imagedb_name alias: host_db -########################### -# jobs for any development branch # -########################### - -build_db-dev: - image: docker:latest - stage: build_db - services: - - docker:dind - rules: - - if: '$CI_COMMIT_BRANCH != "main"' # only if there is changes in branch other than main -# changes: # and there is changes in Dockerfile -# - db.dockerfile - script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version-$tag_dev -f db.dockerfile . - - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name +include: + - local: '/gitlab-ci/dev.gitlab-ci.yml' # jobs for any development branch + - local: '/gitlab-ci/main.gitlab-ci.yml' # jobs for branch main only -build_db-prod: - image: docker:latest - stage: build_db - services: - - docker:dind - rules: - - if: '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch - when: manual - script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version -f db.dockerfile . - - docker tag $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version $CI_REGISTRY_IMAGE/$imagedb_name:latest - - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name - #build_env_test: # image: docker:latest # stage: build_env_test diff --git a/gitlab-ci/dev.gitlab-ci.yml b/gitlab-ci/dev.gitlab-ci.yml new file mode 100644 index 0000000..14ffeb5 --- /dev/null +++ b/gitlab-ci/dev.gitlab-ci.yml @@ -0,0 +1,15 @@ +# for any branch, but main + +build_db-dev: + image: docker:latest + stage: build_db + services: + - docker:dind + rules: + - if: '$CI_COMMIT_BRANCH != "main"' # only if there is changes in branch other than main +# changes: # and there is changes in Dockerfile +# - db.dockerfile + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version-$tag_dev -f db.dockerfile . + - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name \ No newline at end of file diff --git a/gitlab-ci/main.gitlab-ci.yml b/gitlab-ci/main.gitlab-ci.yml new file mode 100644 index 0000000..a48afee --- /dev/null +++ b/gitlab-ci/main.gitlab-ci.yml @@ -0,0 +1,15 @@ +# for main banch only + +build_db-prod: + image: docker:latest + stage: build_db + services: + - docker:dind + rules: + - if: '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch + when: manual + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version -f db.dockerfile . + - docker tag $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version $CI_REGISTRY_IMAGE/$imagedb_name:latest + - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name \ No newline at end of file -- GitLab From 894f4a5da6df87c5f22b617816b579c805174e7b Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 18:02:45 +0100 Subject: [PATCH 03/51] [gitlab-ci] test rule --- gitlab-ci/dev.gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitlab-ci/dev.gitlab-ci.yml b/gitlab-ci/dev.gitlab-ci.yml index 14ffeb5..d58d51e 100644 --- a/gitlab-ci/dev.gitlab-ci.yml +++ b/gitlab-ci/dev.gitlab-ci.yml @@ -7,8 +7,8 @@ build_db-dev: - docker:dind rules: - if: '$CI_COMMIT_BRANCH != "main"' # only if there is changes in branch other than main -# changes: # and there is changes in Dockerfile -# - db.dockerfile + changes: # and there is changes in Dockerfile + - db.dockerfile script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version-$tag_dev -f db.dockerfile . -- GitLab From 754474456336a4efda2d2fd1d7bab49d401ab1ee Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 18:08:36 +0100 Subject: [PATCH 04/51] [gitlab-ci] restructuration --- .gitlab-ci.yml | 4 +-- gitlab-ci/build_images_docker.gitlab-ci.yml | 33 +++++++++++++++++++++ gitlab-ci/dev.gitlab-ci.yml | 15 ---------- gitlab-ci/main.gitlab-ci.yml | 15 ---------- 4 files changed, 35 insertions(+), 32 deletions(-) create mode 100644 gitlab-ci/build_images_docker.gitlab-ci.yml delete mode 100644 gitlab-ci/dev.gitlab-ci.yml delete mode 100644 gitlab-ci/main.gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a040daa..9eb5692 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ stages: - - build_db + - build_db_image # - build_env_test - test_psql # - test_r @@ -22,7 +22,7 @@ default: alias: host_db include: - - local: '/gitlab-ci/dev.gitlab-ci.yml' # jobs for any development branch + - local: '/gitlab-ci/build_images_docker.gitlab-ci.yml' # building docker images - local: '/gitlab-ci/main.gitlab-ci.yml' # jobs for branch main only #build_env_test: diff --git a/gitlab-ci/build_images_docker.gitlab-ci.yml b/gitlab-ci/build_images_docker.gitlab-ci.yml new file mode 100644 index 0000000..51ec8f8 --- /dev/null +++ b/gitlab-ci/build_images_docker.gitlab-ci.yml @@ -0,0 +1,33 @@ +# build docker images + +####################### +# for any branch, but main +build_db-dev: + image: docker:latest + stage: build_db_image + services: + - docker:dind + rules: + - if: '$CI_COMMIT_BRANCH != "main"' # only if there is changes in branch other than main + changes: # and there is changes in Dockerfile + - db.dockerfile + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version-$tag_dev -f db.dockerfile . + - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name + +####################### +# for main banch only +build_db-prod: + image: docker:latest + stage: build_db_image + services: + - docker:dind + rules: + - if: '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch + when: manual + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version -f db.dockerfile . + - docker tag $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version $CI_REGISTRY_IMAGE/$imagedb_name:latest + - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name \ No newline at end of file diff --git a/gitlab-ci/dev.gitlab-ci.yml b/gitlab-ci/dev.gitlab-ci.yml deleted file mode 100644 index d58d51e..0000000 --- a/gitlab-ci/dev.gitlab-ci.yml +++ /dev/null @@ -1,15 +0,0 @@ -# for any branch, but main - -build_db-dev: - image: docker:latest - stage: build_db - services: - - docker:dind - rules: - - if: '$CI_COMMIT_BRANCH != "main"' # only if there is changes in branch other than main - changes: # and there is changes in Dockerfile - - db.dockerfile - script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version-$tag_dev -f db.dockerfile . - - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name \ No newline at end of file diff --git a/gitlab-ci/main.gitlab-ci.yml b/gitlab-ci/main.gitlab-ci.yml deleted file mode 100644 index a48afee..0000000 --- a/gitlab-ci/main.gitlab-ci.yml +++ /dev/null @@ -1,15 +0,0 @@ -# for main banch only - -build_db-prod: - image: docker:latest - stage: build_db - services: - - docker:dind - rules: - - if: '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch - when: manual - script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version -f db.dockerfile . - - docker tag $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version $CI_REGISTRY_IMAGE/$imagedb_name:latest - - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name \ No newline at end of file -- GitLab From 23bdb2d78afed790d8b3f948c6451395401f12c8 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 18:08:36 +0100 Subject: [PATCH 05/51] [gitlab-ci] restructuration --- .gitlab-ci.yml | 5 ++-- gitlab-ci/build_images_docker.gitlab-ci.yml | 33 +++++++++++++++++++++ gitlab-ci/dev.gitlab-ci.yml | 15 ---------- gitlab-ci/main.gitlab-ci.yml | 15 ---------- 4 files changed, 35 insertions(+), 33 deletions(-) create mode 100644 gitlab-ci/build_images_docker.gitlab-ci.yml delete mode 100644 gitlab-ci/dev.gitlab-ci.yml delete mode 100644 gitlab-ci/main.gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a040daa..f777563 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ stages: - - build_db + - build_db_image # - build_env_test - test_psql # - test_r @@ -22,8 +22,7 @@ default: alias: host_db include: - - local: '/gitlab-ci/dev.gitlab-ci.yml' # jobs for any development branch - - local: '/gitlab-ci/main.gitlab-ci.yml' # jobs for branch main only + - local: '/gitlab-ci/build_images_docker.gitlab-ci.yml' # building docker images #build_env_test: # image: docker:latest diff --git a/gitlab-ci/build_images_docker.gitlab-ci.yml b/gitlab-ci/build_images_docker.gitlab-ci.yml new file mode 100644 index 0000000..51ec8f8 --- /dev/null +++ b/gitlab-ci/build_images_docker.gitlab-ci.yml @@ -0,0 +1,33 @@ +# build docker images + +####################### +# for any branch, but main +build_db-dev: + image: docker:latest + stage: build_db_image + services: + - docker:dind + rules: + - if: '$CI_COMMIT_BRANCH != "main"' # only if there is changes in branch other than main + changes: # and there is changes in Dockerfile + - db.dockerfile + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version-$tag_dev -f db.dockerfile . + - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name + +####################### +# for main banch only +build_db-prod: + image: docker:latest + stage: build_db_image + services: + - docker:dind + rules: + - if: '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch + when: manual + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version -f db.dockerfile . + - docker tag $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version $CI_REGISTRY_IMAGE/$imagedb_name:latest + - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name \ No newline at end of file diff --git a/gitlab-ci/dev.gitlab-ci.yml b/gitlab-ci/dev.gitlab-ci.yml deleted file mode 100644 index d58d51e..0000000 --- a/gitlab-ci/dev.gitlab-ci.yml +++ /dev/null @@ -1,15 +0,0 @@ -# for any branch, but main - -build_db-dev: - image: docker:latest - stage: build_db - services: - - docker:dind - rules: - - if: '$CI_COMMIT_BRANCH != "main"' # only if there is changes in branch other than main - changes: # and there is changes in Dockerfile - - db.dockerfile - script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version-$tag_dev -f db.dockerfile . - - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name \ No newline at end of file diff --git a/gitlab-ci/main.gitlab-ci.yml b/gitlab-ci/main.gitlab-ci.yml deleted file mode 100644 index a48afee..0000000 --- a/gitlab-ci/main.gitlab-ci.yml +++ /dev/null @@ -1,15 +0,0 @@ -# for main banch only - -build_db-prod: - image: docker:latest - stage: build_db - services: - - docker:dind - rules: - - if: '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch - when: manual - script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version -f db.dockerfile . - - docker tag $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version $CI_REGISTRY_IMAGE/$imagedb_name:latest - - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name \ No newline at end of file -- GitLab From 97020299e43aee44d738691ec1b4857399912901 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 18:15:02 +0100 Subject: [PATCH 06/51] [gitlab-ci] restructuration --- .gitlab-ci.yml | 15 +++------------ gitlab-ci/test_psql.gitlab-ci.yml | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 gitlab-ci/test_psql.gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f777563..933fbcc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,8 @@ default: include: - local: '/gitlab-ci/build_images_docker.gitlab-ci.yml' # building docker images + - local: '/gitlab-ci/test_psql.gitlab-ci.yml' # test the db docker images is accessible from as simple tool as psql + #build_env_test: # image: docker:latest @@ -35,18 +37,7 @@ include: # - docker tag $CI_REGISTRY_IMAGE/$imager_name:$r_version $CI_REGISTRY_IMAGE/$imager_name:latest # - docker push --all-tags $CI_REGISTRY_IMAGE/$imager_name -test_psql-dev: - image: ubuntu - stage: test_psql - script: - - apt update - - apt install -y postgresql-client - - psql --version - - export PGPASSWORD=$POSTGRES_PASSWORD - - psql -U postgres -h host_db -c "SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';" - - psql -U postgres -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat - - + #test_r: # image: rocker/tidyverse # stage: test_r diff --git a/gitlab-ci/test_psql.gitlab-ci.yml b/gitlab-ci/test_psql.gitlab-ci.yml new file mode 100644 index 0000000..dad6be0 --- /dev/null +++ b/gitlab-ci/test_psql.gitlab-ci.yml @@ -0,0 +1,17 @@ +# test the db docker images is accessible from as simple tool as psql + +####################### +# for any branch, but main +test_psql-dev: + image: ubuntu + stage: test_psql + script: + - apt update + - apt install -y postgresql-client + - psql --version + - export PGPASSWORD=$POSTGRES_PASSWORD + - psql -U postgres -h host_db -c "SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';" + - psql -U postgres -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat + +####################### +# for main banch only \ No newline at end of file -- GitLab From cfa53ee28fd1f162b277bcd54c63ac202ed7b345 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 18:29:54 +0100 Subject: [PATCH 07/51] [gitlab-ci] restructuration --- gitlab-ci/test_psql.gitlab-ci.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gitlab-ci/test_psql.gitlab-ci.yml b/gitlab-ci/test_psql.gitlab-ci.yml index dad6be0..08d7194 100644 --- a/gitlab-ci/test_psql.gitlab-ci.yml +++ b/gitlab-ci/test_psql.gitlab-ci.yml @@ -1,15 +1,21 @@ # test the db docker images is accessible from as simple tool as psql ####################### -# for any branch, but main -test_psql-dev: - image: ubuntu +# template for the test +.test_psql_template: stage: test_psql - script: + image: ubuntu + before_script: - apt update - apt install -y postgresql-client - psql --version - export PGPASSWORD=$POSTGRES_PASSWORD + +####################### +# for any branch, but main +test_psql-dev: + extends: .test_psql_template + script: - psql -U postgres -h host_db -c "SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';" - psql -U postgres -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat -- GitLab From 111eafa02054218ca2d6daac4871af7c4e1dcd19 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 18:37:42 +0100 Subject: [PATCH 08/51] [gitlab-ci] restructuration --- .gitlab-ci.yml | 1 + gitlab-ci/build_images_docker.gitlab-ci.yml | 10 ++++------ gitlab-ci/generic_rules.gitlab-ci.yaml | 15 +++++++++++++++ gitlab-ci/test_psql.gitlab-ci.yml | 4 +++- 4 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 gitlab-ci/generic_rules.gitlab-ci.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 933fbcc..6db8c09 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,6 +22,7 @@ default: alias: host_db include: + - local: '/gitlab-ci/generic_rules.gitlab-ci.yaml' # generic rules to be used for main brnach or others - local: '/gitlab-ci/build_images_docker.gitlab-ci.yml' # building docker images - local: '/gitlab-ci/test_psql.gitlab-ci.yml' # test the db docker images is accessible from as simple tool as psql diff --git a/gitlab-ci/build_images_docker.gitlab-ci.yml b/gitlab-ci/build_images_docker.gitlab-ci.yml index 51ec8f8..93e2dee 100644 --- a/gitlab-ci/build_images_docker.gitlab-ci.yml +++ b/gitlab-ci/build_images_docker.gitlab-ci.yml @@ -7,10 +7,8 @@ build_db-dev: stage: build_db_image services: - docker:dind - rules: - - if: '$CI_COMMIT_BRANCH != "main"' # only if there is changes in branch other than main - changes: # and there is changes in Dockerfile - - db.dockerfile + extends: + - .rules_other script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version-$tag_dev -f db.dockerfile . @@ -23,8 +21,8 @@ build_db-prod: stage: build_db_image services: - docker:dind - rules: - - if: '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch + extends: + - .rules_main when: manual script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY diff --git a/gitlab-ci/generic_rules.gitlab-ci.yaml b/gitlab-ci/generic_rules.gitlab-ci.yaml new file mode 100644 index 0000000..ce70a34 --- /dev/null +++ b/gitlab-ci/generic_rules.gitlab-ci.yaml @@ -0,0 +1,15 @@ +# generic rules to be used for main brnach or others + +####################### +# for any branch, but main +.rules_other: + rules: + - if: '$CI_COMMIT_BRANCH != "main"' # only if there is changes in branch other than main + changes: # and there is changes in Dockerfile + - db.dockerfile + +####################### +# for main banch only +.rules_main: + rules: + - if: '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch \ No newline at end of file diff --git a/gitlab-ci/test_psql.gitlab-ci.yml b/gitlab-ci/test_psql.gitlab-ci.yml index 08d7194..0189a9d 100644 --- a/gitlab-ci/test_psql.gitlab-ci.yml +++ b/gitlab-ci/test_psql.gitlab-ci.yml @@ -14,7 +14,9 @@ ####################### # for any branch, but main test_psql-dev: - extends: .test_psql_template + extends: + - .rules_other + - .test_psql_template script: - psql -U postgres -h host_db -c "SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';" - psql -U postgres -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat -- GitLab From f4d89301d10020141a71f2b52f46e7efabe3f27f Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 18:47:17 +0100 Subject: [PATCH 09/51] [gitlab-ci] restructuration --- .gitlab-ci.yml | 8 ++------ gitlab-ci/generic_rules.gitlab-ci.yaml | 2 +- gitlab-ci/services.gitlab-ci.yml | 15 +++++++++++++++ gitlab-ci/test_psql.gitlab-ci.yml | 15 +++++++++++---- 4 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 gitlab-ci/services.gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6db8c09..7262242 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,13 +16,9 @@ variables: r_version: "0.1" POSTGRES_PASSWORD: postgres -default: - services: - - name: $CI_REGISTRY_IMAGE/$imagedb_name - alias: host_db - include: - - local: '/gitlab-ci/generic_rules.gitlab-ci.yaml' # generic rules to be used for main brnach or others + - local: '/gitlab-ci/generic_rules.gitlab-ci.yaml' # generic rules to be used for main branch or others + - local: '/gitlab-ci/services.gitlab-ci.yaml' # to use the right docker db image - local: '/gitlab-ci/build_images_docker.gitlab-ci.yml' # building docker images - local: '/gitlab-ci/test_psql.gitlab-ci.yml' # test the db docker images is accessible from as simple tool as psql diff --git a/gitlab-ci/generic_rules.gitlab-ci.yaml b/gitlab-ci/generic_rules.gitlab-ci.yaml index ce70a34..5fa8ecb 100644 --- a/gitlab-ci/generic_rules.gitlab-ci.yaml +++ b/gitlab-ci/generic_rules.gitlab-ci.yaml @@ -1,4 +1,4 @@ -# generic rules to be used for main brnach or others +# generic rules to be used for main branch or others ####################### # for any branch, but main diff --git a/gitlab-ci/services.gitlab-ci.yml b/gitlab-ci/services.gitlab-ci.yml new file mode 100644 index 0000000..4821c27 --- /dev/null +++ b/gitlab-ci/services.gitlab-ci.yml @@ -0,0 +1,15 @@ +# to use the right docker db image + +####################### +# for any branch, but main +.service-dev: + services: + - name: $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version-$tag_dev + alias: host_db + +####################### +# for main banch only +.service-prod: + services: + - name: $CI_REGISTRY_IMAGE/$imagedb_name:latest + alias: host_db \ No newline at end of file diff --git a/gitlab-ci/test_psql.gitlab-ci.yml b/gitlab-ci/test_psql.gitlab-ci.yml index 0189a9d..1dd39a0 100644 --- a/gitlab-ci/test_psql.gitlab-ci.yml +++ b/gitlab-ci/test_psql.gitlab-ci.yml @@ -10,16 +10,23 @@ - apt install -y postgresql-client - psql --version - export PGPASSWORD=$POSTGRES_PASSWORD + script: + - psql -U postgres -h host_db -c "SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';" + - psql -U postgres -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat ####################### # for any branch, but main test_psql-dev: extends: - .rules_other + - .service-dev - .test_psql_template - script: - - psql -U postgres -h host_db -c "SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';" - - psql -U postgres -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat + ####################### -# for main banch only \ No newline at end of file +# for main banch only +test_psql-prod: + extends: + - .rules_main + - .service-prod + - .test_psql_template -- GitLab From 051f0ef4495a97d5f15d71413b83a4df227812cf Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 18:48:54 +0100 Subject: [PATCH 10/51] [gitlab-ci] restructuration --- .gitlab-ci.yml | 4 ++-- ...neric_rules.gitlab-ci.yaml => generic_rules.gitlab-ci.yml} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename gitlab-ci/{generic_rules.gitlab-ci.yaml => generic_rules.gitlab-ci.yml} (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7262242..664d126 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,8 +17,8 @@ variables: POSTGRES_PASSWORD: postgres include: - - local: '/gitlab-ci/generic_rules.gitlab-ci.yaml' # generic rules to be used for main branch or others - - local: '/gitlab-ci/services.gitlab-ci.yaml' # to use the right docker db image + - local: '/gitlab-ci/generic_rules.gitlab-ci.yml' # generic rules to be used for main branch or others + - local: '/gitlab-ci/services.gitlab-ci.yml' # to use the right docker db image - local: '/gitlab-ci/build_images_docker.gitlab-ci.yml' # building docker images - local: '/gitlab-ci/test_psql.gitlab-ci.yml' # test the db docker images is accessible from as simple tool as psql diff --git a/gitlab-ci/generic_rules.gitlab-ci.yaml b/gitlab-ci/generic_rules.gitlab-ci.yml similarity index 100% rename from gitlab-ci/generic_rules.gitlab-ci.yaml rename to gitlab-ci/generic_rules.gitlab-ci.yml -- GitLab From 601b29c687426ad78505b4bc100c62b0bbc67701 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 18:50:04 +0100 Subject: [PATCH 11/51] [gitlab-ci] introduce minor change to dockerfile to see if it works --- db.dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db.dockerfile b/db.dockerfile index afa8712..a30a225 100644 --- a/db.dockerfile +++ b/db.dockerfile @@ -6,7 +6,7 @@ ENV LANG fr_FR.utf8 # script de construction de la base # attention doit commencer à 11 car il y a un 10_postgis.sh -#RUN ls /docker-entrypoint-initdb.d +RUN ls /docker-entrypoint-initdb.d COPY initdb/ /docker-entrypoint-initdb.d # insert in the first ligne the connection to the right db -- GitLab From e511ec726939db6081fef53f95047cba4a8979da Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 20:26:33 +0100 Subject: [PATCH 12/51] [gitlab-ci] restructuration --- .gitlab-ci.yml | 15 ++------------- {R => gitlab-ci/R}/test_BDD.R | 0 {R => gitlab-ci/R}/test_install.R | 0 {R => gitlab-ci/R}/test_simple.R | 0 gitlab-ci/test_r.gitlab-ci.yml | 32 +++++++++++++++++++++++++++++++ 5 files changed, 34 insertions(+), 13 deletions(-) rename {R => gitlab-ci/R}/test_BDD.R (100%) rename {R => gitlab-ci/R}/test_install.R (100%) rename {R => gitlab-ci/R}/test_simple.R (100%) create mode 100644 gitlab-ci/test_r.gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 664d126..3a01793 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,10 +18,10 @@ variables: include: - local: '/gitlab-ci/generic_rules.gitlab-ci.yml' # generic rules to be used for main branch or others - - local: '/gitlab-ci/services.gitlab-ci.yml' # to use the right docker db image + - local: '/gitlab-ci/services.gitlab-ci.yml' # to use the right docker db image - local: '/gitlab-ci/build_images_docker.gitlab-ci.yml' # building docker images - local: '/gitlab-ci/test_psql.gitlab-ci.yml' # test the db docker images is accessible from as simple tool as psql - + - local: '/gitlab-ci/test_r.gitlab-ci.yml' # test the db docker images with R script #build_env_test: # image: docker:latest @@ -34,15 +34,4 @@ include: # - docker tag $CI_REGISTRY_IMAGE/$imager_name:$r_version $CI_REGISTRY_IMAGE/$imager_name:latest # - docker push --all-tags $CI_REGISTRY_IMAGE/$imager_name - -#test_r: -# image: rocker/tidyverse -# stage: test_r -# script: -# - Rscript -e '1+1' -# - Rscript -e 'a<-1; a+1' -# - R -e '1+1' -# - Rscript 'R/test_simple.R' -## - Rscript 'R/test_install.R' -# - Rscript 'R/test_BDD.R' \ No newline at end of file diff --git a/R/test_BDD.R b/gitlab-ci/R/test_BDD.R similarity index 100% rename from R/test_BDD.R rename to gitlab-ci/R/test_BDD.R diff --git a/R/test_install.R b/gitlab-ci/R/test_install.R similarity index 100% rename from R/test_install.R rename to gitlab-ci/R/test_install.R diff --git a/R/test_simple.R b/gitlab-ci/R/test_simple.R similarity index 100% rename from R/test_simple.R rename to gitlab-ci/R/test_simple.R diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml new file mode 100644 index 0000000..01793bb --- /dev/null +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -0,0 +1,32 @@ +# test the db docker images with R script + +####################### +# template for the test +.test_r_template: + stage: test_r + image: rocker/tidyverse + script: + - Rscript -e '1+1' + - Rscript -e 'a<-1; a+1' + - R -e '1+1' + - Rscript 'gitlab-ci/R/test_simple.R' + - Rscript 'gitlab-ci/R/test_install.R' + - Rscript 'gitlab-ci/R/test_BDD.R' + +####################### +# for any branch, but main +test_r-dev: + extends: + - .rules_other + - .service-dev + - .test_r_template + + +####################### +# for main banch only +test_r-prod: + extends: + - .rules_main + - .service-prod + - .test_r_template + -- GitLab From 6b4eb50e033a2da84ec307e4843c3d56b6abc336 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 20:27:58 +0100 Subject: [PATCH 13/51] [gitlab-ci] restructuration --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3a01793..5ac0537 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: - build_db_image # - build_env_test - test_psql -# - test_r + - test_r variables: tag_dev: "dev" -- GitLab From 3f92c688bd7ab5db4f1941de9f1e9aad88eab894 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 20:37:32 +0100 Subject: [PATCH 14/51] [gitlab-ci] R improvement --- gitlab-ci/test_r.gitlab-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 01793bb..53a9862 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -8,6 +8,7 @@ script: - Rscript -e '1+1' - Rscript -e 'a<-1; a+1' + - Rscript -e 'installed.packages()' - R -e '1+1' - Rscript 'gitlab-ci/R/test_simple.R' - Rscript 'gitlab-ci/R/test_install.R' @@ -30,3 +31,9 @@ test_r-prod: - .service-prod - .test_r_template +####################### +# test each time +test_r: + extends: + - .service-prod + - .test_r_template \ No newline at end of file -- GitLab From 1f6754dfecdc8e9282ab58632b41b9d5c154b1ea Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 20:44:51 +0100 Subject: [PATCH 15/51] [gitlab-ci] use littler --- gitlab-ci/R/test_install.R | 1 - gitlab-ci/test_r.gitlab-ci.yml | 13 ++++++------- 2 files changed, 6 insertions(+), 8 deletions(-) delete mode 100644 gitlab-ci/R/test_install.R diff --git a/gitlab-ci/R/test_install.R b/gitlab-ci/R/test_install.R deleted file mode 100644 index a5de540..0000000 --- a/gitlab-ci/R/test_install.R +++ /dev/null @@ -1 +0,0 @@ -install.packages('sqldf') \ No newline at end of file diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 53a9862..42ba25b 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -6,13 +6,12 @@ stage: test_r image: rocker/tidyverse script: - - Rscript -e '1+1' - - Rscript -e 'a<-1; a+1' - - Rscript -e 'installed.packages()' - - R -e '1+1' - - Rscript 'gitlab-ci/R/test_simple.R' - - Rscript 'gitlab-ci/R/test_install.R' - - Rscript 'gitlab-ci/R/test_BDD.R' + - r -e '1+1' + - r --help + - r -e 'a<-1; a+1' + - r -e '1+1' + - r 'gitlab-ci/R/test_simple.R' + - r 'gitlab-ci/R/test_BDD.R' ####################### # for any branch, but main -- GitLab From 31f3e60b65b2d0b4af15cc432e2d944c36c4efa5 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 20:48:00 +0100 Subject: [PATCH 16/51] [gitlab-ci] use littler --- gitlab-ci/test_r.gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 42ba25b..0bbe3d6 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -7,11 +7,10 @@ image: rocker/tidyverse script: - r -e '1+1' - - r --help - r -e 'a<-1; a+1' - r -e '1+1' - r 'gitlab-ci/R/test_simple.R' - - r 'gitlab-ci/R/test_BDD.R' +# - r 'gitlab-ci/R/test_BDD.R' ####################### # for any branch, but main -- GitLab From e48d78cd5d7586a179907f83c25b8374acd29616 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 20:50:52 +0100 Subject: [PATCH 17/51] [gitlab-ci] use littler --- gitlab-ci/test_r.gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 0bbe3d6..e41282d 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -6,9 +6,10 @@ stage: test_r image: rocker/tidyverse script: - - r -e '1+1' + - r -e 'cat(1+1)' - r -e 'a<-1; a+1' - r -e '1+1' + - install.r digest - r 'gitlab-ci/R/test_simple.R' # - r 'gitlab-ci/R/test_BDD.R' -- GitLab From 30a5bb97cbbd534726d863b1972cd64ab023ebe9 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 20:54:28 +0100 Subject: [PATCH 18/51] [gitlab-ci] use littler --- gitlab-ci/test_r.gitlab-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index e41282d..a99cd06 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -6,10 +6,11 @@ stage: test_r image: rocker/tidyverse script: - - r -e 'cat(1+1)' + - r -e 'print(1+1)' - r -e 'a<-1; a+1' - - r -e '1+1' - - install.r digest + - r -e 'a<-1' + - r -e 'print(a+1)' +# - install.r digest - r 'gitlab-ci/R/test_simple.R' # - r 'gitlab-ci/R/test_BDD.R' -- GitLab From a52561b74fe2964033705d87e653b95413c15b56 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 21:15:57 +0100 Subject: [PATCH 19/51] [gitlab-ci] revert to R (instead of r) --- gitlab-ci/test_r.gitlab-ci.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index a99cd06..3c88a0a 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -6,13 +6,15 @@ stage: test_r image: rocker/tidyverse script: - - r -e 'print(1+1)' - - r -e 'a<-1; a+1' - - r -e 'a<-1' - - r -e 'print(a+1)' -# - install.r digest - - r 'gitlab-ci/R/test_simple.R' -# - r 'gitlab-ci/R/test_BDD.R' + - Rscript -e '1+1' + - Rscript -e 'a<-1; a+1' + +# the following failed because each line is a new R instance +# - Rscript -e 'a<-1' +# - Rscript -e 'a+1' + + - Rscript 'gitlab-ci/R/test_simple.R' +# - Rscript 'gitlab-ci/R/test_BDD.R' ####################### # for any branch, but main -- GitLab From ae6a3c2bcfe684f6dca0d87a3197c91aa1997add Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 21:18:49 +0100 Subject: [PATCH 20/51] [gitlab-ci] switch to r-base --- .gitlab-ci.yml | 1 + gitlab-ci/test_r.gitlab-ci.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5ac0537..7740a0f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,6 +14,7 @@ variables: postgis_version: "3.2" imager_name: "environnement_test_r" r_version: "0.1" + r_base_version: "4.1.2" POSTGRES_PASSWORD: postgres include: diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 3c88a0a..64a8757 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -4,7 +4,7 @@ # template for the test .test_r_template: stage: test_r - image: rocker/tidyverse + image: r-base:$r_base_version script: - Rscript -e '1+1' - Rscript -e 'a<-1; a+1' -- GitLab From d6ce3a68a9769e64b5f6eb03170b6822b4641084 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 21:20:33 +0100 Subject: [PATCH 21/51] [gitlab-ci] with test-BDD --- gitlab-ci/test_r.gitlab-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 64a8757..8c41b5e 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -8,13 +8,11 @@ script: - Rscript -e '1+1' - Rscript -e 'a<-1; a+1' - # the following failed because each line is a new R instance # - Rscript -e 'a<-1' # - Rscript -e 'a+1' - - Rscript 'gitlab-ci/R/test_simple.R' -# - Rscript 'gitlab-ci/R/test_BDD.R' + - Rscript 'gitlab-ci/R/test_BDD.R' ####################### # for any branch, but main -- GitLab From 6c1e98c0d0ebb416be16490dfa2f9f1c0d12d099 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 21:40:07 +0100 Subject: [PATCH 22/51] [gitalb-ci] switch to rstudio/r-base It provides a ubuntu based version. We can thus use [c2d4u ppa](https://launchpad.net/%7Ec2d4u.team/+archive/ubuntu/c2d4u4.0+) which allow the [installation of CRAN packages](https://cran.r-project.org/bin/linux/ubuntu/#get-5000-cran-packages) --- .gitlab-ci.yml | 2 +- gitlab-ci/test_r.gitlab-ci.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7740a0f..35c9ffd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,7 +14,7 @@ variables: postgis_version: "3.2" imager_name: "environnement_test_r" r_version: "0.1" - r_base_version: "4.1.2" + r_base_version: "4.1.2-focal" POSTGRES_PASSWORD: postgres include: diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 8c41b5e..d0a995c 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -4,7 +4,7 @@ # template for the test .test_r_template: stage: test_r - image: r-base:$r_base_version + image: rstudio/r-base:$r_base_version # use rstudio which provides a ubuntu based version, so that we can use https://cran.r-project.org/bin/linux/ubuntu/ to install packages script: - Rscript -e '1+1' - Rscript -e 'a<-1; a+1' @@ -12,7 +12,7 @@ # - Rscript -e 'a<-1' # - Rscript -e 'a+1' - Rscript 'gitlab-ci/R/test_simple.R' - - Rscript 'gitlab-ci/R/test_BDD.R' +# - Rscript 'gitlab-ci/R/test_BDD.R' ####################### # for any branch, but main -- GitLab From ec5fb72857e806441c4188935773b5c4263ed288 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 21:45:14 +0100 Subject: [PATCH 23/51] [gitlab-ci] try ppa --- gitlab-ci/test_r.gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index d0a995c..e00b2fd 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -5,6 +5,8 @@ .test_r_template: stage: test_r image: rstudio/r-base:$r_base_version # use rstudio which provides a ubuntu based version, so that we can use https://cran.r-project.org/bin/linux/ubuntu/ to install packages + before-script: + - add-apt-repository ppa:c2d4u.team/c2d4u4.0+ # add the ppa with CRAN packages as ubuntu packages (https://cran.r-project.org/bin/linux/ubuntu/#get-5000-cran-packages) ; to search for a package : https://launchpad.net/~c2d4u.team/+archive/ubuntu/c2d4u4.0+/+packages script: - Rscript -e '1+1' - Rscript -e 'a<-1; a+1' @@ -12,6 +14,7 @@ # - Rscript -e 'a<-1' # - Rscript -e 'a+1' - Rscript 'gitlab-ci/R/test_simple.R' + - apt install --no-install-recommends r-cran-sqldf # - Rscript 'gitlab-ci/R/test_BDD.R' ####################### -- GitLab From 12e8504cf7fc1c11ee9dba01d811d8454314cde1 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 21:46:08 +0100 Subject: [PATCH 24/51] up --- gitlab-ci/test_r.gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index e00b2fd..64fb606 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -5,7 +5,7 @@ .test_r_template: stage: test_r image: rstudio/r-base:$r_base_version # use rstudio which provides a ubuntu based version, so that we can use https://cran.r-project.org/bin/linux/ubuntu/ to install packages - before-script: + before_script: - add-apt-repository ppa:c2d4u.team/c2d4u4.0+ # add the ppa with CRAN packages as ubuntu packages (https://cran.r-project.org/bin/linux/ubuntu/#get-5000-cran-packages) ; to search for a package : https://launchpad.net/~c2d4u.team/+archive/ubuntu/c2d4u4.0+/+packages script: - Rscript -e '1+1' -- GitLab From ad49ee18725aceef873dc18bd732e8fa5dece349 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 21:53:43 +0100 Subject: [PATCH 25/51] up --- gitlab-ci/test_r.gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 64fb606..5fae8e1 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -6,6 +6,8 @@ stage: test_r image: rstudio/r-base:$r_base_version # use rstudio which provides a ubuntu based version, so that we can use https://cran.r-project.org/bin/linux/ubuntu/ to install packages before_script: + - apt update -qq # update indices + - apt install --no-install-recommends software-properties-common dirmngr # install two helper packages we need - add-apt-repository ppa:c2d4u.team/c2d4u4.0+ # add the ppa with CRAN packages as ubuntu packages (https://cran.r-project.org/bin/linux/ubuntu/#get-5000-cran-packages) ; to search for a package : https://launchpad.net/~c2d4u.team/+archive/ubuntu/c2d4u4.0+/+packages script: - Rscript -e '1+1' -- GitLab From c5fb4a6bfb3c2fb75dc942764a74480363e57ec6 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 22:00:37 +0100 Subject: [PATCH 26/51] up --- gitlab-ci/test_r.gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 5fae8e1..bc861f3 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -6,9 +6,9 @@ stage: test_r image: rstudio/r-base:$r_base_version # use rstudio which provides a ubuntu based version, so that we can use https://cran.r-project.org/bin/linux/ubuntu/ to install packages before_script: - - apt update -qq # update indices - - apt install --no-install-recommends software-properties-common dirmngr # install two helper packages we need - - add-apt-repository ppa:c2d4u.team/c2d4u4.0+ # add the ppa with CRAN packages as ubuntu packages (https://cran.r-project.org/bin/linux/ubuntu/#get-5000-cran-packages) ; to search for a package : https://launchpad.net/~c2d4u.team/+archive/ubuntu/c2d4u4.0+/+packages + - apt-get update -qq # update indices + - apt-get install -y --no-install-recommends software-properties-common dirmngr # install two helper packages we need + - add-apt-repository --yes ppa:c2d4u.team/c2d4u4.0+ # add the ppa with CRAN packages as ubuntu packages (https://cran.r-project.org/bin/linux/ubuntu/#get-5000-cran-packages) ; to search for a package : https://launchpad.net/~c2d4u.team/+archive/ubuntu/c2d4u4.0+/+packages script: - Rscript -e '1+1' - Rscript -e 'a<-1; a+1' -- GitLab From 76b50c8f6ba6726d05103885d1aefed81b024b57 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 22:02:56 +0100 Subject: [PATCH 27/51] up --- gitlab-ci/test_r.gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index bc861f3..edfb01a 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -8,7 +8,7 @@ before_script: - apt-get update -qq # update indices - apt-get install -y --no-install-recommends software-properties-common dirmngr # install two helper packages we need - - add-apt-repository --yes ppa:c2d4u.team/c2d4u4.0+ # add the ppa with CRAN packages as ubuntu packages (https://cran.r-project.org/bin/linux/ubuntu/#get-5000-cran-packages) ; to search for a package : https://launchpad.net/~c2d4u.team/+archive/ubuntu/c2d4u4.0+/+packages + - add-apt-repository --yes ppa:c2d4u.team/c2d4u4.0+ && apt-get update -qq # add the ppa with CRAN packages as ubuntu packages (https://cran.r-project.org/bin/linux/ubuntu/#get-5000-cran-packages) ; to search for a package : https://launchpad.net/~c2d4u.team/+archive/ubuntu/c2d4u4.0+/+packages script: - Rscript -e '1+1' - Rscript -e 'a<-1; a+1' @@ -16,7 +16,7 @@ # - Rscript -e 'a<-1' # - Rscript -e 'a+1' - Rscript 'gitlab-ci/R/test_simple.R' - - apt install --no-install-recommends r-cran-sqldf + - apt-get install --no-install-recommends r-cran-sqldf # - Rscript 'gitlab-ci/R/test_BDD.R' ####################### -- GitLab From 71210e6bdc729c442ecce07d882fad5dd7ca815a Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 22:05:50 +0100 Subject: [PATCH 28/51] up --- gitlab-ci/test_r.gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index edfb01a..45f995a 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -16,7 +16,7 @@ # - Rscript -e 'a<-1' # - Rscript -e 'a+1' - Rscript 'gitlab-ci/R/test_simple.R' - - apt-get install --no-install-recommends r-cran-sqldf + - apt-get install r-cran-sqldf # - Rscript 'gitlab-ci/R/test_BDD.R' ####################### -- GitLab From 62dcc4cd279d5b2b9e61e8ca27e7b32d54a46291 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 22:07:52 +0100 Subject: [PATCH 29/51] up --- gitlab-ci/test_r.gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 45f995a..da9248f 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -16,7 +16,7 @@ # - Rscript -e 'a<-1' # - Rscript -e 'a+1' - Rscript 'gitlab-ci/R/test_simple.R' - - apt-get install r-cran-sqldf + - apt-get install r-cran-rsqlite # - Rscript 'gitlab-ci/R/test_BDD.R' ####################### -- GitLab From 96bda0df28fd8c06caaf34e94cd1ef4d22cade67 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 22:32:06 +0100 Subject: [PATCH 30/51] up --- gitlab-ci/test_r.gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index da9248f..807dd09 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -8,6 +8,7 @@ before_script: - apt-get update -qq # update indices - apt-get install -y --no-install-recommends software-properties-common dirmngr # install two helper packages we need + - wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc && add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" - add-apt-repository --yes ppa:c2d4u.team/c2d4u4.0+ && apt-get update -qq # add the ppa with CRAN packages as ubuntu packages (https://cran.r-project.org/bin/linux/ubuntu/#get-5000-cran-packages) ; to search for a package : https://launchpad.net/~c2d4u.team/+archive/ubuntu/c2d4u4.0+/+packages script: - Rscript -e '1+1' @@ -16,7 +17,7 @@ # - Rscript -e 'a<-1' # - Rscript -e 'a+1' - Rscript 'gitlab-ci/R/test_simple.R' - - apt-get install r-cran-rsqlite + - apt-get install -y r-cran-sqldf # - Rscript 'gitlab-ci/R/test_BDD.R' ####################### -- GitLab From 99d97a024484885955c9b30cc9adeb6d9112b67a Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 22:36:36 +0100 Subject: [PATCH 31/51] up --- gitlab-ci/R/test_BDD.R | 30 +++++++++++++++--------------- gitlab-ci/test_r.gitlab-ci.yml | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/gitlab-ci/R/test_BDD.R b/gitlab-ci/R/test_BDD.R index 485233b..0ede5a9 100644 --- a/gitlab-ci/R/test_BDD.R +++ b/gitlab-ci/R/test_BDD.R @@ -1,18 +1,18 @@ -cat("###################") -cat("début") -cat("###################") - -install.packages("RPostgreSQL") - -cat("###################") -cat("Rpostgresql ok") -cat("###################") - -install.packages("sqldf") - -cat("###################") -cat("sqldf ok") -cat("###################") +#cat("###################") +#cat("début") +#cat("###################") +# +#install.packages("RPostgreSQL") +# +#cat("###################") +#cat("Rpostgresql ok") +#cat("###################") +# +#install.packages("sqldf") +# +#cat("###################") +#cat("sqldf ok") +#cat("###################") require("RPostgreSQL") require("sqldf") diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 807dd09..96cb769 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -17,8 +17,8 @@ # - Rscript -e 'a<-1' # - Rscript -e 'a+1' - Rscript 'gitlab-ci/R/test_simple.R' - - apt-get install -y r-cran-sqldf -# - Rscript 'gitlab-ci/R/test_BDD.R' + - apt-get install -y r-cran-sqldf r-cran-rpostgresql # for using sqldf ... in the next line + - Rscript 'gitlab-ci/R/test_BDD.R' ####################### # for any branch, but main -- GitLab From 2af130ab32e059d8087d576635ac93751d0618ca Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 22:41:12 +0100 Subject: [PATCH 32/51] up --- gitlab-ci/R/test_BDD.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gitlab-ci/R/test_BDD.R b/gitlab-ci/R/test_BDD.R index 0ede5a9..9bb0637 100644 --- a/gitlab-ci/R/test_BDD.R +++ b/gitlab-ci/R/test_BDD.R @@ -25,7 +25,10 @@ options(sqldf.RPostgreSQL.user = "iav", cat("###################") cat("Requête") -cat("###################") +cat("###################\n") + +version = sqldf("SELECT version();") +print(version) a = sqldf("SELECT * FROM iav.t_dispositifcomptage_dic") -- GitLab From 6ced973aeb0ef87d4b424a7d5dbd9eb75cd60d59 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 22:47:22 +0100 Subject: [PATCH 33/51] up --- gitlab-ci/R/test_BDD.R | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/gitlab-ci/R/test_BDD.R b/gitlab-ci/R/test_BDD.R index 9bb0637..5d93f82 100644 --- a/gitlab-ci/R/test_BDD.R +++ b/gitlab-ci/R/test_BDD.R @@ -1,19 +1,3 @@ -#cat("###################") -#cat("début") -#cat("###################") -# -#install.packages("RPostgreSQL") -# -#cat("###################") -#cat("Rpostgresql ok") -#cat("###################") -# -#install.packages("sqldf") -# -#cat("###################") -#cat("sqldf ok") -#cat("###################") - require("RPostgreSQL") require("sqldf") @@ -24,12 +8,22 @@ options(sqldf.RPostgreSQL.user = "iav", sqldf.RPostgreSQL.port = 5432) cat("###################") -cat("Requête") +cat("Requêtes") cat("###################\n") version = sqldf("SELECT version();") print(version) -a = sqldf("SELECT * FROM iav.t_dispositifcomptage_dic") +cat("###################") +cat("liste schemas") +cat("###################\n") + +schemas = sqldf("SELECT nspname FROM pg_catalog.pg_namespace;") +print(schemas) + +cat("###################") +cat("liste dic") +cat("###################\n") -a +dic = sqldf("SELECT * FROM iav.t_dispositifcomptage_dic") +print(dic) -- GitLab From 99bd64b0e8b547bcc8dbb9450ebabce7669a3a56 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 22:52:23 +0100 Subject: [PATCH 34/51] UP --- gitlab-ci/R/test_BDD.R | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/gitlab-ci/R/test_BDD.R b/gitlab-ci/R/test_BDD.R index 5d93f82..5f4f141 100644 --- a/gitlab-ci/R/test_BDD.R +++ b/gitlab-ci/R/test_BDD.R @@ -15,15 +15,26 @@ version = sqldf("SELECT version();") print(version) cat("###################") -cat("liste schemas") +cat("list schemas") cat("###################\n") schemas = sqldf("SELECT nspname FROM pg_catalog.pg_namespace;") print(schemas) cat("###################") -cat("liste dic") +cat("list tables in iav ") cat("###################\n") -dic = sqldf("SELECT * FROM iav.t_dispositifcomptage_dic") +tables = sqldf("SELECT table_schema, table_name +FROM information_schema.tables +ORDER BY table_schema, table_name +WHERE table_schema = 'IAV' +;") +print(tables) + +cat("###################") +cat("list dic") +cat("###################\n") + +dic = sqldf("SELECT * FROM iav.t_dispositifcomptage_dic;") print(dic) -- GitLab From b268e1f41b1131faf791f96834628ab0ec7fad2b Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 22:59:47 +0100 Subject: [PATCH 35/51] UP --- gitlab-ci/R/test_BDD.R | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gitlab-ci/R/test_BDD.R b/gitlab-ci/R/test_BDD.R index 5f4f141..4d7ea44 100644 --- a/gitlab-ci/R/test_BDD.R +++ b/gitlab-ci/R/test_BDD.R @@ -25,11 +25,7 @@ cat("###################") cat("list tables in iav ") cat("###################\n") -tables = sqldf("SELECT table_schema, table_name -FROM information_schema.tables -ORDER BY table_schema, table_name -WHERE table_schema = 'IAV' -;") +tables = sqldf("SELECT table_schema, table_name FROM information_schema.tables ORDER BY table_schema, table_name WHERE table_schema = 'iav' ;") print(tables) cat("###################") -- GitLab From 40f35aa01e156e9433de956354a4ed7423a3c424 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 23:26:12 +0100 Subject: [PATCH 36/51] up --- gitlab-ci/R/test_BDD.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitlab-ci/R/test_BDD.R b/gitlab-ci/R/test_BDD.R index 4d7ea44..f470485 100644 --- a/gitlab-ci/R/test_BDD.R +++ b/gitlab-ci/R/test_BDD.R @@ -1,8 +1,8 @@ require("RPostgreSQL") require("sqldf") -options(sqldf.RPostgreSQL.user = "iav", - sqldf.RPostgreSQL.password = "iav", +options(sqldf.RPostgreSQL.user = "postgres", + sqldf.RPostgreSQL.password = "postgres", sqldf.RPostgreSQL.dbname = "bd_contmig_nat", sqldf.RPostgreSQL.host = "host_db", sqldf.RPostgreSQL.port = 5432) @@ -25,7 +25,7 @@ cat("###################") cat("list tables in iav ") cat("###################\n") -tables = sqldf("SELECT table_schema, table_name FROM information_schema.tables ORDER BY table_schema, table_name WHERE table_schema = 'iav' ;") +tables = sqldf("SELECT table_schema, table_name FROM information_schema.tables WHERE table_schema = 'iav' ORDER BY table_schema, table_name ;") print(tables) cat("###################") -- GitLab From 5f5f6c4ce16b4a1d9f3b0806b951f575636f3da5 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 23:43:31 +0100 Subject: [PATCH 37/51] [gitlab-ci] force la version 9.6 de postgresql Il semble qu'il y ait un pb de droits (personne autre que postgres n'a de droits) sur la version 14 de posgtresql --- gitlab-ci/R/test_BDD.R | 6 +++--- gitlab-ci/test_r.gitlab-ci.yml | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/gitlab-ci/R/test_BDD.R b/gitlab-ci/R/test_BDD.R index f470485..f9f744b 100644 --- a/gitlab-ci/R/test_BDD.R +++ b/gitlab-ci/R/test_BDD.R @@ -1,14 +1,14 @@ require("RPostgreSQL") require("sqldf") -options(sqldf.RPostgreSQL.user = "postgres", - sqldf.RPostgreSQL.password = "postgres", +options(sqldf.RPostgreSQL.user = "iav", + sqldf.RPostgreSQL.password = "iav", sqldf.RPostgreSQL.dbname = "bd_contmig_nat", sqldf.RPostgreSQL.host = "host_db", sqldf.RPostgreSQL.port = 5432) cat("###################") -cat("Requêtes") +cat("Version postgresql") cat("###################\n") version = sqldf("SELECT version();") diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 96cb769..f207441 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -41,5 +41,7 @@ test_r-prod: # test each time test_r: extends: - - .service-prod - - .test_r_template \ No newline at end of file + - .test_r_template + services: + - name: $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$9.6-ps$postgis_version + alias: host_db \ No newline at end of file -- GitLab From 43ca4768ada8d88e3c1ad12977639c155f079ba7 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 23:44:39 +0100 Subject: [PATCH 38/51] oh l'erreur grotesque --- gitlab-ci/test_r.gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index f207441..69a2a6f 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -43,5 +43,5 @@ test_r: extends: - .test_r_template services: - - name: $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$9.6-ps$postgis_version + - name: $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg9.6-ps$postgis_version alias: host_db \ No newline at end of file -- GitLab From e1512f5e4d1f04955c67cf4d277adb0bb8a6ce6d Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Sun, 30 Jan 2022 23:49:22 +0100 Subject: [PATCH 39/51] =?UTF-8?q?[gitlab-ci]=20mise=20en=20=C3=A9vidence?= =?UTF-8?q?=20pb=20droits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gitlab-ci/test_psql.gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gitlab-ci/test_psql.gitlab-ci.yml b/gitlab-ci/test_psql.gitlab-ci.yml index 1dd39a0..8c429da 100644 --- a/gitlab-ci/test_psql.gitlab-ci.yml +++ b/gitlab-ci/test_psql.gitlab-ci.yml @@ -13,12 +13,13 @@ script: - psql -U postgres -h host_db -c "SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';" - psql -U postgres -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat + - export PGPASSWORD=iav psql -U iav -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat ####################### # for any branch, but main test_psql-dev: extends: - - .rules_other +# - .rules_other - .service-dev - .test_psql_template -- GitLab From 83337d5f4ef993e5f69a5a24b7c39951ccc9aad8 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Mon, 31 Jan 2022 00:00:05 +0100 Subject: [PATCH 40/51] =?UTF-8?q?[gitlab-ci]=20mise=20en=20=C3=A9vidence?= =?UTF-8?q?=20pb=20droits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gitlab-ci/test_psql.gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitlab-ci/test_psql.gitlab-ci.yml b/gitlab-ci/test_psql.gitlab-ci.yml index 8c429da..7b9cbe5 100644 --- a/gitlab-ci/test_psql.gitlab-ci.yml +++ b/gitlab-ci/test_psql.gitlab-ci.yml @@ -6,8 +6,8 @@ stage: test_psql image: ubuntu before_script: - - apt update - - apt install -y postgresql-client + - apt-get update + - apt-get install -y postgresql-client - psql --version - export PGPASSWORD=$POSTGRES_PASSWORD script: -- GitLab From e7d599bb7932f76b587241b3b641f1af9bd0b755 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Mon, 31 Jan 2022 00:02:07 +0100 Subject: [PATCH 41/51] =?UTF-8?q?[gitlab-ci]=20mise=20en=20=C3=A9vidence?= =?UTF-8?q?=20pb=20droits?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gitlab-ci/test_psql.gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitlab-ci/test_psql.gitlab-ci.yml b/gitlab-ci/test_psql.gitlab-ci.yml index 7b9cbe5..e074e6c 100644 --- a/gitlab-ci/test_psql.gitlab-ci.yml +++ b/gitlab-ci/test_psql.gitlab-ci.yml @@ -13,7 +13,7 @@ script: - psql -U postgres -h host_db -c "SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';" - psql -U postgres -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat - - export PGPASSWORD=iav psql -U iav -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat + - export PGPASSWORD=iav && psql -U iav -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat ####################### # for any branch, but main -- GitLab From fcd623e19fdede5d78c85e2745c2d96da714cdf9 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Mon, 31 Jan 2022 00:11:20 +0100 Subject: [PATCH 42/51] [gitlab-ci] --- gitlab-ci/R/test_BDD.R | 4 ++-- gitlab-ci/test_psql.gitlab-ci.yml | 4 ++-- gitlab-ci/test_r.gitlab-ci.yml | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/gitlab-ci/R/test_BDD.R b/gitlab-ci/R/test_BDD.R index f9f744b..b47c15d 100644 --- a/gitlab-ci/R/test_BDD.R +++ b/gitlab-ci/R/test_BDD.R @@ -1,8 +1,8 @@ require("RPostgreSQL") require("sqldf") -options(sqldf.RPostgreSQL.user = "iav", - sqldf.RPostgreSQL.password = "iav", +options(sqldf.RPostgreSQL.user = "postgres", + sqldf.RPostgreSQL.password = "postgres", sqldf.RPostgreSQL.dbname = "bd_contmig_nat", sqldf.RPostgreSQL.host = "host_db", sqldf.RPostgreSQL.port = 5432) diff --git a/gitlab-ci/test_psql.gitlab-ci.yml b/gitlab-ci/test_psql.gitlab-ci.yml index e074e6c..47096cb 100644 --- a/gitlab-ci/test_psql.gitlab-ci.yml +++ b/gitlab-ci/test_psql.gitlab-ci.yml @@ -13,13 +13,13 @@ script: - psql -U postgres -h host_db -c "SELECT * FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';" - psql -U postgres -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat - - export PGPASSWORD=iav && psql -U iav -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat + - export PGPASSWORD=iav && psql -U iav -h host_db -c "select * from iav.t_dispositifcomptage_dic" bd_contmig_nat # test avec l'utilisateur iav pour vérfier les droits ####################### # for any branch, but main test_psql-dev: extends: -# - .rules_other + - .rules_other - .service-dev - .test_psql_template diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 69a2a6f..f10a844 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -38,10 +38,8 @@ test_r-prod: - .test_r_template ####################### -# test each time +# test sur la version 9.6 test_r: extends: - .test_r_template - services: - - name: $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg9.6-ps$postgis_version - alias: host_db \ No newline at end of file + - .service-prod \ No newline at end of file -- GitLab From 66fa6abada60ce99e61e88d98989486cad59d387 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Mon, 31 Jan 2022 00:48:04 +0100 Subject: [PATCH 43/51] [gitlab-ci] premier essai R image --- .gitlab-ci.yml | 6 ++- R.dockerfile | 36 ++++++++++++++++ gitlab-ci/build_images_docker.gitlab-ci.yml | 47 ++++++++++++++++++--- gitlab-ci/generic_rules.gitlab-ci.yml | 1 + gitlab-ci/test_r.gitlab-ci.yml | 4 +- 5 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 R.dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 35c9ffd..9068071 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ stages: - - build_db_image + - build_images # - build_env_test - test_psql - test_r @@ -14,7 +14,9 @@ variables: postgis_version: "3.2" imager_name: "environnement_test_r" r_version: "0.1" - r_base_version: "4.1.2-focal" + imageR_name: "R4stacomi" + r_base_version: "4.x" + docker_version: "20.10" POSTGRES_PASSWORD: postgres include: diff --git a/R.dockerfile b/R.dockerfile new file mode 100644 index 0000000..0b5f5b5 --- /dev/null +++ b/R.dockerfile @@ -0,0 +1,36 @@ +ARG ubuntu_version=20.04 + +FROM ubuntu:${ubuntu_version} + +ENV DEBIAN_FRONTEND=noninteractive + +RUN (apt-get update && apt-get upgrade -y -q && apt-get -y -q autoclean && apt-get -y -q autoremove) + +# base d'utilitaires commun (pour mutualisation avec d'autres dockers) +RUN apt-get update && apt-get install -y -q vim apt-utils \ + sudo wget unzip \ + # pour envsubst + gettext-base \ + # pour pouvoir lancer les services avec systemctl depuis un docker (https://packages.debian.org/bullseye/systemctl) + systemctl \ + && rm -rf /var/lib/apt/lists/* + +# installation des dépendances +RUN apt-get update && apt-get install -y -q -y --no-install-recommends \ + software-properties-common dirmngr \ + && rm -rf /var/lib/apt/lists/* + +# https://cran.r-project.org/bin/linux/ubuntu/ +RUN wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | \ + sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc \ + && add-apt-repository --yes "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/" && apt-get update -qq \ + && apt-get install -y -q --no-install-recommends r-base \ + && add-apt-repository --yes ppa:c2d4u.team/c2d4u4.0+ && apt-get update -qq \ + && rm -rf /var/lib/apt/lists/* + +# our required R packages +RUN apt-get update -qq && apt-get install -y -q -y --no-install-recommends \ + r-cran-sqldf r-cran-rpostgresql \ + && rm -rf /var/lib/apt/lists/* + +CMD ["R"] \ No newline at end of file diff --git a/gitlab-ci/build_images_docker.gitlab-ci.yml b/gitlab-ci/build_images_docker.gitlab-ci.yml index 93e2dee..a977efe 100644 --- a/gitlab-ci/build_images_docker.gitlab-ci.yml +++ b/gitlab-ci/build_images_docker.gitlab-ci.yml @@ -1,12 +1,15 @@ # build docker images +####################### +# DB + ####################### # for any branch, but main build_db-dev: - image: docker:latest - stage: build_db_image + image: docker:$docker_version + stage: build_images services: - - docker:dind + - docker:$docker_version-dind extends: - .rules_other script: @@ -18,7 +21,7 @@ build_db-dev: # for main banch only build_db-prod: image: docker:latest - stage: build_db_image + stage: build_images services: - docker:dind extends: @@ -28,4 +31,38 @@ build_db-prod: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version -f db.dockerfile . - docker tag $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version $CI_REGISTRY_IMAGE/$imagedb_name:latest - - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name \ No newline at end of file + - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name + + ####################### +# R for stacomi + +####################### +# for any branch, but main +build_R-dev: + image: docker:$docker_version + stage: build_images + services: + - docker:$docker_version-dind + extends: + - .rules_other + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build -t $CI_REGISTRY_IMAGE/$imageR_name:$r_base_version-$tag_dev -f R.dockerfile . + - docker push --all-tags $CI_REGISTRY_IMAGE/$imageR_name + +####################### +# for main banch only +build_R-prod: + image: docker:latest + stage: build_images + services: + - docker:dind + extends: + - .rules_main + when: manual + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build -t $CI_REGISTRY_IMAGE/$imageR_name:$r_base_version -f R.dockerfile . + - docker tag $CI_REGISTRY_IMAGE/$imageR_name:$r_base_version $CI_REGISTRY_IMAGE/$imageR_name:latest + - docker push --all-tags $CI_REGISTRY_IMAGE/$imageR_name + \ No newline at end of file diff --git a/gitlab-ci/generic_rules.gitlab-ci.yml b/gitlab-ci/generic_rules.gitlab-ci.yml index 5fa8ecb..d341aa5 100644 --- a/gitlab-ci/generic_rules.gitlab-ci.yml +++ b/gitlab-ci/generic_rules.gitlab-ci.yml @@ -7,6 +7,7 @@ - if: '$CI_COMMIT_BRANCH != "main"' # only if there is changes in branch other than main changes: # and there is changes in Dockerfile - db.dockerfile + - R.dockerfile ####################### # for main banch only diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index f10a844..0647d34 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -4,7 +4,6 @@ # template for the test .test_r_template: stage: test_r - image: rstudio/r-base:$r_base_version # use rstudio which provides a ubuntu based version, so that we can use https://cran.r-project.org/bin/linux/ubuntu/ to install packages before_script: - apt-get update -qq # update indices - apt-get install -y --no-install-recommends software-properties-common dirmngr # install two helper packages we need @@ -23,6 +22,7 @@ ####################### # for any branch, but main test_r-dev: + image: $CI_REGISTRY_IMAGE/$imageR_name:$r_base_version-$tag_dev extends: - .rules_other - .service-dev @@ -32,6 +32,7 @@ test_r-dev: ####################### # for main banch only test_r-prod: + image: $CI_REGISTRY_IMAGE/$imageR_name:latest extends: - .rules_main - .service-prod @@ -40,6 +41,7 @@ test_r-prod: ####################### # test sur la version 9.6 test_r: + image: $CI_REGISTRY_IMAGE/$imageR_name:$r_base_version-$tag_dev extends: - .test_r_template - .service-prod \ No newline at end of file -- GitLab From f7ef487c36c4cc7ade1fa9a45af12b712a5b0f1d Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Mon, 31 Jan 2022 00:50:22 +0100 Subject: [PATCH 44/51] up --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9068071..821b78c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,7 +14,7 @@ variables: postgis_version: "3.2" imager_name: "environnement_test_r" r_version: "0.1" - imageR_name: "R4stacomi" + imageR_name: "r4stacomi" r_base_version: "4.x" docker_version: "20.10" POSTGRES_PASSWORD: postgres -- GitLab From a6b8c10352f8e7f04d9613c9e2c551ad4417aa8f Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Mon, 31 Jan 2022 00:51:47 +0100 Subject: [PATCH 45/51] up --- gitlab-ci/build_images_docker.gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitlab-ci/build_images_docker.gitlab-ci.yml b/gitlab-ci/build_images_docker.gitlab-ci.yml index a977efe..b52e3be 100644 --- a/gitlab-ci/build_images_docker.gitlab-ci.yml +++ b/gitlab-ci/build_images_docker.gitlab-ci.yml @@ -43,8 +43,8 @@ build_R-dev: stage: build_images services: - docker:$docker_version-dind - extends: - - .rules_other +# extends: +# - .rules_other script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker build -t $CI_REGISTRY_IMAGE/$imageR_name:$r_base_version-$tag_dev -f R.dockerfile . -- GitLab From 483a87ebf518f514bfe71a890e45032bca2c8329 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Mon, 31 Jan 2022 00:58:55 +0100 Subject: [PATCH 46/51] [gitlab-ci] prdcution de r4stacomi latest --- gitlab-ci/build_images_docker.gitlab-ci.yml | 10 +++++----- gitlab-ci/test_r.gitlab-ci.yml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gitlab-ci/build_images_docker.gitlab-ci.yml b/gitlab-ci/build_images_docker.gitlab-ci.yml index b52e3be..d37054a 100644 --- a/gitlab-ci/build_images_docker.gitlab-ci.yml +++ b/gitlab-ci/build_images_docker.gitlab-ci.yml @@ -43,8 +43,8 @@ build_R-dev: stage: build_images services: - docker:$docker_version-dind -# extends: -# - .rules_other + extends: + - .rules_other script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker build -t $CI_REGISTRY_IMAGE/$imageR_name:$r_base_version-$tag_dev -f R.dockerfile . @@ -57,11 +57,11 @@ build_R-prod: stage: build_images services: - docker:dind - extends: - - .rules_main +# extends: +# - .rules_main when: manual script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin - docker build -t $CI_REGISTRY_IMAGE/$imageR_name:$r_base_version -f R.dockerfile . - docker tag $CI_REGISTRY_IMAGE/$imageR_name:$r_base_version $CI_REGISTRY_IMAGE/$imageR_name:latest - docker push --all-tags $CI_REGISTRY_IMAGE/$imageR_name diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 0647d34..68516c4 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -34,7 +34,7 @@ test_r-dev: test_r-prod: image: $CI_REGISTRY_IMAGE/$imageR_name:latest extends: - - .rules_main +# - .rules_main - .service-prod - .test_r_template -- GitLab From 5f3ea83c5efb5ad6e94d5e3d35f4cc200730651b Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Mon, 31 Jan 2022 01:06:01 +0100 Subject: [PATCH 47/51] [gitlab-ci] test en dev --- db.dockerfile | 2 +- gitlab-ci/build_images_docker.gitlab-ci.yml | 4 ++-- gitlab-ci/test_r.gitlab-ci.yml | 10 +--------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/db.dockerfile b/db.dockerfile index a30a225..afa8712 100644 --- a/db.dockerfile +++ b/db.dockerfile @@ -6,7 +6,7 @@ ENV LANG fr_FR.utf8 # script de construction de la base # attention doit commencer à 11 car il y a un 10_postgis.sh -RUN ls /docker-entrypoint-initdb.d +#RUN ls /docker-entrypoint-initdb.d COPY initdb/ /docker-entrypoint-initdb.d # insert in the first ligne the connection to the right db diff --git a/gitlab-ci/build_images_docker.gitlab-ci.yml b/gitlab-ci/build_images_docker.gitlab-ci.yml index d37054a..4405d0f 100644 --- a/gitlab-ci/build_images_docker.gitlab-ci.yml +++ b/gitlab-ci/build_images_docker.gitlab-ci.yml @@ -57,8 +57,8 @@ build_R-prod: stage: build_images services: - docker:dind -# extends: -# - .rules_main + extends: + - .rules_main when: manual script: - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index 68516c4..dfe7e4a 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -34,14 +34,6 @@ test_r-dev: test_r-prod: image: $CI_REGISTRY_IMAGE/$imageR_name:latest extends: -# - .rules_main + - .rules_main - .service-prod - .test_r_template - -####################### -# test sur la version 9.6 -test_r: - image: $CI_REGISTRY_IMAGE/$imageR_name:$r_base_version-$tag_dev - extends: - - .test_r_template - - .service-prod \ No newline at end of file -- GitLab From cb7dee924a406829d067aaebf1197b3d57d1d282 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Mon, 31 Jan 2022 01:10:26 +0100 Subject: [PATCH 48/51] [gitlab-ci] simule livraison sur main --- .gitlab-ci.yml | 5 ++--- .../{generic_rules.gitlab-ci.yml => rules.gitlab-ci.yml} | 2 +- gitlab-ci/test_psql.gitlab-ci.yml | 2 +- gitlab-ci/test_r.gitlab-ci.yml | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) rename gitlab-ci/{generic_rules.gitlab-ci.yml => rules.gitlab-ci.yml} (81%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 821b78c..be42fe0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,8 +3,7 @@ stages: - build_images # - build_env_test - - test_psql - - test_r + - test variables: tag_dev: "dev" @@ -20,7 +19,7 @@ variables: POSTGRES_PASSWORD: postgres include: - - local: '/gitlab-ci/generic_rules.gitlab-ci.yml' # generic rules to be used for main branch or others + - local: '/gitlab-ci/rules.gitlab-ci.yml' # generic rules to be used for main branch or others - local: '/gitlab-ci/services.gitlab-ci.yml' # to use the right docker db image - local: '/gitlab-ci/build_images_docker.gitlab-ci.yml' # building docker images - local: '/gitlab-ci/test_psql.gitlab-ci.yml' # test the db docker images is accessible from as simple tool as psql diff --git a/gitlab-ci/generic_rules.gitlab-ci.yml b/gitlab-ci/rules.gitlab-ci.yml similarity index 81% rename from gitlab-ci/generic_rules.gitlab-ci.yml rename to gitlab-ci/rules.gitlab-ci.yml index d341aa5..0e8ec94 100644 --- a/gitlab-ci/generic_rules.gitlab-ci.yml +++ b/gitlab-ci/rules.gitlab-ci.yml @@ -13,4 +13,4 @@ # for main banch only .rules_main: rules: - - if: '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch \ No newline at end of file + - if: true # '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch \ No newline at end of file diff --git a/gitlab-ci/test_psql.gitlab-ci.yml b/gitlab-ci/test_psql.gitlab-ci.yml index 47096cb..22e98c0 100644 --- a/gitlab-ci/test_psql.gitlab-ci.yml +++ b/gitlab-ci/test_psql.gitlab-ci.yml @@ -3,7 +3,7 @@ ####################### # template for the test .test_psql_template: - stage: test_psql + stage: test image: ubuntu before_script: - apt-get update diff --git a/gitlab-ci/test_r.gitlab-ci.yml b/gitlab-ci/test_r.gitlab-ci.yml index dfe7e4a..d04bd0d 100644 --- a/gitlab-ci/test_r.gitlab-ci.yml +++ b/gitlab-ci/test_r.gitlab-ci.yml @@ -3,7 +3,7 @@ ####################### # template for the test .test_r_template: - stage: test_r + stage: test before_script: - apt-get update -qq # update indices - apt-get install -y --no-install-recommends software-properties-common dirmngr # install two helper packages we need -- GitLab From 219bbd126ed37a5953b0784891b57f87728ece2a Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Mon, 31 Jan 2022 01:14:27 +0100 Subject: [PATCH 49/51] up --- gitlab-ci/rules.gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gitlab-ci/rules.gitlab-ci.yml b/gitlab-ci/rules.gitlab-ci.yml index 0e8ec94..aeabf7f 100644 --- a/gitlab-ci/rules.gitlab-ci.yml +++ b/gitlab-ci/rules.gitlab-ci.yml @@ -13,4 +13,6 @@ # for main banch only .rules_main: rules: - - if: true # '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch \ No newline at end of file + - exists: + - db.dockerfile + - if: '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch \ No newline at end of file -- GitLab From ca19b50bff05e8e7e471822bc7347b66e096a905 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Mon, 31 Jan 2022 01:20:17 +0100 Subject: [PATCH 50/51] [gitlan-ci] simule dev --- gitlab-ci/build_images_docker.gitlab-ci.yml | 6 +++--- gitlab-ci/rules.gitlab-ci.yml | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/gitlab-ci/build_images_docker.gitlab-ci.yml b/gitlab-ci/build_images_docker.gitlab-ci.yml index 4405d0f..44e549e 100644 --- a/gitlab-ci/build_images_docker.gitlab-ci.yml +++ b/gitlab-ci/build_images_docker.gitlab-ci.yml @@ -13,7 +13,7 @@ build_db-dev: extends: - .rules_other script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version-$tag_dev -f db.dockerfile . - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name @@ -28,7 +28,7 @@ build_db-prod: - .rules_main when: manual script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin - docker build --build-arg postgresql_version=$postgres_version --build-arg postgis_version=$postgis_version -t $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version -f db.dockerfile . - docker tag $CI_REGISTRY_IMAGE/$imagedb_name:$db_version-pg$postgres_version-ps$postgis_version $CI_REGISTRY_IMAGE/$imagedb_name:latest - docker push --all-tags $CI_REGISTRY_IMAGE/$imagedb_name @@ -46,7 +46,7 @@ build_R-dev: extends: - .rules_other script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin - docker build -t $CI_REGISTRY_IMAGE/$imageR_name:$r_base_version-$tag_dev -f R.dockerfile . - docker push --all-tags $CI_REGISTRY_IMAGE/$imageR_name diff --git a/gitlab-ci/rules.gitlab-ci.yml b/gitlab-ci/rules.gitlab-ci.yml index aeabf7f..c18e283 100644 --- a/gitlab-ci/rules.gitlab-ci.yml +++ b/gitlab-ci/rules.gitlab-ci.yml @@ -5,14 +5,12 @@ .rules_other: rules: - if: '$CI_COMMIT_BRANCH != "main"' # only if there is changes in branch other than main - changes: # and there is changes in Dockerfile - - db.dockerfile - - R.dockerfile +# changes: # and there is changes in Dockerfile +# - db.dockerfile +# - R.dockerfile ####################### # for main banch only .rules_main: rules: - - exists: - - db.dockerfile - if: '$CI_COMMIT_BRANCH == "main"' # only if there is changes in the main branch \ No newline at end of file -- GitLab From 98c9c5b331de26508130d8b733e6152d2b1b63f9 Mon Sep 17 00:00:00 2001 From: BEAULATON Laurent <laurent.beaulaton@ofb.gouv.fr> Date: Mon, 31 Jan 2022 01:24:43 +0100 Subject: [PATCH 51/51] [gitlab-ci] livraison finale --- gitlab-ci/rules.gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gitlab-ci/rules.gitlab-ci.yml b/gitlab-ci/rules.gitlab-ci.yml index c18e283..d341aa5 100644 --- a/gitlab-ci/rules.gitlab-ci.yml +++ b/gitlab-ci/rules.gitlab-ci.yml @@ -5,9 +5,9 @@ .rules_other: rules: - if: '$CI_COMMIT_BRANCH != "main"' # only if there is changes in branch other than main -# changes: # and there is changes in Dockerfile -# - db.dockerfile -# - R.dockerfile + changes: # and there is changes in Dockerfile + - db.dockerfile + - R.dockerfile ####################### # for main banch only -- GitLab