From 39c9645215832a805e44301e4e70e401ff263169 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Wed, 15 Jun 2022 20:37:01 +0530 Subject: [PATCH 1/8] add ci job to sync chanages from searx --- .gitlab-ci.yml | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 525555f2b..4f01d160a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,18 +5,61 @@ stages: - build - test - deploy + - update-from-upstream services: - docker:20.10-dind +searx: + stage: update-from-upstream + image: registry.gitlab.e.foundation/e/tools/docker-tools:latest + only: + - schedules + variables: + GIT_STRATEGY: none + CI_PROJECT_SSH_URL: git@gitlab.e.foundation:$CI_PROJECT_PATH + before_script: + - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - echo "${SSH_E_ROBOT_PRIVATE_KEY}" | tr -d '\r' | ssh-add - > /dev/null + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - echo "${SSH_KNOWN_HOSTS}" > /root/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + - git config --global user.email $GITLAB_USER_EMAIL + - git config --global user.name "$GITLAB_USER_NAME" + - rm -rf $CI_PROJECT_DIR + - git clone $CI_PROJECT_SSH_URL $CI_PROJECT_DIR + - cd $CI_PROJECT_DIR + script: + - git fetch origin + - BRANCH_NAME=$(date +%F-%H%M)-searx + - git checkout -b $BRANCH_NAME + - git remote add upstream $UPSTREAM_REPO + - git pull upstream $UPSTREAM_BRANCH || true + - git add . + - git commit -m "sync changes from upstream" + - git push origin $BRANCH_NAME + - curl -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests" --header "TOKEN:$CI_JOB_TOKEN" --header "Content-Type:application/json" --data "{'title':'test MR from curl', 'source_branch':$BRANCH_NAME, 'target_branch':'fix-preferences', 'assignee_id':$MR_ASSIGNEE_ID}" + python: stage: check + only: + - tags + - branches + except: + - schedules script: - ./manage test.pep8 - ./manage test.pylint build:web: stage: build + only: + - tags + - branches + except: + - schedules before_script: - ./manage node.update - ./manage node.env @@ -38,6 +81,11 @@ build:web: - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG build:docker: + only: + - tags + - branches + except: + - schedules extends: .build:docker build:docker:tags: @@ -52,6 +100,11 @@ build:docker:tags: test:unit: stage: test + only: + - tags + - branches + except: + - schedules script: - ./manage test.coverage coverage: '/TOTAL.*\s+(\d+%)$/' @@ -75,6 +128,8 @@ deploy:spot.eeo.one.backend1: when: manual only: - branches + except: + - schedules environment: name: eeo1 url: https://spot.eeo.one @@ -112,6 +167,8 @@ deploy:spot.eeo.one.backend2: when: manual only: - branches + except: + - schedules environment: name: eeo2 url: https://spot.eeo.one -- GitLab From d550657a62e1451834d17e4fa90d04417035d115 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Wed, 15 Jun 2022 21:15:27 +0530 Subject: [PATCH 2/8] fix target branch --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4f01d160a..f5a664b1e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -40,7 +40,7 @@ searx: - git add . - git commit -m "sync changes from upstream" - git push origin $BRANCH_NAME - - curl -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests" --header "TOKEN:$CI_JOB_TOKEN" --header "Content-Type:application/json" --data "{'title':'test MR from curl', 'source_branch':$BRANCH_NAME, 'target_branch':'fix-preferences', 'assignee_id':$MR_ASSIGNEE_ID}" + - curl -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests" --header "TOKEN:$CI_JOB_TOKEN" --header "Content-Type:application/json" --data "{'title':'test MR from curl', 'source_branch':$BRANCH_NAME, 'target_branch':'master', 'assignee_id':$MR_ASSIGNEE_ID}" python: stage: check -- GitLab From 9d8e3e45c03c75d6d3448dea056d8e4d90f07425 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Wed, 15 Jun 2022 21:54:26 +0530 Subject: [PATCH 3/8] commit only when changes --- .gitlab-ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f5a664b1e..c8bad41e3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,6 +37,12 @@ searx: - git checkout -b $BRANCH_NAME - git remote add upstream $UPSTREAM_REPO - git pull upstream $UPSTREAM_BRANCH || true + - if ! (git diff --exit-code > /dev/null) || ! (git diff --exit-code > /dev/null) || ! [[ -z "$(git status --porcelain)" ]] ; then + echo "Changes detected, committing to origin/$BRANCH_NAME..." + else + echo "Everything is up to date, nothing to commit" + exit 0 + fi - git add . - git commit -m "sync changes from upstream" - git push origin $BRANCH_NAME -- GitLab From aafc1c7cae88fec34f7a4467f0ac13f32ddb5698 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Wed, 15 Jun 2022 22:12:04 +0530 Subject: [PATCH 4/8] add ; --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c8bad41e3..def48b2a4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,10 +38,10 @@ searx: - git remote add upstream $UPSTREAM_REPO - git pull upstream $UPSTREAM_BRANCH || true - if ! (git diff --exit-code > /dev/null) || ! (git diff --exit-code > /dev/null) || ! [[ -z "$(git status --porcelain)" ]] ; then - echo "Changes detected, committing to origin/$BRANCH_NAME..." + echo "Changes detected, committing to origin/$BRANCH_NAME..."; else - echo "Everything is up to date, nothing to commit" - exit 0 + echo "Everything is up to date, nothing to commit"; + exit 0; fi - git add . - git commit -m "sync changes from upstream" -- GitLab From a4d71b89474459b5863c2294af8a248915a9e4d7 Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Thu, 16 Jun 2022 00:46:16 +0530 Subject: [PATCH 5/8] update curl --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index def48b2a4..c2202febe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,7 +46,7 @@ searx: - git add . - git commit -m "sync changes from upstream" - git push origin $BRANCH_NAME - - curl -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests" --header "TOKEN:$CI_JOB_TOKEN" --header "Content-Type:application/json" --data "{'title':'test MR from curl', 'source_branch':$BRANCH_NAME, 'target_branch':'master', 'assignee_id':$MR_ASSIGNEE_ID}" + - curl -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests" --header "TOKEN:$CI_JOB_TOKEN" --header "Content-Type:application/json" --data '{ "title":"Sync changes from searx","source_branch":$BRANCH_NAME,"target_branch":"master","assignee_id":$MR_ASSIGNEE_ID}' python: stage: check -- GitLab From c49cba993e93a980e82ec36e899c4718b42447ce Mon Sep 17 00:00:00 2001 From: Nivesh Krishna Date: Thu, 16 Jun 2022 12:20:58 +0000 Subject: [PATCH 6/8] Update .gitlab-ci.yml --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c2202febe..49ff544dc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,7 +46,7 @@ searx: - git add . - git commit -m "sync changes from upstream" - git push origin $BRANCH_NAME - - curl -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests" --header "TOKEN:$CI_JOB_TOKEN" --header "Content-Type:application/json" --data '{ "title":"Sync changes from searx","source_branch":$BRANCH_NAME,"target_branch":"master","assignee_id":$MR_ASSIGNEE_ID}' + - curl -Sv -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests" --header "PRIVATE-TOKEN:$CI_JOB_TOKEN" --header "Content-Type:application/json" --data '{ "title":"Sync changes from searx","source_branch":$BRANCH_NAME,"target_branch":"master","assignee_id":$MR_ASSIGNEE_ID}' python: stage: check -- GitLab From e60a139dedf0be3b7ef119a310d54b89e2c3dbd0 Mon Sep 17 00:00:00 2001 From: Nivesh Date: Fri, 17 Jun 2022 13:56:08 +0530 Subject: [PATCH 7/8] test different syntax --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 49ff544dc..28e9d5b86 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,7 +46,7 @@ searx: - git add . - git commit -m "sync changes from upstream" - git push origin $BRANCH_NAME - - curl -Sv -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests" --header "PRIVATE-TOKEN:$CI_JOB_TOKEN" --header "Content-Type:application/json" --data '{ "title":"Sync changes from searx","source_branch":$BRANCH_NAME,"target_branch":"master","assignee_id":$MR_ASSIGNEE_ID}' + - curl -Sv -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests" --header "PRIVATE-TOKEN:$CI_JOB_TOKEN" --header "Content-Type:application/json" --data '{ "title":"Sync changes from searx","source_branch":`$BRANCH_NAME`,"target_branch":"master","assignee_id":`$MR_ASSIGNEE_ID`}' python: stage: check -- GitLab From 01ea736c86c151c9d9d1b32c8eeafc3878338294 Mon Sep 17 00:00:00 2001 From: Nivesh Date: Fri, 17 Jun 2022 15:05:09 +0530 Subject: [PATCH 8/8] test syntax --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 28e9d5b86..5655172f3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,7 +46,7 @@ searx: - git add . - git commit -m "sync changes from upstream" - git push origin $BRANCH_NAME - - curl -Sv -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests" --header "PRIVATE-TOKEN:$CI_JOB_TOKEN" --header "Content-Type:application/json" --data '{ "title":"Sync changes from searx","source_branch":`$BRANCH_NAME`,"target_branch":"master","assignee_id":`$MR_ASSIGNEE_ID`}' + - curl -Sv -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/merge_requests" --header "PRIVATE-TOKEN:$PRIV_TOKEN" --header "Content-Type:application/json" --data '{ "title":"Sync changes from searx","source_branch":`"${BRANCH_NAME}"`,"target_branch":"master","assignee_id":`"$MR_ASSIGNEE_ID"`}' python: stage: check -- GitLab