From 55fc81f89d06945c88215b6978bd33630b8d30e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Lecomte?= Date: Mon, 18 Sep 2023 10:08:05 +0200 Subject: [PATCH] fix pipeline --- .gitlab-ci.yml | 171 +----------------- .gitlab/terraform/terraform.tfvars.template | 4 - .gitlab/terraform/variables.tf | 56 ------ {.gitlab => tryton/.gitlab}/env/tryton.env | 0 {.gitlab => tryton/.gitlab}/env/windows.env | 0 .../.gitlab}/terraform/backend.tf | 0 {.gitlab => tryton/.gitlab}/terraform/data.tf | 0 .../.gitlab}/terraform/locals.tf | 0 {.gitlab => tryton/.gitlab}/terraform/main.tf | 14 +- .../.gitlab}/terraform/providers.tf | 4 + .../.gitlab}/terraform/security_group.tf | 0 .../terraform/terraform.tfvars.template | 3 +- .../{build => .gitlab}/terraform/variables.tf | 11 +- tryton/build/env/tryton.env | 1 - tryton/build/env/windows.env | 31 ---- tryton/build/terraform/backend.tf | 3 - tryton/build/terraform/data.tf | 34 ---- tryton/build/terraform/locals.tf | 9 - tryton/build/terraform/main.tf | 91 ---------- tryton/build/terraform/providers.tf | 25 --- tryton/build/terraform/security_group.tf | 23 --- sign-client.bat => tryton/sign-client.bat | 4 +- tryton/win-make.sh | 22 ++- win-make.sh | 84 --------- 24 files changed, 40 insertions(+), 550 deletions(-) delete mode 100644 .gitlab/terraform/terraform.tfvars.template delete mode 100644 .gitlab/terraform/variables.tf rename {.gitlab => tryton/.gitlab}/env/tryton.env (100%) rename {.gitlab => tryton/.gitlab}/env/windows.env (100%) rename {.gitlab => tryton/.gitlab}/terraform/backend.tf (100%) rename {.gitlab => tryton/.gitlab}/terraform/data.tf (100%) rename {.gitlab => tryton/.gitlab}/terraform/locals.tf (100%) rename {.gitlab => tryton/.gitlab}/terraform/main.tf (88%) rename {.gitlab => tryton/.gitlab}/terraform/providers.tf (84%) rename {.gitlab => tryton/.gitlab}/terraform/security_group.tf (100%) rename tryton/{build => .gitlab}/terraform/terraform.tfvars.template (56%) rename tryton/{build => .gitlab}/terraform/variables.tf (84%) delete mode 100644 tryton/build/env/tryton.env delete mode 100644 tryton/build/env/windows.env delete mode 100644 tryton/build/terraform/backend.tf delete mode 100644 tryton/build/terraform/data.tf delete mode 100644 tryton/build/terraform/locals.tf delete mode 100644 tryton/build/terraform/main.tf delete mode 100644 tryton/build/terraform/providers.tf delete mode 100644 tryton/build/terraform/security_group.tf rename sign-client.bat => tryton/sign-client.bat (85%) delete mode 100755 win-make.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ecf65860f5e..76183f73364 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,170 +1,5 @@ -stages: - - synchronize - - create - - build - - destroy - -################## extends ################## - -.terraform: - before_script: - - apt update && apt install -y --no-install-recommends --no-install-suggests git gnupg software-properties-common curl openssh-client gettext - - curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - - - apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" - - apt update && apt install -y --no-install-recommends --no-install-suggests terraform - - cd "${CI_PROJECT_DIR}/.gitlab/terraform" - - |- - terraform init \ - -backend-config="address=${CI_SERVER_URL}/api/v4/projects/${CI_PROJECT_ID}/terraform/state/${CI_COMMIT_REF_SLUG}_${CI_PIPELINE_ID}" \ - -backend-config="lock_address=${CI_SERVER_URL}/api/v4/projects/${CI_PROJECT_ID}/terraform/state/${CI_COMMIT_REF_SLUG}_${CI_PIPELINE_ID}/lock" \ - -backend-config="unlock_address=${CI_SERVER_URL}/api/v4/projects/${CI_PROJECT_ID}/terraform/state/${CI_COMMIT_REF_SLUG}_${CI_PIPELINE_ID}/lock" \ - -backend-config="username=project_${CI_PROJECT_ID}_bot" \ - -backend-config="password=${PROJECT_API_TOKEN}" \ - -backend-config="lock_method=POST" \ - -backend-config="unlock_method=DELETE" \ - -backend-config="retry_wait_min=5" - - envsubst < "terraform.tfvars.template" > "terraform.tfvars" - -################## Includes ################## - include: - - project: 'coopengo/devops/gitlab-ci-template' + - project: "coopengo/devops/gitlab-ci-template" ref: master - file: '/Jobs/reference.debian.gitlab-ci.yml' - -################## Jobs ################## - -synchronize:pipeline: - stage: synchronize - image: bitnami/git:latest - before_script: - - mkdir -p ~/.ssh - - chmod 700 ~/.ssh - - ssh-keyscan -H "${CI_SERVER_HOST}" >>~/.ssh/known_hosts - - cat "${SSH_KEY}" > ~/.ssh/id_rsa - - chmod 400 ~/.ssh/id_rsa - - git config --global user.email "${GITLAB_USER_EMAIL}" - - git config --global user.name "🤖 GitLab CI/CD 🤖" - - git remote set-url origin git@${CI_SERVER_HOST}:${CI_PROJECT_PATH}.git - - git fetch --all - script: - - |- - for BRANCH in $(git ls-remote --refs -h origin -l "coog-*" | cut -s -d '/' -f3 | grep -E "^(coog-[[:digit:]]{1,2}).([[:digit:]]{1,2})$" ) - do - git checkout "${BRANCH}" - git checkout "${CI_COMMIT_SHORT_SHA}" .gitlab-ci.yml sign-client.bat .gitlab/ - git commit -m "Merge .gitlab-ci.yml, sign-client.bat and build directory from \"${CI_COMMIT_SHORT_SHA}\"" || echo "Nothing to do" - done - git push --all - rules: - - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH' - changes: - - ".gitlab-ci.yml" - - ".gitlab/**/*" - - "sign-client.bat" - -create:windows: - stage: create - image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest - before_script: - - apt update && apt install -y --no-install-recommends git - - |- - if [[ $(git tag --points-at HEAD | wc -l) -ne 1 && ${CI_PIPELINE_SOURCE} != "web" ]] - then - echo "Last commit doesn't have 1 tag, that mean there is no change" - echo "Pipeline stop here" - exit 1 - fi - - !reference [.terraform, before_script] - script: - - terraform plan - - terraform apply --auto-approve - - cd "${CI_PROJECT_DIR}" - - |- - export EC2_STATE_TRY="1" - while [[ $(aws ec2 describe-instances --filters "Name = instance.group-name, Values = tryton-${CI_COMMIT_REF_NAME}-${CI_PIPELINE_ID}" --query 'Reservations[*].Instances[0].State.Name' --output text) != "running" ]] && - [[ "$EC2_STATE_TRY" -le "10" ]] - do - echo "Warning : Must wait 60 second minimum else ssh refuse connection" - echo "Instance not ready... Retry in 60 sec - ${EC2_STATE_TRY}" - sleep 60 - let ++EC2_STATE_TRY - done - if [[ "$EC2_STATE_TRY" -ge "10" ]] - then - echo "Instance still not running" - exit 1 - fi - - |- - export INSTANCE_IP_TRY="1" - while [[ "${INSTANCE_IP}" == "" ]] && [[ "${INSTANCE_IP_TRY}" -le "20" ]] - do - export INSTANCE_IP=$(aws ec2 describe-instances --filters "Name = instance.group-name, Values = tryton-${CI_COMMIT_REF_NAME}-${CI_PIPELINE_ID}" --query 'Reservations[*].Instances[0].PrivateIpAddress' --output text) - if [[ "${INSTANCE_IP}" == "" ]] - then - echo "INSTANCE_IP variable is empty." - echo "Wait 10 seconds before retry" - echo "Try ${INSTANCE_IP_TRY}/20" - sleep 10 - (( ++INSTANCE_IP_TRY )) - fi - done - if [[ "$INSTANCE_IP" == "" ]] - then - echo "Couldn't get INSTANCE_IP" - exit 1 - fi - - envsubst < "${CI_PROJECT_DIR}/.gitlab/env/tryton.env" > tryton.env - artifacts: - paths: - - tryton.env - expire_in: 2 hours - rules: - - if: $CI_COMMIT_TAG =~ /^coog-(([[:digit:]]{1,2}).([[:digit:]]{1,2}))/ - -build:tryton_client: - stage: build - image: darkwizard242/ansible:debian-bullseye - variables: - ANSIBLE_FORCE_COLOR: "true" - before_script: - - ansible --version - - apt update && apt install --no-install-recommends --no-install-suggests -y git sudo openssh-client nmap - - source tryton.env - - !reference [.git_with_ssh:debian, before_script] - script: - - |- - export SSH_CONNECTION="1" - while [[ "$(nmap ${INSTANCE_IP} -Pn -p 22 | egrep -io 'open|closed|filtered')" != "open" ]] && [[ "${SSH_CONNECTION}" -le "20" ]] - do - echo "Windows server (${INSTANCE_IP}) is not available." - echo "Retry in 60 seconds" - echo "Try ${SSH_CONNECTION}/20" - sleep 60 - (( ++SSH_CONNECTION )) - done - - ssh -T -o "StrictHostKeyChecking=no" administrator@"${INSTANCE_IP}" \ - "PATH=\"${PATH}:/c/msys32/mingw32/bin\" && cd tryton && /usr/bin/git fetch --tags --all -p -f && /usr/bin/git reset --hard origin/master && /usr/bin/git clean -fd && /usr/bin/git checkout ${CI_COMMIT_REF_NAME} && source .gitlab/env/windows.env && ./win-make.sh build ${COOPENGO_SOFTWARE_CERT_PASSWORD} ${WINDOWS_USER_PASSWORD} && ./win-make.sh upload ${GITHUB_TOKEN}" - needs: - - create:windows - rules: - - if: $CI_COMMIT_TAG =~ /^coog-(([[:digit:]]{1,2}).([[:digit:]]{1,2}))/ - - -destroy:windows: - stage: destroy - image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest - before_script: - - !reference [.terraform, before_script] - script: - - terraform plan --refresh-only - - terraform destroy --auto-approve - - curl -s --header "Private-Token:${PROJECT_API_TOKEN}" --request DELETE "${CI_SERVER_URL}/api/v4/projects/${CI_PROJECT_ID}/terraform/state/${CI_COMMIT_REF_SLUG}_${CI_PIPELINE_ID}" - needs: - - job: build:tryton_client - artifacts: false - - job: create:windows - artifacts: false - rules: - - if: $CI_COMMIT_TAG =~ /^coog-(([[:digit:]]{1,2}).([[:digit:]]{1,2}))/ - when: always + file: + - "/Project/${CI_PROJECT_NAME}/.gitlab-ci.yml" diff --git a/.gitlab/terraform/terraform.tfvars.template b/.gitlab/terraform/terraform.tfvars.template deleted file mode 100644 index bf938c9d213..00000000000 --- a/.gitlab/terraform/terraform.tfvars.template +++ /dev/null @@ -1,4 +0,0 @@ -coog_main_version = "${CI_COMMIT_REF_NAME}" -ci_pipeline_id = "${CI_PIPELINE_ID}" -vpc_id = "${AWS_GITLAB_EC2_VPCID}" -availability_zone = "${AWS_GITLAB_EC2_AZ}" \ No newline at end of file diff --git a/.gitlab/terraform/variables.tf b/.gitlab/terraform/variables.tf deleted file mode 100644 index f1d8ea0ac19..00000000000 --- a/.gitlab/terraform/variables.tf +++ /dev/null @@ -1,56 +0,0 @@ -variable "name" { - description = "Name to be used on all the resources as identifier" - type = string - default = "tryton" -} - -variable "owner" { - description = "Define who is the owner of theses resources" - type = string - default = "coopengo" -} - -variable "environment" { - description = "Define envionment usage" - type = string - default = "production" -} - -variable "coog_main_version" { - description = "Environnement for specific coog version test" - type = string - default = "master" -} - -variable "ci_pipeline_id" { - description = "Pipeline ID from GitLab" - type = string - default = "" -} - -variable "instance_count" { - default = "1" -} - -variable "instance_tags" { - type = list(any) - default = ["tryton"] -} - -variable "instance_type" { - description = "AWS instance type for postgres database" - type = string - default = "t3a.medium" -} - -variable "vpc_id" { - description = "Get AWS ID from Gitlab-runner." - type = string - default = null -} - -variable "availability_zone" { - description = "Get AWS availability_zone from Gitlab-runner. Configured on the same AZ to avoid extra billing." - type = string - default = null -} \ No newline at end of file diff --git a/.gitlab/env/tryton.env b/tryton/.gitlab/env/tryton.env similarity index 100% rename from .gitlab/env/tryton.env rename to tryton/.gitlab/env/tryton.env diff --git a/.gitlab/env/windows.env b/tryton/.gitlab/env/windows.env similarity index 100% rename from .gitlab/env/windows.env rename to tryton/.gitlab/env/windows.env diff --git a/.gitlab/terraform/backend.tf b/tryton/.gitlab/terraform/backend.tf similarity index 100% rename from .gitlab/terraform/backend.tf rename to tryton/.gitlab/terraform/backend.tf diff --git a/.gitlab/terraform/data.tf b/tryton/.gitlab/terraform/data.tf similarity index 100% rename from .gitlab/terraform/data.tf rename to tryton/.gitlab/terraform/data.tf diff --git a/.gitlab/terraform/locals.tf b/tryton/.gitlab/terraform/locals.tf similarity index 100% rename from .gitlab/terraform/locals.tf rename to tryton/.gitlab/terraform/locals.tf diff --git a/.gitlab/terraform/main.tf b/tryton/.gitlab/terraform/main.tf similarity index 88% rename from .gitlab/terraform/main.tf rename to tryton/.gitlab/terraform/main.tf index 563f00ea782..b6e6ad074c3 100644 --- a/.gitlab/terraform/main.tf +++ b/tryton/.gitlab/terraform/main.tf @@ -40,18 +40,10 @@ module "asg_gitlab_runner_manager" { instance_type = "c5a.large" weighted_capacity = "5" }, - { - instance_type = "c6i.large" - weighted_capacity = "4" - }, { instance_type = "c5n.large" weighted_capacity = "3" }, - { - instance_type = "t3.medium" - weighted_capacity = "2" - }, { instance_type = "c5.large" weighted_capacity = "1" @@ -67,16 +59,12 @@ module "asg_gitlab_runner_manager" { ebs = { delete_on_termination = true encrypted = false - volume_size = 50 + volume_size = 70 volume_type = "gp3" } } ] - credit_specification = { - cpu_credits = "standard" - } - network_interfaces = [ { delete_on_termination = true diff --git a/.gitlab/terraform/providers.tf b/tryton/.gitlab/terraform/providers.tf similarity index 84% rename from .gitlab/terraform/providers.tf rename to tryton/.gitlab/terraform/providers.tf index 393b4f61303..fb517e4fb0d 100644 --- a/.gitlab/terraform/providers.tf +++ b/tryton/.gitlab/terraform/providers.tf @@ -12,6 +12,10 @@ terraform { provider "aws" { region = "eu-west-3" + assume_role { + role_arn = "arn:aws:iam::${var.assume_role}:role/gitlab-ci" + } + default_tags { tags = { diff --git a/.gitlab/terraform/security_group.tf b/tryton/.gitlab/terraform/security_group.tf similarity index 100% rename from .gitlab/terraform/security_group.tf rename to tryton/.gitlab/terraform/security_group.tf diff --git a/tryton/build/terraform/terraform.tfvars.template b/tryton/.gitlab/terraform/terraform.tfvars.template similarity index 56% rename from tryton/build/terraform/terraform.tfvars.template rename to tryton/.gitlab/terraform/terraform.tfvars.template index bf938c9d213..dde4468c16e 100644 --- a/tryton/build/terraform/terraform.tfvars.template +++ b/tryton/.gitlab/terraform/terraform.tfvars.template @@ -1,4 +1,5 @@ coog_main_version = "${CI_COMMIT_REF_NAME}" ci_pipeline_id = "${CI_PIPELINE_ID}" vpc_id = "${AWS_GITLAB_EC2_VPCID}" -availability_zone = "${AWS_GITLAB_EC2_AZ}" \ No newline at end of file +availability_zone = "${AWS_GITLAB_EC2_AZ}" +assume_role = "${AWS_ASSUME_ROLE_COOPENGO_INTERNE}" \ No newline at end of file diff --git a/tryton/build/terraform/variables.tf b/tryton/.gitlab/terraform/variables.tf similarity index 84% rename from tryton/build/terraform/variables.tf rename to tryton/.gitlab/terraform/variables.tf index f1d8ea0ac19..f01360fbc98 100644 --- a/tryton/build/terraform/variables.tf +++ b/tryton/.gitlab/terraform/variables.tf @@ -53,4 +53,13 @@ variable "availability_zone" { description = "Get AWS availability_zone from Gitlab-runner. Configured on the same AZ to avoid extra billing." type = string default = null -} \ No newline at end of file +} + +variable "assume_role" { + description = "Define which AWS Account assume" + type = string + validation { + condition = length(var.assume_role) >= 12 + error_message = "Add AWS Account ID to assume" + } +} diff --git a/tryton/build/env/tryton.env b/tryton/build/env/tryton.env deleted file mode 100644 index 5ffad419bc0..00000000000 --- a/tryton/build/env/tryton.env +++ /dev/null @@ -1 +0,0 @@ -INSTANCE_IP="${INSTANCE_IP}" \ No newline at end of file diff --git a/tryton/build/env/windows.env b/tryton/build/env/windows.env deleted file mode 100644 index 4238f584676..00000000000 --- a/tryton/build/env/windows.env +++ /dev/null @@ -1,31 +0,0 @@ -ACLOCAL_PATH='/mingw32/share/aclocal:/usr/share/aclocal' -CONFIG_SITE='/etc/config.site' -HG='/usr/bin/hg' -HOSTNAME='EC2AMAZ-NQ1FMKN' -INFOPATH='/usr/local/info:/usr/share/info:/usr/info:/share/info' -LANG='fr_FR.UTF-8' -MANPATH='/mingw32/local/man:/mingw32/share/man:/usr/local/man:/usr/share/man:/usr/man:/share/man' -MINGW_CHOST='i686-w64-mingw32' -MINGW_PACKAGE_PREFIX='mingw-w64-i686' -MINGW_PREFIX='/mingw32' -MSYSTEM_CARCH='i686' -MSYSTEM_CHOST='i686-w64-mingw32' -MSYSTEM_PREFIX='/mingw32' -MSYSTEM='MINGW32' -OLDPWD='/home/Administrator' -ORIGINAL_PATH='/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/' -ORIGINAL_TEMP='' -ORIGINAL_TMP='' -PATH='/mingw32/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl' -PKG_CONFIG_PATH='/mingw32/lib/pkgconfig:/mingw32/share/pkgconfig' -PRINTER='Microsoft Print to PDF' -PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[35m\]$MSYSTEM\[\e[0m\] \[\e[33m\]\w\[\e[0m\]\n\[\e[1m\]#\[\e[0m\] ' -SHLVL='1' -SSH_TTY='/dev/pty2' -temp='' -TEMP='/tmp' -TERM='xterm-256color' -tmp='' -TMP='/tmp' -TZ='Etc/GMT' -XDG_DATA_DIRS='/mingw32/share/:/usr/local/share/:/usr/share/' \ No newline at end of file diff --git a/tryton/build/terraform/backend.tf b/tryton/build/terraform/backend.tf deleted file mode 100644 index d87763339f8..00000000000 --- a/tryton/build/terraform/backend.tf +++ /dev/null @@ -1,3 +0,0 @@ -terraform { - backend "http" {} -} \ No newline at end of file diff --git a/tryton/build/terraform/data.tf b/tryton/build/terraform/data.tf deleted file mode 100644 index 78fe5df6ac7..00000000000 --- a/tryton/build/terraform/data.tf +++ /dev/null @@ -1,34 +0,0 @@ -data "aws_security_groups" "gitlab_runner_slave" { - filter { - name = "group-name" - values = ["gitlab_runner-slave"] - } - - filter { - name = "vpc-id" - values = [var.vpc_id] - } -} - -data "aws_ami" "windows" { - most_recent = true - owners = ["self"] - filter { - name = "name" - values = ["gtk-build-python3_*"] - } - - filter { - name = "platform" - values = ["windows"] - } -} - -data "aws_subnet" "gitlab_runner" { - availability_zone = var.availability_zone - vpc_id = var.vpc_id - - tags = { - Type = "public subnets" - } -} \ No newline at end of file diff --git a/tryton/build/terraform/locals.tf b/tryton/build/terraform/locals.tf deleted file mode 100644 index a413baf2a9f..00000000000 --- a/tryton/build/terraform/locals.tf +++ /dev/null @@ -1,9 +0,0 @@ -locals { - common_tags = { - Name = lower(var.name) - Owner = lower(var.owner) - Managed_by = lower("terraform") - Environment = lower(var.environment) - Project = lower("tryton") - } -} \ No newline at end of file diff --git a/tryton/build/terraform/main.tf b/tryton/build/terraform/main.tf deleted file mode 100644 index e81a503c6ad..00000000000 --- a/tryton/build/terraform/main.tf +++ /dev/null @@ -1,91 +0,0 @@ -# To do: -# - Intégrer une deuxieme base de données pour les tests pypy -# - Revoir la structure du terraform pour mettre les bases coog et coog-pypy dans un même fichier - -# spot_price - (Optional; Default: On-demand price) The maximum price to request on the spot market. -module "asg_gitlab_runner_manager" { - source = "terraform-aws-modules/autoscaling/aws" - version = "~> 4.4" - - name = "${var.name}-${var.coog_main_version}-${var.ci_pipeline_id}" - - min_size = 1 - max_size = 1 - desired_capacity = 1 - wait_for_capacity_timeout = 0 - health_check_type = "EC2" - vpc_zone_identifier = [data.aws_subnet.gitlab_runner.id] - - key_name = "gitlab-ci" - # user_data_base64 = filebase64("configure_postgres.sh") - - # Launch template - create_lt = true - - image_id = data.aws_ami.windows.image_id - instance_type = var.instance_type - ebs_optimized = false - enable_monitoring = false - use_mixed_instances_policy = true - - mixed_instances_policy = { - instances_distribution = { - on_demand_base_capacity = 0 - on_demand_percentage_above_base_capacity = 0 - spot_allocation_strategy = "capacity-optimized" - } - override = [ - - { - instance_type = "t3.medium" - weighted_capacity = "5" - }, - { - instance_type = "c6i.large" - weighted_capacity = "4" - }, - { - instance_type = "c5n.large" - weighted_capacity = "3" - }, - { - instance_type = "c5a.large" - weighted_capacity = "2" - }, - { - instance_type = "c5.large" - weighted_capacity = "1" - }, - ] - } - - block_device_mappings = [ - { - # Root volume - device_name = "/dev/sda1" - no_device = 0 - ebs = { - delete_on_termination = true - encrypted = false - volume_size = 50 - volume_type = "gp3" - } - } - ] - - credit_specification = { - cpu_credits = "standard" - } - - network_interfaces = [ - { - delete_on_termination = true - description = "eth0" - associate_public_ip_address = true - device_index = 0 - security_groups = [aws_security_group.postgres_sql.id] - } - ] - - tags_as_map = { for k, v in local.common_tags : k => v if k != "Name" } -} \ No newline at end of file diff --git a/tryton/build/terraform/providers.tf b/tryton/build/terraform/providers.tf deleted file mode 100644 index 393b4f61303..00000000000 --- a/tryton/build/terraform/providers.tf +++ /dev/null @@ -1,25 +0,0 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - # version = "~> 3.65" - } - } - - required_version = ">= 1.0" -} - -provider "aws" { - region = "eu-west-3" - - - default_tags { - tags = { - Name = "${var.name}-${var.coog_main_version}-${var.ci_pipeline_id}" - Owner = "coopengo" - Managed_by = "ec2-instance-gitlab_runner-manager" - Environment = "production" - Project = lower("gitlab-cicd") - } - } -} diff --git a/tryton/build/terraform/security_group.tf b/tryton/build/terraform/security_group.tf deleted file mode 100644 index 22217b6dd0a..00000000000 --- a/tryton/build/terraform/security_group.tf +++ /dev/null @@ -1,23 +0,0 @@ -resource "aws_security_group" "postgres_sql" { - name = "tryton-${var.coog_main_version}-${var.ci_pipeline_id}" - description = "Build tryton-${var.coog_main_version} for the Gitlab pipeline ${var.ci_pipeline_id}" - vpc_id = var.vpc_id - - // allow traffic for TCP 22 from gitlab_runner_slave - ingress { - from_port = 22 - to_port = 22 - protocol = "tcp" - security_groups = data.aws_security_groups.gitlab_runner_slave.ids - } - - // outbound internet access - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } - - tags = { for k, v in local.common_tags : k => v if k != "Name" } -} \ No newline at end of file diff --git a/sign-client.bat b/tryton/sign-client.bat similarity index 85% rename from sign-client.bat rename to tryton/sign-client.bat index 9a98114fa27..7f7beac9926 100644 --- a/sign-client.bat +++ b/tryton/sign-client.bat @@ -2,9 +2,9 @@ set password=%1 set cert_path=C:\Users\Administrator\Desktop\certificat\coopengo-software-cert.pfx set current_directory=%cd% -set folder=C:\msys32\home\Administrator\tryton\dist +set folder=C:\msys32\home\Administrator\tryton\tryton\dist -cd "C:\msys32\home\Administrator\tryton" +cd "C:\msys32\home\Administrator\tryton\tryton" if exist %folder% ( echo Signing coog.exe ... diff --git a/tryton/win-make.sh b/tryton/win-make.sh index 89b2c4f8867..53c40ba9fc6 100755 --- a/tryton/win-make.sh +++ b/tryton/win-make.sh @@ -1,6 +1,11 @@ #!/bin/bash -GDRIVE_FOLDER_ID=1zdO12Vei2nAUY__-ICesV_WWkPbkCVH9 +# For build +CERTIFICAT_PASSWORD=$2 +WINDOWS_USER_PASSWORD=$3 + +# For upload +GITHUB_TOKEN=$2 version() { local t @@ -38,7 +43,7 @@ deps() { chardet \ pyflakes - echo "gdrive should be installed from https://github.com/prasmussen/gdrive#downloads" + echo "gdrive should be installed from https://github.com/glotlabs/gdrive#downloads" echo "gdrive should be placed in a PATH folder" } @@ -51,14 +56,23 @@ build() { local v; v=$(version) python setup.py compile_catalog python setup-freeze.py install_exe -d dist + "C:/PSTools/PsExec.exe" -u Administrator -p ${WINDOWS_USER_PASSWORD} "C:\msys32\home\Administrator\tryton\tryton\sign-client.bat" ${CERTIFICAT_PASSWORD} makensis -DVERSION="$v" -DBITS=32 -DSERIES="$v" setup.nsi - makensis -DVERSION="$v" -DBITS=32 setup-single.nsi + # makensis -DVERSION="$v" -DBITS=32 setup-single.nsi + mv dist "$v" + "C:/PSTools/PsExec.exe" -u Administrator -p ${WINDOWS_USER_PASSWORD} "C:\msys32\home\Administrator\tryton\tryton\sign-client.bat" ${CERTIFICAT_PASSWORD} + zip -q -9 -r "coog-$v.zip" "$v" } upload() { + local v; v=$(version) + + CREATE_RELEASE=$(curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${GITHUB_TOKEN}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/coopengo/tryton/releases -d "{\"tag_name\":\"coog-$v\",\"name\":\"coog-$v\",\"body\":\"Coog client for coog-$v\",\"make_latest\":\"false\"}") + UPLOAD_URL=$(echo "${CREATE_RELEASE}" | jq -r '.upload_url' | sed 's/{?name,label}//') + for f in ./coog-* do - gdrive upload -p "$GDRIVE_FOLDER_ID" "$f" + curl -X POST -H "Content-Type: application/octet-stream" --data-binary "@${f/.\/}" -H "Authorization: Bearer ${GITHUB_TOKEN}" "${UPLOAD_URL}?name=${f/.\/}" done } diff --git a/win-make.sh b/win-make.sh deleted file mode 100755 index 558bf4e0c9a..00000000000 --- a/win-make.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash - -# For build -CERTIFICAT_PASSWORD=$2 -WINDOWS_USER_PASSWORD=$3 - -# For upload -GITHUB_TOKEN=$2 - -version() { - local t - t=$(git describe --tags --exact-match 2> /dev/null | grep "^coog-" | head -1) - if [ ! -z "$t" ] - then - echo "${t//coog-/}" - else - local b; b=$(git rev-parse --abbrev-ref HEAD) - local c; c=$(git rev-parse --short HEAD) - echo "$b-$c" | sed -e "s/coog-//g" - fi -} - -deps() { - pacman -S \ - mingw-w64-i686-librsvg \ - mingw-w64-i686-nsis \ - mingw-w64-i686-python3 \ - mingw-w64-i686-python3-setuptools \ - mingw-w64-i686-python3-pip \ - mingw-w64-i686-gtk3 \ - mingw-w64-i686-python3-gobject \ - mingw-w64-i686-gtksourceview3 \ - mingw-w64-i686-gtkglext \ - mingw-w64-i686-python3-cx_Freeze \ - mingw-w64-i686-gobject-introspection \ - mingw-w64-i686-goocanvas \ - mingw-w64-i686-gtksourceview3 \ - mingw-w64-i686-evince - - - pip install \ - python-dateutil \ - chardet \ - pyflakes - - echo "gdrive should be installed from https://github.com/glotlabs/gdrive#downloads" - echo "gdrive should be placed in a PATH folder" -} - -clean() { - rm -rf build dist coog-* -} - -build() { - clean - local v; v=$(version) - python setup.py compile_catalog - python setup-freeze.py install_exe -d dist - "C:/PSTools/PsExec.exe" -u Administrator -p ${WINDOWS_USER_PASSWORD} "C:\msys32\home\Administrator\tryton\sign-client.bat" ${CERTIFICAT_PASSWORD} - makensis -DVERSION="$v" -DBITS=32 -DSERIES="$v" setup.nsi - # makensis -DVERSION="$v" -DBITS=32 setup-single.nsi - mv dist "$v" - "C:/PSTools/PsExec.exe" -u Administrator -p ${WINDOWS_USER_PASSWORD} "C:\msys32\home\Administrator\tryton\sign-client.bat" ${CERTIFICAT_PASSWORD} - zip -q -9 -r "coog-$v.zip" "$v" -} - -upload() { - local v; v=$(version) - - CREATE_RELEASE=$(curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${GITHUB_TOKEN}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/coopengo/tryton/releases -d "{\"tag_name\":\"coog-$v\",\"name\":\"coog-$v\",\"body\":\"Coog client for coog-$v\",\"make_latest\":\"false\"}") - UPLOAD_URL=$(echo "${CREATE_RELEASE}" | jq -r '.upload_url' | sed 's/{?name,label}//') - - for f in ./coog-* - do - curl -X POST -H "Content-Type: application/octet-stream" --data-binary "@${f/.\/}" -H "Authorization: Bearer ${GITHUB_TOKEN}" "${UPLOAD_URL}?name=${f/.\/}" - done -} - -main() { - [ -z "$1" ] && echo missing command && return 1 - "$1" "$@" -} - -main "$@"