From 5bef9525ed7d387178086d7f05208bd344a88c41 Mon Sep 17 00:00:00 2001 From: Eva Vasques Date: Tue, 10 Oct 2023 13:16:07 +0100 Subject: [PATCH 1/6] Remove travis configs --- .travis.settings.xml | 63 ---- .travis.yml | 307 ------------------ scripts/travis/build.sh | 106 ------ scripts/travis/build_functions.sh | 223 ------------- scripts/travis/cleanup_cache.sh | 19 -- scripts/travis/copy_ags_to_release_bucket.sh | 27 -- .../travis/copy_share_image_to_dockerHub.sh | 27 -- .../travis/copy_share_to_release_bucket.sh | 32 -- scripts/travis/copy_to_release_bucket.sh | 31 -- scripts/travis/init.sh | 18 - scripts/travis/maven_publish.sh | 31 -- scripts/travis/maven_release.sh | 36 -- scripts/travis/update_downstream.sh | 88 ----- scripts/travis/verify_release_tag.sh | 52 --- 14 files changed, 1060 deletions(-) delete mode 100644 .travis.settings.xml delete mode 100644 .travis.yml delete mode 100644 scripts/travis/build.sh delete mode 100644 scripts/travis/build_functions.sh delete mode 100644 scripts/travis/cleanup_cache.sh delete mode 100644 scripts/travis/copy_ags_to_release_bucket.sh delete mode 100644 scripts/travis/copy_share_image_to_dockerHub.sh delete mode 100644 scripts/travis/copy_share_to_release_bucket.sh delete mode 100755 scripts/travis/copy_to_release_bucket.sh delete mode 100644 scripts/travis/init.sh delete mode 100755 scripts/travis/maven_publish.sh delete mode 100755 scripts/travis/maven_release.sh delete mode 100644 scripts/travis/update_downstream.sh delete mode 100755 scripts/travis/verify_release_tag.sh diff --git a/.travis.settings.xml b/.travis.settings.xml deleted file mode 100644 index fefacc5060..0000000000 --- a/.travis.settings.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - alfresco-internal - - true - - - - alfresco-internal - - true - - - true - - Alfresco Internal Repository - https://artifacts.alfresco.com/nexus/content/groups/internal - - - - - alfresco-internal - Alfresco Internal Repository - https://artifacts.alfresco.com/nexus/content/groups/public - - - - - - - - alfresco-public - ${env.MAVEN_USERNAME} - ${env.MAVEN_PASSWORD} - - - alfresco-internal - ${env.MAVEN_USERNAME} - ${env.MAVEN_PASSWORD} - - - alfresco-enterprise-releases - ${env.MAVEN_USERNAME} - ${env.MAVEN_PASSWORD} - - - quay.io - ${env.QUAY_USERNAME} - ${env.QUAY_PASSWORD} - - - docker.io - ${env.DOCKERHUB_USERNAME} - ${env.DOCKERHUB_PASSWORD} - - - alfresco-internal-snapshot - ${env.MAVEN_USERNAME} - ${env.MAVEN_PASSWORD} - - - diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index afc99209e2..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,307 +0,0 @@ ---- -dist: xenial -language: java -jdk: openjdk11 - -services: - - docker - -git: - depth: false - quiet: true - -cache: - directories: - - ${HOME}/.m2/repository - -# the cache can grow constantly -before_cache: bash scripts/travis/cleanup_cache.sh - -branches: - only: - - master - - /release\/.*/ - - /feature\/.*/ - - /fix\/.*/ - -env: - global: - - TAS_SCRIPTS=../alfresco-community-repo/packaging/tests/scripts - - TAS_ENVIRONMENT=./tests/environment - # Release version has to start with real version (7.1.0-....) for the docker image to build successfully. - - RELEASE_VERSION=7.1.0.4 - - DEVELOPMENT_VERSION=7.1.0.5-SNAPSHOT - - DTAS_VERSION="${DTAS_VERSION:-v1.1}" - -stages: - - name: test - if: commit_message !~ /\[skip tests\]/ - - name: docker_latest - if: commit_message !~ /\[skip docker_latest\]/ AND branch = master AND type != pull_request AND fork = false - - name: docker_release - if: commit_message !~ /\[skip docker_release\]/ AND branch =~ /release\/.*/ AND type != pull_request AND fork = false - - name: release - if: commit_message =~ /\[release\]/ AND (branch = master OR branch =~ /release\/.*/) AND type != pull_request AND fork = false - - name: publish - if: commit_message =~ /\[publish\]/ AND (branch = master OR branch =~ /release\/.*/) AND type != pull_request AND fork = false - - name: update_downstream - if: (commit_message =~ /\[downstream\]/ OR (commit_message =~ /\[release\]/ AND commit_message !~ /\[no downstream\]/)) AND (branch = master OR branch =~ /release\/.*/) AND type != pull_request AND fork = false - -before_install: travis_retry bash scripts/travis/init.sh -install: travis_retry travis_wait 40 bash scripts/travis/build.sh - -jobs: - include: - - name: "REST API TAS tests part1" - if: commit_message =~ /\[tas\]/ - before_script: - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-rest-api-tests.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" - script: - - travis_wait 60 mvn -B install -f tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part1 -Denvironment=default -DrunBugs=false - - - name: "REST API TAS tests part2" - if: commit_message =~ /\[tas\]/ - before_script: - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-rest-api-tests.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" - script: - - travis_wait 60 mvn -B install -f tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part2 -Denvironment=default -DrunBugs=false - - - name: "REST API TAS tests part3" - if: commit_message =~ /\[tas\]/ - before_script: - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-rest-api-tests.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" - script: - - travis_wait 60 mvn -B install -f tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part3 -Denvironment=default -DrunBugs=false - - - name: "CMIS TAS tests - BROWSER binding" - if: commit_message =~ /\[tas\]/ - before_script: - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-cmis-tests.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" - script: - - travis_wait 40 mvn -B install -f tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-browser -Denvironment=default -DrunBugs=false - - - name: "CMIS TAS tests - ATOM binding" - if: commit_message =~ /\[tas\]/ - before_script: - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-cmis-tests.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" - script: - - travis_wait 40 mvn -B install -f tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-atom -Denvironment=default -DrunBugs=false - - - name: "CMIS TAS tests - WEBSERVICES binding" - if: commit_message =~ /\[tas\]/ - before_script: - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-cmis-tests.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" - script: - - travis_wait 40 mvn -B install -f tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-webservices -Denvironment=default -DrunBugs=false - - - name: "Email TAS tests" - if: commit_message =~ /\[tas\]/ - before_script: - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-email-tests.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" - script: - - travis_wait 30 mvn -B install -f tests/tas-email/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false - - - name: "WebDAV TAS tests" - if: commit_message =~ /\[tas\]/ - before_script: - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-minimal.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" - script: - - travis_wait 20 mvn -B install -f tests/tas-webdav/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false - - - name: "Integration TAS tests" - if: commit_message =~ /\[tas\]/ - before_script: - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-integration-tests.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" - script: - - travis_wait 30 mvn -B install -f tests/tas-integration/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false - - - name: "LDAP TAS tests" - if: commit_message =~ /\[tas\]/ - before_script: - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-with-ldap.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" - script: - - travis_wait 60 mvn -B install -f tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-ldap -Denvironment=default -DrunBugs=false - - travis_wait 10 mvn -B install -f tests/tas-integration/pom.xml -Prun-ldap -Denvironment=default -DrunBugs=false - - - name: "REST API TAS tests with AIMS" - if: commit_message !~ /\[skip tas\]/ AND fork = false # AIMS docker image requires access to quay.io - before_script: - # AIMS cannot be configured via localhost - - export HOST_IP=$(hostname -I | cut -f1 -d' ') - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-aims.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" 180 - script: - - travis_wait 60 mvn -B install -f tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-aims -Denvironment=aims-environment -DrunBugs=false "-Didentity-service.auth-server-url=http://${HOST_IP}:8999/auth" - - - name: "CMIS TAS tests with AIMS - BROWSER binding" - if: commit_message !~ /\[skip tas\]/ AND fork = false # AIMS docker image requires access to quay.io - before_script: - # AIMS cannot be configured via localhost - - export HOST_IP=$(hostname -I | cut -f1 -d' ') - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-aims.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" 180 - script: - - travis_wait 40 mvn -B install -f tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-browser-with-aims -Denvironment=aims-environment -DrunBugs=false "-Didentity-service.auth-server-url=http://${HOST_IP}:8999/auth" - - - name: "CMIS TAS tests with AIMS - ATOM binding" - if: commit_message !~ /\[skip tas\]/ AND fork = false # AIMS docker image requires access to quay.io - before_script: - # AIMS cannot be configured via localhost - - export HOST_IP=$(hostname -I | cut -f1 -d' ') - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-aims.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" 180 - script: - - travis_wait 40 mvn -B install -f tests/tas-cmis/pom.xml -Pall-tas-tests,run-cmis-atom-with-aims -Denvironment=aims-environment -DrunBugs=false "-Didentity-service.auth-server-url=http://${HOST_IP}:8999/auth" - - - name: "Sync Service TAS tests" - if: commit_message !~ /\[skip tas\]/ - before_script: - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-sync-service.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" - script: - - travis_wait 20 mvn -B install -f tests/tas-sync-service/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false - - - name: "Elasticsearch TAS tests" - if: commit_message !~ /\[skip search\]/ - script: - - travis_wait 30 mvn -B install -f tests/tas-elasticsearch/pom.xml -Pall-tas-tests,elastic -Denvironment=default -DrunBugs=false - - - name: "Elasticsearch Basic Auth TAS tests" - if: commit_message !~ /\[skip search\]/ - script: - - travis_wait 30 mvn -B install -f tests/tas-elasticsearch/pom.xml -Pall-tas-tests,elastic-basic-auth -Denvironment=default -DrunBugs=false - - - name: "All AMPs tests" - before_script: - - travis_retry travis_wait 20 mvn -B -q install -f tests/tas-all-amps/pom.xml -DskipTests -Pall-tas-tests,prepare-wars-with-amps - script: - - ./tests/scripts/checkLibraryDuplicates.sh ./tests/tas-all-amps/target/war/alfresco/WEB-INF/lib - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-all-amps-test.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" - - travis_wait 20 mvn -B install -f tests/tas-all-amps/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false - - # Test local repo and share docker images that will be used in the single pipeline. Tag:latest - - name: "Single Pipeline image tests" - if: fork = false AND type != pull_request - before_script: - - travis_retry travis_wait 20 mvn -B clean install -Ppipeline,build-docker-images $(mvn -B -q help:evaluate "-Dexpression=dependency.alfresco-enterprise-repo.version" -DforceStdout | grep -q '\-SNAPSHOT$' && echo '-Drepo.image.tag=latest') $(mvn -B -q help:evaluate "-Dexpression=dependency.alfresco-enterprise-share.version" -DforceStdout | grep -q '\-SNAPSHOT$' && echo '-Dshare.image.tag=latest') - # Show what DTAS will be looking for - - cat tests/pipeline-all-amps/repo/target/dtas/dtas-config.json - - pyenv versions - - pyenv global 3.7.1 - - pip install requests pytest==6.2.4 pytest-testinfra==6.3.0 jmespath==0.10.0 - - git clone --depth 1 --branch $DTAS_VERSION https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/Alfresco/alfresco-deployment-test-automation-scripts.git dtas - - docker images | grep pipeline - script: - - ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-pipeline-all-amps.yml - - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8080/alfresco/" 180 - - docker ps - # Show what AMPs the repo has installed - - curl -v --user admin.pipeline@alfresco.com:admin http://localhost:8080/alfresco/api/discovery - - cd dtas - - pytest --configuration ../tests/pipeline-all-amps/repo/target/dtas/dtas-config.json tests/ -s - - - name: "Update latest and Single Pipeline - images" - stage: docker_latest - # Remove the pipeline profile to avoid sending an image tagged with the build number to the single pipeline - script: travis_retry travis_wait 30 mvn -B -V clean install -DskipTests -Dmaven.javadoc.skip=true -Dbuild-number=${TRAVIS_BUILD_NUMBER} -Pags -Ppush-docker-images,pipeline - - - name: "Update release and Single Pipeline - images" - stage: docker_release - # Remove the pipeline profile to avoid sending an image tagged with the build number to the single pipeline - script: travis_retry travis_wait 30 mvn -B -V clean install -DskipTests -Dmaven.javadoc.skip=true -Dbuild-number=${TRAVIS_BUILD_NUMBER} -Ppush-docker-images,pipeline,release-branch - - - name: "Release and Copy to S3 Staging Bucket" - stage: release - before_script: bash scripts/travis/verify_release_tag.sh - script: travis_wait 60 bash scripts/travis/maven_release.sh - before_deploy: - # Move the final artifacts to a single folder (deploy_dir) to be copied to S3 - - mkdir -p deploy_dir - - cp distribution/target/alfresco.war deploy_dir - - cp distribution/target/*-distribution*.zip deploy_dir - - ls -lA deploy_dir - - mkdir -p deploy_dir_share - - cp distribution-share/target/*.war deploy_dir_share - - cp distribution-share/target/*.zip deploy_dir_share - - ls -lA deploy_dir_share - - mkdir -p deploy_dir_ags - - cp distribution-ags/target/*.zip deploy_dir_ags - - ls -lA deploy_dir_ags - deploy: - - provider: s3 - access_key_id: "${AWS_STAGING_ACCESS_KEY}" - secret_access_key: "${AWS_STAGING_SECRET_KEY}" - bucket: "alfresco-artefacts-staging" - region: "eu-west-1" - # Once Travis releases their *dpl v2* api (currently in beta, check https://docs.travis-ci.com/user/deployment-v2#how-to-opt-in-to-v2) - # the skip_cleanup option will no longer be needed (or valid) and should be removed (ACS-1155). - skip_cleanup: true - acl: private - local_dir: "deploy_dir" - upload_dir: "alfresco-content-services/release/${TRAVIS_BRANCH}/${TRAVIS_BUILD_NUMBER}" - on: - all_branches: true - - provider: s3 - access_key_id: "${AWS_STAGING_ACCESS_KEY}" - secret_access_key: "${AWS_STAGING_SECRET_KEY}" - bucket: "alfresco-artefacts-staging" - region: "eu-west-1" - skip_cleanup: true - acl: private - local_dir: "deploy_dir_share" - upload_dir: "share/${RELEASE_VERSION}" - on: - all_branches: true - - provider: s3 - access_key_id: "${AWS_STAGING_ACCESS_KEY}" - secret_access_key: "${AWS_STAGING_SECRET_KEY}" - bucket: "alfresco-artefacts-staging" - region: "eu-west-1" - skip_cleanup: true - acl: private - local_dir: "deploy_dir_ags" - upload_dir: "enterprise/RM/${RELEASE_VERSION}" - on: - all_branches: true - after_deploy: - - echo "Finished release and deployed to https://s3.console.aws.amazon.com/s3/buckets/alfresco-artefacts-staging/alfresco-content-services/release/${TRAVIS_BRANCH}/${TRAVIS_BUILD_NUMBER}" - - - name: "Copy to S3 Release Bucket" - stage: publish - # We do not want to build/install the tip of the branch which will be a SNAPSHOT. - install: skip - script: travis_wait 60 bash scripts/travis/maven_publish.sh - before_deploy: pip install awscli - deploy: - - provider: script - script: bash scripts/travis/copy_to_release_bucket.sh - on: - all_branches: true - - provider: script - script: bash scripts/travis/copy_share_to_release_bucket.sh - on: - all_branches: true - - provider: script - script: bash scripts/travis/copy_ags_to_release_bucket.sh - on: - all_branches: true - - provider: script - script: bash scripts/travis/copy_share_image_to_dockerHub.sh - on: - all_branches: true - - - name: "Update acs-community-packaging (after release)" - stage: update_downstream - install: skip - script: bash scripts/travis/update_downstream.sh diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh deleted file mode 100644 index 1344b0ae87..0000000000 --- a/scripts/travis/build.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env bash -echo "=========================== Starting Build Script ===========================" -PS4="\[\e[35m\]+ \[\e[m\]" -set -vex -pushd "$(dirname "${BASH_SOURCE[0]}")/../../" - -source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh" - -ENT_DEPENDENCY_VERSION="$(retrievePomProperty "dependency.alfresco-enterprise-repo.version")" -REPO_IMAGE=$([[ "${ENT_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] && echo "-Drepo.image.tag=latest" || echo) - -# Either both the parent and the upstream dependency are the same, or else fail the build -if [ "${ENT_DEPENDENCY_VERSION}" != "$(retrievePomParentVersion)" ]; then - printf "Upstream dependency version (%s) is different then the project parent version!\n" "${ENT_DEPENDENCY_VERSION}" - exit 1 -fi - -# Prevent merging of any SNAPSHOT dependencies into the master or the release/* branches -if [[ $(isPullRequestBuild) && "${ENT_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ && "${TRAVIS_BRANCH}" =~ ^master$|^release/.+$ ]] ; then - printf "PRs with SNAPSHOT dependencies are not allowed into master or release branches\n" - exit 1 -fi - -# Prevent release jobs from starting when there are SNAPSHOT upstream dependencies -if [[ "${ENT_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] && [ "${TRAVIS_BUILD_STAGE_NAME,,}" = "release" ] ; then - printf "Cannot release project with SNAPSHOT dependencies!\n" - exit 1 -fi - -ENT_UPSTREAM_REPO="github.com/Alfresco/alfresco-enterprise-repo.git" - -# Checkout the upstream alfresco-enterprise-repo project (tag or branch) -if [[ "${ENT_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] ; then - pullSameBranch "${ENT_UPSTREAM_REPO}" -else - pullUpstreamTag "${ENT_UPSTREAM_REPO}" "${ENT_DEPENDENCY_VERSION}" -fi - -COM_DEPENDENCY_VERSION="$(retrievePomProperty "dependency.alfresco-community-repo.version" "${ENT_UPSTREAM_REPO}")" - -# Either both the parent and the upstream dependency are the same, or else fail the build -if [ "${COM_DEPENDENCY_VERSION}" != "$(retrievePomParentVersion "${ENT_UPSTREAM_REPO}")" ]; then - printf "Upstream dependency version (%s) is different then the project parent version!\n" "${COM_DEPENDENCY_VERSION}" - exit 1 -fi - -# Prevent merging of any SNAPSHOT dependencies into the master or the release/* branches -if [[ $(isPullRequestBuild) && "${COM_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ && "${TRAVIS_BRANCH}" =~ ^master$|^release/.+$ ]] ; then - printf "PRs with SNAPSHOT dependencies are not allowed into master or release branches\n" - exit 1 -fi - -# Prevent release jobs from starting when there are SNAPSHOT upstream dependencies -if [[ "${COM_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] && [ "${TRAVIS_BUILD_STAGE_NAME,,}" = "release" ] ; then - printf "Cannot release project with SNAPSHOT dependencies!\n" - exit 1 -fi - -COM_UPSTREAM_REPO="github.com/Alfresco/alfresco-community-repo.git" - -# Checkout the upstream alfresco-community-repo project (tag or branch; + build if the latter) -if [[ "${COM_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] ; then - pullAndBuildSameBranchOnUpstream "${COM_UPSTREAM_REPO}" "-Pags -Dlicense.failOnNotUptodateHeader=true" -else - pullUpstreamTag "${COM_UPSTREAM_REPO}" "${COM_DEPENDENCY_VERSION}" -fi - -# Build the upstream alfresco-enterprise-repo project with its docker image -if [[ "${ENT_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] ; then - buildSameBranchOnUpstream "${ENT_UPSTREAM_REPO}" "-Pbuild-docker-images -Pags -Dlicense.failOnNotUptodateHeader=true" -else - buildUpstreamTag "${ENT_UPSTREAM_REPO}" "${ENT_DEPENDENCY_VERSION}" "-Pbuild-docker-images -Pags -Dlicense.failOnNotUptodateHeader=true" -fi - -SHARE_DEPENDENCY_VERSION="$(retrievePomProperty "dependency.alfresco-enterprise-share.version")" -SHARE_IMAGE=$([[ "${SHARE_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] && echo "-Dshare.image.tag=latest" || echo) - -# Prevent merging of any SNAPSHOT dependencies into the master or the release/* branches -if [[ $(isPullRequestBuild) && "${SHARE_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ && "${TRAVIS_BRANCH}" =~ ^master$|^release/.+$ ]] ; then - printf "PRs with SNAPSHOT dependencies are not allowed into master or release branches\n" - exit 1 -fi - -# Prevent release jobs from starting when there are SNAPSHOT upstream dependencies -if [[ "${SHARE_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] && [ "${TRAVIS_BUILD_STAGE_NAME,,}" = "release" ] ; then - printf "Cannot release project with SNAPSHOT dependencies!\n" - exit 1 -fi - -SHARE_UPSTREAM_REPO="github.com/Alfresco/alfresco-enterprise-share.git" - -# Checkout the upstream alfresco-enterprise-share project (tag or branch; + build if the latter) -if [[ "${SHARE_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] ; then - pullAndBuildSameBranchOnUpstream "${SHARE_UPSTREAM_REPO}" "-Pbuild-docker-images -Pags -Dlicense.failOnNotUptodateHeader=true -Ddocker.quay-expires.value=NEVER ${REPO_IMAGE} -Ddependency.alfresco-community-repo.version=${COM_DEPENDENCY_VERSION} -Ddependency.alfresco-enterprise-repo.version=${ENT_DEPENDENCY_VERSION}" -else - pullUpstreamTagAndBuildDockerImage "${SHARE_UPSTREAM_REPO}" "${SHARE_DEPENDENCY_VERSION}" "-Pbuild-docker-images -Pags -Dlicense.failOnNotUptodateHeader=true -Ddocker.quay-expires.value=NEVER -Ddependency.alfresco-community-repo.version=${COM_DEPENDENCY_VERSION} -Ddependency.alfresco-enterprise-repo.version=${ENT_DEPENDENCY_VERSION}" -fi - -# Build the current project -mvn -B -V -q install -DskipTests -Dmaven.javadoc.skip=true -Pbuild-docker-images -Pags ${REPO_IMAGE} ${SHARE_IMAGE} - - -popd -set +vex -echo "=========================== Finishing Build Script ==========================" - diff --git a/scripts/travis/build_functions.sh b/scripts/travis/build_functions.sh deleted file mode 100644 index 7c9a2e12a1..0000000000 --- a/scripts/travis/build_functions.sh +++ /dev/null @@ -1,223 +0,0 @@ -#!/usr/bin/env bash -set +vx - -function isPullRequestBuild() { - test "${TRAVIS_PULL_REQUEST}" != "false" -} - -function isBranchBuild() { - test "${TRAVIS_PULL_REQUEST}" = "false" -} - -function cloneRepo() { - local REPO="${1}" - local TAG_OR_BRANCH="${2}" - - printf "Clonning \"%s\" on %s\n" "${TAG_OR_BRANCH}" "${REPO}" - - # clone the repository branch/tag - pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" >/dev/null - - rm -rf "$(basename "${REPO%.git}")" - - git clone -b "${TAG_OR_BRANCH}" --depth=1 "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REPO}" - - popd >/dev/null -} - -function retrievePomParentVersion() { - local REPO="${1}" - - if [ -z "${REPO}" ]; then - pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null - else - pushd "$(dirname "${BASH_SOURCE[0]}")/../../../$(basename "${REPO%.git}")" >/dev/null - fi - - sed -n '//,/<\/parent>/p' pom.xml \ - | sed -n '//,/<\/version>/p' \ - | tr -d '\n' \ - | grep -oP '(?<=).*(?=)' \ - | xargs - - popd >/dev/null -} - -function retrievePomProperty() { - local KEY="${1}" - local REPO="${2}" - - if [ -z "${REPO}" ]; then - pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null - else - pushd "$(dirname "${BASH_SOURCE[0]}")/../../../$(basename "${REPO%.git}")" >/dev/null - fi - - sed -n '//,/<\/properties>/p' pom.xml \ - | sed -n "/<${KEY}>/,/<\/${KEY}>/p" \ - | tr -d '\n' \ - | grep -oP "(?<=<${KEY}>).*(?=)" \ - | xargs - - popd >/dev/null -} - -function evaluatePomProperty() { - local KEY="${1}" - - pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null - - mvn -B -q help:evaluate -Dexpression="${KEY}" -DforceStdout - - popd >/dev/null -} - -function remoteBranchExists() { - local REMOTE_REPO="${1}" - local BRANCH="${2}" - - git ls-remote --exit-code --heads "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REMOTE_REPO}" "${BRANCH}" &>/dev/null -} - -function identifyUpstreamSourceBranch() { - local UPSTREAM_REPO="${1}" - - # if it's a pull request, use the source branch name (if it exists) - if isPullRequestBuild && remoteBranchExists "${UPSTREAM_REPO}" "${TRAVIS_PULL_REQUEST_BRANCH}" ; then - echo "${TRAVIS_PULL_REQUEST_BRANCH}" - exit 0 - fi - - # otherwise use the current branch name (or in case of PRs, the target branch name) - if remoteBranchExists "${UPSTREAM_REPO}" "${TRAVIS_BRANCH}" ; then - echo "${TRAVIS_BRANCH}" - exit 0 - fi - - # if none of the previous exists, use the "master" branch - echo "master" -} - -function pullUpstreamTag() { - local UPSTREAM_REPO="${1}" - local TAG="${2}" - - cloneRepo "${UPSTREAM_REPO}" "${TAG}" -} - -function pullSameBranch() { - local UPSTREAM_REPO="${1}" - - local SOURCE_BRANCH="$(identifyUpstreamSourceBranch "${UPSTREAM_REPO}")" - - cloneRepo "${UPSTREAM_REPO}" "${SOURCE_BRANCH}" -} - -function buildUpstreamTag() { - local UPSTREAM_REPO="${1}" - local TAG="${2}" - local EXTRA_BUILD_ARGUMENTS="${3}" - - pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" - - cd "$(basename "${UPSTREAM_REPO%.git}")" - - mvn -B -V clean package -DskipTests -Dmaven.javadoc.skip=true "-Dimage.tag=${TAG}" ${EXTRA_BUILD_ARGUMENTS} - - popd -} - -function buildSameBranchOnUpstream() { - local UPSTREAM_REPO="${1}" - local EXTRA_BUILD_ARGUMENTS="${2}" - - pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" - - cd "$(basename "${UPSTREAM_REPO%.git}")" - - mvn -B -V -q clean install -DskipTests -Dmaven.javadoc.skip=true ${EXTRA_BUILD_ARGUMENTS} - mvn -B -V -q install -DskipTests -f packaging/tests/pom.xml - - popd -} - -function pullUpstreamTagAndBuildDockerImage() { - local UPSTREAM_REPO="${1}" - local TAG="${2}" - local EXTRA_BUILD_ARGUMENTS="${3}" - - cloneRepo "${UPSTREAM_REPO}" "${TAG}" - - pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" - - cd "$(basename "${UPSTREAM_REPO%.git}")" - - mvn -B -V clean package -DskipTests -Dmaven.javadoc.skip=true "-Dimage.tag=${TAG}" ${EXTRA_BUILD_ARGUMENTS} - - popd -} - -function pullAndBuildSameBranchOnUpstream() { - local UPSTREAM_REPO="${1}" - local EXTRA_BUILD_ARGUMENTS="${2}" - - local SOURCE_BRANCH="$(identifyUpstreamSourceBranch "${UPSTREAM_REPO}")" - - cloneRepo "${UPSTREAM_REPO}" "${SOURCE_BRANCH}" - - pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" - - cd "$(basename "${UPSTREAM_REPO%.git}")" - - mvn -B -V -q clean install -DskipTests -Dmaven.javadoc.skip=true ${EXTRA_BUILD_ARGUMENTS} - mvn -B -V -q install -DskipTests -f packaging/tests/pom.xml - - popd -} - -function retieveLatestTag() { - local REPO="${1}" - local BRANCH="${2}" - - local LOCAL_PATH="/tmp/$(basename "${REPO%.git}")" - - git clone -q -b "${BRANCH}" "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REPO}" "${LOCAL_PATH}" - - pushd "${LOCAL_PATH}" >/dev/null - git describe --abbrev=0 --tags - popd >/dev/null - - rm -rf "${LOCAL_PATH}" -} - -function publishDistributionZip() { - local GROUP_ID="${1}" - local ARTIFACT_ID="${2}" - local VERSION="${3}" - local NEXUS_REPO="${4}" - - local ARTIFACT_PATH="$(echo ${GROUP_ID}/${ARTIFACT_ID} | sed 's/\./\//g')" - local LOCAL_PATH="${HOME}/.m2/repository/${ARTIFACT_PATH}" - local TMP_PATH="/tmp/${ARTIFACT_ID}" - - # Download the artifact. Make sure we are not using a cached version - rm -rf "${LOCAL_PATH}" - mvn org.apache.maven.plugins:maven-dependency-plugin:get \ - -Dartifact=${GROUP_ID}:${ARTIFACT_ID}:${VERSION}:zip \ - -Dtransitive=false - ls -l "${LOCAL_PATH}/${VERSION}" - - # The local maven repo must not contain the downloaded artifacts otherwise the upload can fail - rm -rf "${TMP_PATH}" - mv "${LOCAL_PATH}/${VERSION}" "${TMP_PATH}" - - # Upload the artifact - mvn deploy:deploy-file \ - -Dfile="${TMP_PATH}/${ARTIFACT_ID}-${VERSION}.zip" \ - -DrepositoryId=alfresco-enterprise-releases \ - -Durl="${NEXUS_REPO}" \ - -DgroupId="${GROUP_ID}" -DartifactId="${ARTIFACT_ID}" -Dversion="${VERSION}" \ - -Dpackaging=zip -} - -set -vx diff --git a/scripts/travis/cleanup_cache.sh b/scripts/travis/cleanup_cache.sh deleted file mode 100644 index 33b940e2cd..0000000000 --- a/scripts/travis/cleanup_cache.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -set -ev - -rm -rf "${HOME}/.m2/repository/org/alfresco/acs-community-packaging" -rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-community-repo" -rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-community-repo-*" -rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-core" -rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-data-model" -rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-enterprise-remote-api" -rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-enterprise-repo-*" -rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-enterprise-repository" -rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-remote-api" -rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-repository" -rm -rf "${HOME}/.m2/repository/org/alfresco/content-services" -rm -rf "${HOME}/.m2/repository/org/alfresco/content-services*" -rm -rf "${HOME}/.m2/repository/org/alfresco/content-services-community" -rm -rf "${HOME}/.m2/repository/org/alfresco/tas/alfresco-community-repo-*-test" -rm -rf "${HOME}/.m2/repository/org/alfresco/tas/alfresco-enterprise-repo-*-test" - diff --git a/scripts/travis/copy_ags_to_release_bucket.sh b/scripts/travis/copy_ags_to_release_bucket.sh deleted file mode 100644 index 0e1e8e5b92..0000000000 --- a/scripts/travis/copy_ags_to_release_bucket.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -echo "=========================== Starting Copy to Release Bucket Script ===========================" -PS4="\[\e[35m\]+ \[\e[m\]" -set -vex - -# -# Copy from S3 Release bucket to S3 eu.dl bucket -# - -if [ -z "${RELEASE_VERSION}" ]; then - echo "Please provide a RELEASE_VERSION in the format - (7.1.0-EA or 7.1.0-SNAPSHOT)" - exit 1 -fi - -SOURCE="s3://alfresco-artefacts-staging/enterprise/RM/${RELEASE_VERSION}" -DESTINATION="s3://eu.dl.alfresco.com/release/enterprise/RM/${RELEASE_VERSION}" - -printf "\n%s\n%s\n" "${SOURCE}" "${DESTINATION}" - -aws s3 cp --acl private \ - "${SOURCE}/alfresco-governance-services-enterprise-${RELEASE_VERSION}.zip" \ - "${DESTINATION}/alfresco-governance-services-enterprise-${RELEASE_VERSION}.zip" - - -set +vex -echo "=========================== Finishing Copy to Release Bucket Script ==========================" - diff --git a/scripts/travis/copy_share_image_to_dockerHub.sh b/scripts/travis/copy_share_image_to_dockerHub.sh deleted file mode 100644 index ee37251811..0000000000 --- a/scripts/travis/copy_share_image_to_dockerHub.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -echo "=========================== Starting Copy Share Image To Dockerhub Script ===========================" -PS4="\[\e[35m\]+ \[\e[m\]" -set +e -v -x -pushd "$(dirname "${BASH_SOURCE[0]}")/../" - -# -# Copy Image from Quay to dockerhub -# - -TAG_NAME=${RELEASE_VERSION} -SOURCE_IMAGE=quay.io/alfresco/alfresco-share -TARGET_IMAGE=docker.io/alfresco/alfresco-share - -echo "${QUAY_PASSWORD}" | docker login -u="${QUAY_USERNAME}" --password-stdin quay.io -docker pull $SOURCE_IMAGE:$TAG_NAME -docker tag $SOURCE_IMAGE:$TAG_NAME $TARGET_IMAGE:$TAG_NAME - -echo "${DOCKERHUB_PASSWORD}" | docker login -u="${DOCKERHUB_USERNAME}" --password-stdin docker.io -docker push $TARGET_IMAGE:$TAG_NAME - -popd -set +vex -echo "=========================== Finishing Copy Share Image To Dockerhub Script ==========================" - -exit ${SUCCESS} \ No newline at end of file diff --git a/scripts/travis/copy_share_to_release_bucket.sh b/scripts/travis/copy_share_to_release_bucket.sh deleted file mode 100644 index 07fcae35d9..0000000000 --- a/scripts/travis/copy_share_to_release_bucket.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash -echo "=========================== Starting Copy to Release Bucket Script ===========================" -PS4="\[\e[35m\]+ \[\e[m\]" -set -vex - -# -# Copy from S3 Release bucket to S3 eu.dl bucket -# - -if [ -z "${RELEASE_VERSION}" ]; then - echo "Please provide a RELEASE_VERSION in the format - (7.1.0-EA or 7.1.0-SNAPSHOT)" - exit 1 -fi - -SOURCE="s3://alfresco-artefacts-staging/share/${RELEASE_VERSION}" -DESTINATION="s3://eu.dl.alfresco.com/release/share/${RELEASE_VERSION}" - -printf "\n%s\n%s\n" "${SOURCE}" "${DESTINATION}" - - -aws s3 cp --acl private \ - "${SOURCE}/share.war" \ - "${DESTINATION}/share.war" - -aws s3 cp --acl private \ - "${SOURCE}/alfresco-content-services-share-distribution-${RELEASE_VERSION}.zip" \ - "${DESTINATION}/alfresco-content-services-share-distribution-${RELEASE_VERSION}.zip" - - -set +vex -echo "=========================== Finishing Copy to Release Bucket Script ==========================" - diff --git a/scripts/travis/copy_to_release_bucket.sh b/scripts/travis/copy_to_release_bucket.sh deleted file mode 100755 index 5ba49c7a23..0000000000 --- a/scripts/travis/copy_to_release_bucket.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -echo "=========================== Starting Copy to Release Bucket Script ===========================" -PS4="\[\e[35m\]+ \[\e[m\]" -set -vex - -# -# Copy from S3 Release bucket to S3 eu.dl bucket -# - -if [ -z "${RELEASE_VERSION}" ]; then - echo "Please provide a RELEASE_VERSION in the format - (7.1.0-EA or 7.1.0-SNAPSHOT)" - exit 1 -fi - -SOURCE="s3://alfresco-artefacts-staging/alfresco-content-services/release/${TRAVIS_BRANCH}/${TRAVIS_BUILD_NUMBER}" -DESTINATION="s3://eu.dl.alfresco.com/release/enterprise/ACS/${RELEASE_VERSION:0:3}/${RELEASE_VERSION}/${TRAVIS_BUILD_NUMBER}" - -printf "\n%s\n%s\n" "${SOURCE}" "${DESTINATION}" - -aws s3 cp --acl private \ - "${SOURCE}/alfresco.war" \ - "${DESTINATION}/alfresco.war" - -aws s3 cp --acl private \ - "${SOURCE}/alfresco-content-services-distribution-${RELEASE_VERSION}.zip" \ - "${DESTINATION}/alfresco-content-services-distribution-${RELEASE_VERSION}.zip" - - -set +vex -echo "=========================== Finishing Copy to Release Bucket Script ==========================" - diff --git a/scripts/travis/init.sh b/scripts/travis/init.sh deleted file mode 100644 index ca1081746b..0000000000 --- a/scripts/travis/init.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -echo "=========================== Starting Init Script ===========================" -PS4="\[\e[35m\]+ \[\e[m\]" -set -vex -pushd "$(dirname "${BASH_SOURCE[0]}")/../../" - -# Maven Setup -mkdir -p "${HOME}/.m2" && cp -f .travis.settings.xml "${HOME}/.m2/settings.xml" -find "${HOME}/.m2/repository/" -type d -name "*-SNAPSHOT*" | xargs -r -l rm -rf - -# Docker Logins -echo "${DOCKERHUB_PASSWORD}" | docker login -u="${DOCKERHUB_USERNAME}" --password-stdin -echo "${QUAY_PASSWORD}" | docker login -u="${QUAY_USERNAME}" --password-stdin quay.io - -popd -set +vex -echo "=========================== Finishing Init Script ==========================" - diff --git a/scripts/travis/maven_publish.sh b/scripts/travis/maven_publish.sh deleted file mode 100755 index f31ddce04a..0000000000 --- a/scripts/travis/maven_publish.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -echo "=========================== Starting Publish Script ===========================" -# Republishes the maven artifacts in the Enterprise Releases repository. - -PS4="\[\e[35m\]+ \[\e[m\]" -set -vex -pushd "$(dirname "${BASH_SOURCE[0]}")/../../" - -source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh" - -if [ -z "${RELEASE_VERSION}" ]; then - echo "Please provide a Release version in the format - (7.2.0-EA or 7.2.0)" - exit 1 -fi - -# Checkout the tag. -git checkout "${RELEASE_VERSION}" - -# Rebuild the artifacts and publish them to enterprise-releases. -mvn -B \ - -ntp \ - -Ppublish,all-tas-tests,pipeline,ags \ - -DaltDeploymentRepository=alfresco-enterprise-releases::default::https://artifacts.alfresco.com/nexus/content/repositories/enterprise-releases \ - -DskipTests \ - clean deploy - -popd -set +vex -echo "=========================== Finishing Release Script ==========================" - - diff --git a/scripts/travis/maven_release.sh b/scripts/travis/maven_release.sh deleted file mode 100755 index d5431a574c..0000000000 --- a/scripts/travis/maven_release.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -echo "=========================== Starting Release Script ===========================" -PS4="\[\e[35m\]+ \[\e[m\]" -set -vex -pushd "$(dirname "${BASH_SOURCE[0]}")/../../" - -source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh" - -if [ -z "${RELEASE_VERSION}" ] || [ -z "${DEVELOPMENT_VERSION}" ]; then - echo "Please provide a Release and Development version in the format - (7.1.0-EA or 7.1.0-SNAPSHOT)" - exit 1 -fi - -# Use full history for release -git checkout -B "${TRAVIS_BRANCH}" -# Add email to link commits to user -git config user.email "${GIT_EMAIL}" - -mvn -B \ - -Prelease,all-tas-tests,pipeline -Pags \ - -DreleaseVersion="${RELEASE_VERSION}" \ - -DdevelopmentVersion="${DEVELOPMENT_VERSION}" \ - "-Darguments=-Prelease,all-tas-tests,pipeline -Pags -DskipTests -Dbuild-number=${TRAVIS_BUILD_NUMBER}" \ - release:clean release:prepare release:perform \ - -DscmCommentPrefix="[maven-release-plugin][skip ci] " \ - -Dusername="${GIT_USERNAME}" \ - -Dpassword="${GIT_PASSWORD}" - - -# The alfresco-content-services-share-distribution was in the Nexus 'Releases' repository prior to 7.1.0, which was visible to Community. -publishDistributionZip org.alfresco alfresco-content-services-share-distribution ${RELEASE_VERSION} https://nexus.alfresco.com/nexus/content/repositories/releases/ - -popd -set +vex -echo "=========================== Finishing Release Script ==========================" - diff --git a/scripts/travis/update_downstream.sh b/scripts/travis/update_downstream.sh deleted file mode 100644 index ae31a445da..0000000000 --- a/scripts/travis/update_downstream.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bash -echo "=========================== Starting Update Downstream Script ===========================" -PS4="\[\e[35m\]+ \[\e[m\]" -set -vex -pushd "$(dirname "${BASH_SOURCE[0]}")/../../" - -source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh" - -#Fetch the latest changes, as Travis will only checkout the PR commit -git fetch origin "${TRAVIS_BRANCH}" -git checkout "${TRAVIS_BRANCH}" -git pull - -# Retrieve the latest (just released) latest tag on the current branch -VERSION="$(git describe --abbrev=0 --tags)" - -# Retrieve the Community Repo version -COM_VERSION="$(evaluatePomProperty "dependency.alfresco-community-repo.version")" - -# Retrieve the Enterprise Share version -SHA_VERSION="$(evaluatePomProperty "dependency.alfresco-enterprise-share.version")" - -# Retrieve the release and development versions as they are normally the same in community packaging -RELEASE_VERSION=$(grep RELEASE_VERSION= .travis.yml | sed 's/.*RELEASE_VERSION=\(.*\)/\1/') -DEVELOPMENT_VERSION=$(grep DEVELOPMENT_VERSION= .travis.yml | sed 's/.*DEVELOPMENT_VERSION=\(.*\)/\1/') - -DOWNSTREAM_REPO="github.com/Alfresco/acs-community-packaging.git" - -cloneRepo "${DOWNSTREAM_REPO}" "${TRAVIS_BRANCH}" - -cd "$(dirname "${BASH_SOURCE[0]}")/../../../$(basename "${DOWNSTREAM_REPO%.git}")" - -# Update parent version -mvn -B versions:update-parent versions:commit "-DparentVersion=[${COM_VERSION}]" - -# Update dependency version -mvn -B versions:set-property versions:commit \ - -Dproperty=dependency.alfresco-community-repo.version \ - "-DnewVersion=${COM_VERSION}" - -mvn -B versions:set-property versions:commit \ - -Dproperty=dependency.alfresco-community-share.version \ - "-DnewVersion=${SHA_VERSION}" - -mvn -B versions:set-property versions:commit \ - -Dproperty=dependency.acs-packaging.version \ - "-DnewVersion=${VERSION}" - -sed -i "s/.*RELEASE_VERSION=.*/ - RELEASE_VERSION=$RELEASE_VERSION/" .travis.yml -sed -i "s/.*DEVELOPMENT_VERSION=.*/ - DEVELOPMENT_VERSION=$DEVELOPMENT_VERSION/" .travis.yml - -set +e -echo "${TRAVIS_COMMIT_MESSAGE}" | grep '\[publish\]' -if [ "$?" -eq 0 ] -then - COMMIT_DIRECTIVES="[release][publish]" -else - COMMIT_DIRECTIVES="[release]" -fi -set -e - -# Commit changes -git status -git --no-pager diff pom.xml -git add pom.xml -git --no-pager diff pom.xml -git add .travis.yml - -if git status --untracked-files=no --porcelain | grep -q '^' ; then - git commit -m "${COMMIT_DIRECTIVES} ${VERSION} - - Update upstream versions - - alfresco-community-repo: ${COM_VERSION} - - alfresco-enterprise-share: ${SHA_VERSION} - - acs-packaging: ${VERSION} - - RELEASE_VERSION: ${RELEASE_VERSION} - - DEVELOPMENT_VERSION: ${DEVELOPMENT_VERSION}" - git push -else - echo "Dependencies are already up to date." - git status -fi - - -popd -set +vex -echo "=========================== Finishing Update Downstream Script ==========================" - diff --git a/scripts/travis/verify_release_tag.sh b/scripts/travis/verify_release_tag.sh deleted file mode 100755 index 3312042ad0..0000000000 --- a/scripts/travis/verify_release_tag.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env bash -echo "=========================== Starting Verify Release Tag Script ===========================" -PS4="\[\e[35m\]+ \[\e[m\]" -set -vex -pushd "$(dirname "${BASH_SOURCE[0]}")/../../" - -# -# Check that the version to be released does not already have a docker tag. -# - -if [ -z "${RELEASE_VERSION}" ]; then - echo "Please provide a RELEASE_VERSION in the format - (7.1.0-EA or 7.1.0-SNAPSHOT)" - exit 1 -fi - -if git rev-parse "${RELEASE_VERSION}^{tag}" &>/dev/null ; then - echo "The RELEASE_VERSION tag \"${RELEASE_VERSION}\" already exists in the git project" - exit 1 -fi - -# get the image name from the pom file -ALFRESCO_DOCKER_IMAGE="$(mvn -B -q help:evaluate -f ./docker-alfresco/pom.xml -Dexpression=image.name -DforceStdout)" -DOCKER_IMAGE_FULL_NAME="${ALFRESCO_DOCKER_IMAGE}:${RELEASE_VERSION}" - -function docker_image_exists() { - local IMAGE_FULL_NAME="${1}"; shift - local WAIT_TIME="${1:-5}" - local SEARCH_TERM='Pulling|is up to date|not found' - - echo "Looking to see if ${IMAGE_FULL_NAME} already exists..." - local RESULT=$( (timeout --preserve-status "${WAIT_TIME}" docker 2>&1 pull "${IMAGE_FULL_NAME}" &) | grep -v 'Pulling repository' | grep -E -o "${SEARCH_TERM}") - - test "${RESULT}" || { echo "Timed out too soon. Try using a wait_time greater than ${WAIT_TIME}..."; return 1 ;} - if echo "${RESULT}" | grep -vq 'not found'; then - true - else - false - fi -} - -if docker_image_exists "${DOCKER_IMAGE_FULL_NAME}" ; then - echo "Tag ${RELEASE_VERSION} already pushed, release process will interrupt." - exit 1 -else - echo "The ${RELEASE_VERSION} tag was not found" -fi - - -popd -set +vex -echo "=========================== Finishing Verify Release Tag Script ==========================" - From 0b7509be2675f497a34d235e1a8919d610868b6c Mon Sep 17 00:00:00 2001 From: Eva Vasques Date: Tue, 10 Oct 2023 13:17:53 +0100 Subject: [PATCH 2/6] Add GHA configs --- .ci.settings.xml | 63 ++ .github/workflows/ci.yml | 421 +++++++++++ .github/workflows/master_release.yml | 214 ++++++ scripts/ci/build.sh | 126 ++++ scripts/ci/build_functions.sh | 222 ++++++ scripts/ci/cleanup_cache.sh | 19 + scripts/ci/copy_ags_to_release_bucket.sh | 23 + scripts/ci/copy_share_image_to_docker_hub.sh | 25 + scripts/ci/copy_share_to_release_bucket.sh | 23 + scripts/ci/copy_to_release_bucket.sh | 25 + scripts/ci/init.sh | 21 + scripts/ci/maven_publish.sh | 31 + scripts/ci/maven_release.sh | 40 ++ scripts/ci/prepare_staging_deploy.sh | 61 ++ scripts/ci/source_clear.sh | 26 + scripts/ci/update_downstream.sh | 87 +++ scripts/ci/verify_release_tag.sh | 52 ++ scripts/dev/find-fix.py | 134 ++++ scripts/dev/newReleaseBranch.sh | 717 +++++++++++++++++++ 19 files changed, 2330 insertions(+) create mode 100644 .ci.settings.xml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/master_release.yml create mode 100644 scripts/ci/build.sh create mode 100644 scripts/ci/build_functions.sh create mode 100644 scripts/ci/cleanup_cache.sh create mode 100644 scripts/ci/copy_ags_to_release_bucket.sh create mode 100644 scripts/ci/copy_share_image_to_docker_hub.sh create mode 100644 scripts/ci/copy_share_to_release_bucket.sh create mode 100755 scripts/ci/copy_to_release_bucket.sh create mode 100644 scripts/ci/init.sh create mode 100755 scripts/ci/maven_publish.sh create mode 100755 scripts/ci/maven_release.sh create mode 100755 scripts/ci/prepare_staging_deploy.sh create mode 100644 scripts/ci/source_clear.sh create mode 100644 scripts/ci/update_downstream.sh create mode 100755 scripts/ci/verify_release_tag.sh create mode 100755 scripts/dev/find-fix.py create mode 100644 scripts/dev/newReleaseBranch.sh diff --git a/.ci.settings.xml b/.ci.settings.xml new file mode 100644 index 0000000000..fefacc5060 --- /dev/null +++ b/.ci.settings.xml @@ -0,0 +1,63 @@ + + + + alfresco-internal + + true + + + + alfresco-internal + + true + + + true + + Alfresco Internal Repository + https://artifacts.alfresco.com/nexus/content/groups/internal + + + + + alfresco-internal + Alfresco Internal Repository + https://artifacts.alfresco.com/nexus/content/groups/public + + + + + + + + alfresco-public + ${env.MAVEN_USERNAME} + ${env.MAVEN_PASSWORD} + + + alfresco-internal + ${env.MAVEN_USERNAME} + ${env.MAVEN_PASSWORD} + + + alfresco-enterprise-releases + ${env.MAVEN_USERNAME} + ${env.MAVEN_PASSWORD} + + + quay.io + ${env.QUAY_USERNAME} + ${env.QUAY_PASSWORD} + + + docker.io + ${env.DOCKERHUB_USERNAME} + ${env.DOCKERHUB_PASSWORD} + + + alfresco-internal-snapshot + ${env.MAVEN_USERNAME} + ${env.MAVEN_PASSWORD} + + + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..474218eb4f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,421 @@ +name: ACS Packaging CI + +on: + pull_request: + branches: + - feature/** + - fix/** + - master + - release/** + push: + branches: + - feature/** + - fix/** + workflow_call: + workflow_dispatch: + +env: + JAVA_VERSION: "11" + AZURE_AUTHENTICATION_MODE: sharedKey + AZURE_STORAGE_ACCOUNT_NAME: acspackagingci + AZURE_STORAGE_ACCOUNT_KEY: ${{ secrets.AZURE_PACKAGING_STORAGE_ACCOUNT_KEY }} + DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }} + GITHUB_ACTIONS_DEPLOY_TIMEOUT: 60 + GIT_USERNAME: ${{ secrets.BOT_GITHUB_USERNAME }} + GIT_EMAIL: ${{ secrets.BOT_GITHUB_EMAIL }} + GIT_PASSWORD: ${{ secrets.BOT_GITHUB_TOKEN }} + MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} + MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }} + QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} + QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }} + AWS_REGION: eu-west-1 + TAS_ENVIRONMENT: ./tests/environment + TAS_SCRIPTS: ../alfresco-community-repo/packaging/tests/scripts + ALF_LICENCE_S3_PATH: s3://acs-license/acs/alf71-allenabled.lic + ALF_LICENCE_LOCAL_PATH: /tmp/licence.lic + PYTHON_VERSION: 3.7.15 + DTAS_VERSION: v1.1 + +jobs: + veracode: + name: "Source Clear Scan (SCA)" + runs-on: ubuntu-latest + if: > + ((github.ref_name == 'master' || startsWith(github.ref_name, 'release/')) && github.event_name != 'pull_request') && + !contains(github.event.head_commit.message, '[skip tests]') + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 + with: + java-version: ${{ env.JAVA_VERSION }} + - name: "Init" + run: bash ./scripts/ci/init.sh + - uses: Alfresco/alfresco-build-tools/.github/actions/veracode@v1.35.2 + continue-on-error: true + with: + srcclr-api-token: ${{ secrets.SRCCLR_API_TOKEN }} + - name: "Clean Maven cache" + run: bash ./scripts/ci/cleanup_cache.sh + + tas_tests: + name: ${{ matrix.testSuite }} TAS tests + runs-on: ubuntu-latest + if: > + contains(github.event.head_commit.message, '[tas]') && + !contains(github.event.head_commit.message, '[skip tests]') + strategy: + fail-fast: false + matrix: + include: + - testSuite: REST API part1 + pom-dir: tests/tas-restapi + profiles: all-tas-tests,run-restapi-part1 + compose-file: docker-compose-rest-api-tests.yml + deploy-timeout: 60 + - testSuite: REST API part2 + pom-dir: tests/tas-restapi + profiles: all-tas-tests,run-restapi-part2 + compose-file: docker-compose-rest-api-tests.yml + deploy-timeout: 60 + - testSuite: REST API part3 + pom-dir: tests/tas-restapi + profiles: all-tas-tests,run-restapi-part3 + compose-file: docker-compose-rest-api-tests.yml + deploy-timeout: 60 + - testSuite: CMIS (BROWSER binding) + pom-dir: tests/tas-cmis + profiles: all-tas-tests,run-cmis-browser + compose-file: docker-compose-cmis-tests.yml + deploy-timeout: 40 + - testSuite: CMIS (ATOM binding) + pom-dir: tests/tas-cmis + profiles: all-tas-tests,run-cmis-atom + compose-file: docker-compose-cmis-tests.yml + deploy-timeout: 40 + - testSuite: CMIS (WEBSERVICES binding) + pom-dir: tests/tas-cmis + profiles: all-tas-tests,run-cmis-webservices + compose-file: docker-compose-cmis-tests.yml + deploy-timeout: 40 + - testSuite: Email + pom-dir: tests/tas-email + profiles: all-tas-tests + compose-file: docker-compose-email-tests.yml + deploy-timeout: 30 + - testSuite: WebDAV + pom-dir: tests/tas-webdav + profiles: all-tas-tests + compose-file: docker-compose-minimal.yml + deploy-timeout: 20 + - testSuite: Integration + pom-dir: tests/tas-integration + profiles: all-tas-tests + compose-file: docker-compose-integration-tests.yml + deploy-timeout: 30 + - testSuite: LDAP + pom-dir: tests/tas-integration + profiles: run-ldap + compose-file: docker-compose-with-ldap.yml + deploy-timeout: 10 + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 + with: + java-version: ${{ env.JAVA_VERSION }} + - name: "Build" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: | + bash ./scripts/ci/init.sh + bash ./scripts/ci/build.sh + - name: "Set up the environment" + run: | + ${{ env.TAS_SCRIPTS }}/start-compose.sh ${{ env.TAS_ENVIRONMENT }}/${{ matrix.compose-file }} + ${{ env.TAS_SCRIPTS }}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" + - name: "Run tests" + id: tests + timeout-minutes: ${{ matrix.deploy-timeout }} + run: mvn -B install -ntp -f ${{ matrix.pom-dir }}/pom.xml -P${{ matrix.profiles }} -Denvironment=default -DrunBugs=false + - name: "Print output after failure" + if: ${{ always() && steps.tests.outcome == 'failure' }} + run: ${TAS_SCRIPTS}/output_logs_for_failures.sh "${{ matrix.pom-dir }}" + - name: "Clean Maven cache" + run: bash ./scripts/ci/cleanup_cache.sh + + tas_tests_with_aims: + name: ${{ matrix.testSuite }} TAS tests with AIMS + runs-on: ubuntu-latest + if: > + !contains(github.event.head_commit.message, '[skip tas]') && + !contains(github.event.head_commit.message, '[skip tests]') + strategy: + fail-fast: false + matrix: + include: + - testSuite: REST API + pom: tests/tas-restapi/pom.xml + profiles: all-tas-tests,run-restapi-aims + deploy-timeout: 60 + - testSuite: CMIS - BROWSER binding + pom: tests/tas-cmis/pom.xml + profiles: all-tas-tests,run-cmis-browser-with-aims + deploy-timeout: 40 + - testSuite: CMIS - ATOM binding + pom: tests/tas-cmis/pom.xml + profiles: all-tas-tests,run-cmis-atom-with-aims + deploy-timeout: 40 + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 + with: + java-version: ${{ env.JAVA_VERSION }} + - name: "Build" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: | + bash ./scripts/ci/init.sh + bash ./scripts/ci/build.sh + - name: "Set HOST_IP" + run: echo "HOST_IP=$(hostname -I | cut -f1 -d' ')" >> $GITHUB_ENV + - name: "Set up the environment" + run: | + ${{ env.TAS_SCRIPTS }}/start-compose.sh ${{ env.TAS_ENVIRONMENT }}/docker-compose-aims.yml + ${{ env.TAS_SCRIPTS }}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" 180 + - name: "Run tests" + id: tests + timeout-minutes: ${{ matrix.deploy-timeout }} + run: mvn -B install -ntp -f ${{ matrix.pom }} -P${{ matrix.profiles }} -Denvironment=aims-environment -DrunBugs=false "-Didentity-service.auth-server-url=http://${HOST_IP}:8999/auth" + - name: "Print output after failure" + if: ${{ always() && matrix.testSuite == 'REST API' && steps.tests.outcome == 'failure' }} + run: ${TAS_SCRIPTS}/output_logs_for_failures.sh "tests/tas-restapi" + - name: "Clean Maven cache" + run: bash ./scripts/ci/cleanup_cache.sh + + syncservice_tas_tests: + name: "Sync Service TAS tests" + runs-on: ubuntu-latest + if: > + !contains(github.event.head_commit.message, '[skip tas]') && + !contains(github.event.head_commit.message, '[skip tests]') + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 + with: + java-version: ${{ env.JAVA_VERSION }} + - name: "Build" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: | + bash ./scripts/ci/init.sh + bash ./scripts/ci/build.sh + - name: "Set up the environment" + run: | + ${{ env.TAS_SCRIPTS }}/start-compose.sh ${{ env.TAS_ENVIRONMENT }}/docker-compose-sync-service.yml + ${{ env.TAS_SCRIPTS }}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" + - name: "Run tests" + id: tests + timeout-minutes: 40 + run: mvn -B install -ntp -f tests/tas-sync-service/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false + - name: "Print output after failure" + if: ${{ always() && steps.tests.outcome == 'failure' }} + run: ${TAS_SCRIPTS}/output_logs_for_failures.sh "tests/tas-sync-service" + - name: "Clean Maven cache" + run: bash ./scripts/ci/cleanup_cache.sh + + tas_tests_search_api: + name: ${{ matrix.testSuite }} | TAS tests (Search API) + runs-on: ubuntu-latest + if: > + !contains(github.event.head_commit.message, '[skip search]') && + !contains(github.event.head_commit.message, '[skip tests]') + strategy: + fail-fast: false + matrix: + include: + - testSuite: Elasticsearch + profiles: all-tas-tests,elastic + search-engine-type: elasticsearch + - testSuite: Elasticsearch Basic Auth + profiles: all-tas-tests,elastic-basic-auth + search-engine-type: elasticsearch + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 + with: + java-version: ${{ env.JAVA_VERSION }} + - name: "Build" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: | + bash ./scripts/ci/init.sh + bash ./scripts/ci/build.sh + - name: "Run tests" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: mvn -B install -ntp -pl ":content-repository-elasticsearch-test" -am -P${{ matrix.profiles }} -Denvironment=default -DrunBugs=false "-Dsearch.engine.type=${{ matrix.search-engine-type }}" + - name: "Clean Maven cache" + run: bash ./scripts/ci/cleanup_cache.sh + + upgrade_tas_tests: + name: Upgrade Elasticsearch TAS tests + runs-on: ubuntu-latest + if: > + !contains(github.event.head_commit.message, '[skip search]') && + !contains(github.event.head_commit.message, '[skip tests]') + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 + with: + java-version: ${{ env.JAVA_VERSION }} + - name: "Build" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: | + bash ./scripts/ci/init.sh + bash ./scripts/ci/build.sh + - name: "Configure AWS credentials" + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_S3_ACSLICENSE_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_S3_ACSLICENSE_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + - name: "Copy Licence" + run: aws s3 cp ${ALF_LICENCE_S3_PATH} ${ALF_LICENCE_LOCAL_PATH} + - name: "Run tests" + timeout-minutes: 30 + run: mvn -B install -ntp -pl ":content-repository-elasticsearch-test" -am -Pall-tas-tests,elastic-upgrade -Denvironment=default -DrunBugs=false "-Dsearch.engine.type=elasticsearch" + - name: "Clean Maven cache" + run: bash ./scripts/ci/cleanup_cache.sh + + all_amps_tests: + name: "All AMPs tests" + runs-on: ubuntu-latest + if: > + !contains(github.event.head_commit.message, '[skip tests]') + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 + with: + java-version: ${{ env.JAVA_VERSION }} + - name: "Build" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: | + bash ./scripts/ci/init.sh + bash ./scripts/ci/build.sh + - name: "Set up the environment" + run: mvn -B -q install -ntp -f tests/tas-all-amps/pom.xml -DskipTests -Pall-tas-tests,prepare-wars-with-amps + - name: "Run tests" + id: tests + timeout-minutes: 20 + env: + AWS_ACCESS_KEY: ${{ secrets.AWS_S3_PIPELINE_AMPS_ACCESS_KEY_ID }} + AWS_SECRET_KEY: ${{ secrets.AWS_S3_PIPELINE_AMPS_SECRET_ACCESS_KEY }} + run: | + ./tests/scripts/checkLibraryDuplicates.sh ./tests/tas-all-amps/target/war/alfresco/WEB-INF/lib + ${{ env.TAS_SCRIPTS }}/start-compose.sh ${{ env.TAS_ENVIRONMENT }}/docker-compose-all-amps-test.yml + ${{ env.TAS_SCRIPTS }}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" + mvn -B install -ntp -f tests/tas-all-amps/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false + - name: "Print output after failure" + if: ${{ always() && steps.tests.outcome == 'failure' }} + run: ${TAS_SCRIPTS}/output_logs_for_failures.sh "tests/tas-all-amps" + - name: "Clean Maven cache" + run: bash ./scripts/ci/cleanup_cache.sh + + distribution_zip_content_tests: + name: "Distribution Zip content tests" + runs-on: ubuntu-latest + if: > + !contains(github.event.head_commit.message, '[skip tests]') + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 + with: + java-version: ${{ env.JAVA_VERSION }} + - name: "Build" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: | + bash ./scripts/ci/init.sh + bash ./scripts/ci/build.sh + - name: "Set up the environment" + run: mvn -B -V clean install -ntp -Pags -DskipTests -Dmaven.javadoc.skip=true + - name: "Run tests" + id: tests + timeout-minutes: 20 + run: mvn -B install -ntp -f tests/tas-distribution-zip/pom.xml -Prun-distribution-zip-contents-check -DrunBugs=false + - name: "Print output after failure" + if: ${{ always() && steps.tests.outcome == 'failure' }} + run: ${TAS_SCRIPTS}/output_logs_for_failures.sh "tests/tas-distribution-zip" + - name: "Clean Maven cache" + run: bash ./scripts/ci/cleanup_cache.sh + + single_pipeline_image_tests: + name: "Single Pipeline image tests" + runs-on: ubuntu-latest + if: > + github.event_name != 'pull_request' && + !contains(github.event.head_commit.message, '[skip tests]') + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 + with: + java-version: ${{ env.JAVA_VERSION }} + - uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: "Build" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: | + bash ./scripts/ci/init.sh + bash ./scripts/ci/build.sh + - name: "Set up the environment" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + env: + AWS_ACCESS_KEY: ${{ secrets.AWS_S3_PIPELINE_AMPS_ACCESS_KEY_ID }} + AWS_SECRET_KEY: ${{ secrets.AWS_S3_PIPELINE_AMPS_SECRET_ACCESS_KEY }} + run: | + mvn -B clean install -ntp -Ppipeline,build-docker-images $(mvn -B -q help:evaluate "-Dexpression=dependency.alfresco-enterprise-repo.version" -DforceStdout | grep -q '\-SNAPSHOT$' && echo '-Drepo.image.tag=latest') $(mvn -B -q help:evaluate "-Dexpression=dependency.alfresco-enterprise-share.version" -DforceStdout | grep -q '\-SNAPSHOT$' && echo '-Dshare.image.tag=latest') + cat tests/pipeline-all-amps/repo/target/dtas/dtas-config.json + pip install requests pytest==6.2.4 pytest-testinfra==6.3.0 jmespath==0.10.0 + git clone --depth 1 --branch $DTAS_VERSION https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/Alfresco/alfresco-deployment-test-automation-scripts.git dtas + docker images | grep pipeline + ${TAS_SCRIPTS}/start-compose.sh ${TAS_ENVIRONMENT}/docker-compose-pipeline-all-amps.yml + ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8080/alfresco/" 180 + docker ps + curl -v --user admin.pipeline@alfresco.com:admin http://localhost:8080/alfresco/api/discovery + - name: "Run tests" + run: | + cd dtas + pytest --configuration ../tests/pipeline-all-amps/repo/target/dtas/dtas-config.json tests/ -s + - name: "Clean Maven cache" + run: bash ./scripts/ci/cleanup_cache.sh diff --git a/.github/workflows/master_release.yml b/.github/workflows/master_release.yml new file mode 100644 index 0000000000..f96ccad7ce --- /dev/null +++ b/.github/workflows/master_release.yml @@ -0,0 +1,214 @@ +name: Master/Release branch workflow + +on: + push: + branches: + - master + - release/** + schedule: + - cron: '0 5 * * 3' + +env: + JAVA_VERSION: "11" + AWS_REGION: eu-west-1 + GIT_USERNAME: ${{ secrets.BOT_GITHUB_USERNAME }} + GIT_EMAIL: ${{ secrets.BOT_GITHUB_EMAIL }} + GIT_PASSWORD: ${{ secrets.BOT_GITHUB_TOKEN }} + DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} + MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }} + QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }} + QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }} + GITHUB_ACTIONS_DEPLOY_TIMEOUT: 60 + BASE_BUILD_NUMBER: 10000 + # Release version has to start with real version (7.1.0-....) for the docker image to build successfully. + RELEASE_VERSION: 7.1.0.4 + DEVELOPMENT_VERSION: 7.1.0.5-SNAPSHOT + +jobs: + run_ci: + uses: ./.github/workflows/ci.yml + secrets: inherit + + docker_latest: + name: "Update latest and Single Pipeline - images" + runs-on: ubuntu-latest + needs: [run_ci] + if: > + !(failure() || cancelled()) && + !contains(github.event.head_commit.message, '[skip docker_latest]') && + github.ref_name == 'master' && github.event_name != 'pull_request' + services: + registry: + image: registry:2 + ports: + - 5000:5000 + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 + with: + java-version: ${{ env.JAVA_VERSION }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/amd64,linux/arm64 + - name: "Build" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: | + bash ./scripts/ci/init.sh + bash ./scripts/ci/build.sh + - name: Compute final build number + run: | + echo "COMPUTED_BUILD_NUMBER=$(( $BASE_BUILD_NUMBER + $BUILD_NUMBER ))" >> $GITHUB_ENV + - name: "Update images" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: mvn -B -V clean install -ntp -DskipTests -Dmaven.javadoc.skip=true -Dbuild-number=${COMPUTED_BUILD_NUMBER} -Pags -Ppush-docker-images,pipeline + - name: "Clean Maven cache" + run: bash ./scripts/ci/cleanup_cache.sh + + + release: + name: "Release and Copy to S3 Staging Bucket" + runs-on: ubuntu-latest + needs: [docker_latest] + if: > + !(failure() || cancelled()) && + contains(github.event.head_commit.message, '[release]') && + github.event_name != 'pull_request' + services: + registry: + image: registry:2 + ports: + - 5000:5000 + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 + with: + java-version: ${{ env.JAVA_VERSION }} + - uses: actions/setup-python@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: linux/amd64,linux/arm64 + - name: "Build" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: | + bash ./scripts/ci/init.sh + bash ./scripts/ci/build.sh + - uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v1.35.2 + with: + username: ${{ env.GIT_USERNAME }} + email: ${{ env.GIT_EMAIL }} + global: true + - name: Compute final build number + run: | + echo "COMPUTED_BUILD_NUMBER=$(( $BASE_BUILD_NUMBER + $BUILD_NUMBER ))" >> $GITHUB_ENV + - name: "Release" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: | + bash scripts/ci/verify_release_tag.sh + bash scripts/ci/maven_release.sh $COMPUTED_BUILD_NUMBER + bash scripts/ci/prepare_staging_deploy.sh + - name: "Clean Maven cache" + run: bash ./scripts/ci/cleanup_cache.sh + - name: "Configure AWS credentials" + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_S3_STAGING_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.AWS_S3_STAGING_SECRET_KEY }} + aws-region: ${{ env.AWS_REGION }} + - name: "Deploy to S3 Staging Bucket" + run: | + aws s3 cp --acl private --recursive ./deploy_dir s3://alfresco-artefacts-staging/alfresco-content-services/release/${BRANCH_NAME}/${COMPUTED_BUILD_NUMBER} + aws s3 cp --acl private --recursive ./deploy_dir_share s3://alfresco-artefacts-staging/share/${RELEASE_VERSION} + aws s3 cp --acl private --recursive ./deploy_dir_ags s3://alfresco-artefacts-staging/enterprise/RM/${RELEASE_VERSION} + + bash scripts/ci/copy_share_image_to_docker_hub.sh + + echo "Finished release and deployed to https://s3.console.aws.amazon.com/s3/buckets/alfresco-artefacts-staging/alfresco-content-services/release/${BRANCH_NAME}/${COMPUTED_BUILD_NUMBER}" + + publish: + name: "Copy to S3 Release Bucket" + runs-on: ubuntu-latest + needs: [release] + if: > + !(failure() || cancelled()) && + contains(github.event.head_commit.message, '[publish]') && + github.event_name != 'pull_request' + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + fetch-depth: 0 + - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 + with: + java-version: ${{ env.JAVA_VERSION }} + - name: "Init" + run: bash ./scripts/ci/init.sh + - uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v1.35.2 + with: + username: ${{ env.GIT_USERNAME }} + email: ${{ env.GIT_EMAIL }} + global: true + - name: "Rebuild the artifacts and publish them to enterprise-releases" + timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} + run: bash scripts/ci/maven_publish.sh + - name: "Configure AWS credentials" + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_S3_RELEASE_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_S3_RELEASE_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + - name: Compute final build number + run: | + echo "COMPUTED_BUILD_NUMBER=$(( $BASE_BUILD_NUMBER + $BUILD_NUMBER ))" >> $GITHUB_ENV + - name: "Deploy to S3 Release Bucket" + run: | + bash scripts/ci/copy_to_release_bucket.sh $COMPUTED_BUILD_NUMBER + bash scripts/ci/copy_share_to_release_bucket.sh + bash scripts/ci/copy_ags_to_release_bucket.sh + - name: "Clean Maven cache" + run: bash ./scripts/ci/cleanup_cache.sh + + update_downstream: + name: "Update acs-community-packaging (after release)" + runs-on: ubuntu-latest + needs: [publish] + if: > + !(failure() || cancelled()) && + (contains(github.event.head_commit.message, '[downstream]') || (contains(github.event.head_commit.message, '[release]') && + !contains(github.event.head_commit.message, '[no downstream]'))) && + github.event_name != 'pull_request' + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 + - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 + with: + java-version: ${{ env.JAVA_VERSION }} + - name: "Init" + run: bash ./scripts/ci/init.sh + - uses: Alfresco/alfresco-build-tools/.github/actions/configure-git-author@v1.35.2 + with: + username: ${{ env.GIT_USERNAME }} + email: ${{ env.GIT_EMAIL }} + global: true + - name: "Update downstream" + run: bash ./scripts/ci/update_downstream.sh + env: + COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + - name: "Clean Maven cache" + run: bash ./scripts/ci/cleanup_cache.sh diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh new file mode 100644 index 0000000000..080f2a4510 --- /dev/null +++ b/scripts/ci/build.sh @@ -0,0 +1,126 @@ +#!/usr/bin/env bash +echo "=========================== Starting Build Script ===========================" +PS4="\[\e[35m\]+ \[\e[m\]" +set -vex +pushd "$(dirname "${BASH_SOURCE[0]}")/../../" + +source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh" + +usage() { + echo "Builds the upstream projects first, then the current one." 1>&2; + echo 1>&2; + echo "Usage: $0 [-m]" 1>&2; + echo " -m: Flag to build Docker images with multi-architecture" 1>&2; + echo " -h: Display the usage information" 1>&2; + exit 1; +} + +while getopts "mh" option; do + case $option in + m) + DOCKER_BUILD_PROFILE=build-multiarch-docker-images + ;; + h) + usage + ;; + esac +done + +BUILD_PROFILE=${DOCKER_BUILD_PROFILE:-build-docker-images} + +ENT_DEPENDENCY_VERSION="$(retrievePomProperty "dependency.alfresco-enterprise-repo.version")" +REPO_IMAGE=$([[ "${ENT_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] && echo "-Drepo.image.tag=latest" || echo) + +# Either both the parent and the upstream dependency are the same, or else fail the build +if [ "${ENT_DEPENDENCY_VERSION}" != "$(retrievePomParentVersion)" ]; then + printf "Upstream dependency version (%s) is different then the project parent version!\n" "${ENT_DEPENDENCY_VERSION}" + exit 1 +fi + +# Prevent merging of any SNAPSHOT dependencies into the master or the release/* branches +if [[ $(isPullRequestBuild) && "${ENT_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ && "${BRANCH_NAME}" =~ ^master$|^release/.+$ ]] ; then + printf "PRs with SNAPSHOT dependencies are not allowed into master or release branches\n" + exit 1 +fi + +# Prevent release jobs from starting when there are SNAPSHOT upstream dependencies +if [[ "${ENT_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] && [ "${JOB_NAME,,}" = "release" ] ; then + printf "Cannot release project with SNAPSHOT dependencies!\n" + exit 1 +fi + +ENT_UPSTREAM_REPO="github.com/Alfresco/alfresco-enterprise-repo.git" + +# Checkout the upstream alfresco-enterprise-repo project (tag or branch) +if [[ "${ENT_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] ; then + pullSameBranch "${ENT_UPSTREAM_REPO}" +else + pullUpstreamTag "${ENT_UPSTREAM_REPO}" "${ENT_DEPENDENCY_VERSION}" +fi + +COM_DEPENDENCY_VERSION="$(retrievePomProperty "dependency.alfresco-community-repo.version" "${ENT_UPSTREAM_REPO}")" + +# Either both the parent and the upstream dependency are the same, or else fail the build +if [ "${COM_DEPENDENCY_VERSION}" != "$(retrievePomParentVersion "${ENT_UPSTREAM_REPO}")" ]; then + printf "Upstream dependency version (%s) is different then the project parent version!\n" "${COM_DEPENDENCY_VERSION}" + exit 1 +fi + +# Prevent merging of any SNAPSHOT dependencies into the master or the release/* branches +if [[ $(isPullRequestBuild) && "${COM_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ && "${BRANCH_NAME}" =~ ^master$|^release/.+$ ]] ; then + printf "PRs with SNAPSHOT dependencies are not allowed into master or release branches\n" + exit 1 +fi + +# Prevent release jobs from starting when there are SNAPSHOT upstream dependencies +if [[ "${COM_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] && [ "${JOB_NAME,,}" = "release" ] ; then + printf "Cannot release project with SNAPSHOT dependencies!\n" + exit 1 +fi + +COM_UPSTREAM_REPO="github.com/Alfresco/alfresco-community-repo.git" + +# Checkout the upstream alfresco-community-repo project (tag or branch; + build if the latter) +if [[ "${COM_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] ; then + pullAndBuildSameBranchOnUpstream "${COM_UPSTREAM_REPO}" "-Pags -Pall-tas-tests -Dlicense.failOnNotUptodateHeader=true" +else + pullUpstreamTag "${COM_UPSTREAM_REPO}" "${COM_DEPENDENCY_VERSION}" +fi + +# Build the upstream alfresco-enterprise-repo project with its docker image +if [[ "${ENT_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] ; then + buildSameBranchOnUpstream "${ENT_UPSTREAM_REPO}" "-P$BUILD_PROFILE -Pags -Pall-tas-tests -Dlicense.failOnNotUptodateHeader=true" +else + buildUpstreamTag "${ENT_UPSTREAM_REPO}" "${ENT_DEPENDENCY_VERSION}" "-P$BUILD_PROFILE -Pags -Pall-tas-tests -Dlicense.failOnNotUptodateHeader=true" +fi + +SHARE_DEPENDENCY_VERSION="$(retrievePomProperty "dependency.alfresco-enterprise-share.version")" +SHARE_IMAGE=$([[ "${SHARE_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] && echo "-Dshare.image.tag=latest" || echo) + +# Prevent merging of any SNAPSHOT dependencies into the master or the release/* branches +if [[ $(isPullRequestBuild) && "${SHARE_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ && "${BRANCH_NAME}" =~ ^master$|^release/.+$ ]] ; then + printf "PRs with SNAPSHOT dependencies are not allowed into master or release branches\n" + exit 1 +fi + +# Prevent release jobs from starting when there are SNAPSHOT upstream dependencies +if [[ "${SHARE_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] && [ "${JOB_NAME,,}" = "release" ] ; then + printf "Cannot release project with SNAPSHOT dependencies!\n" + exit 1 +fi + +SHARE_UPSTREAM_REPO="github.com/Alfresco/alfresco-enterprise-share.git" +# Checkout the upstream alfresco-enterprise-share project (tag or branch; + build if the latter) +if [[ "${SHARE_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] ; then + pullAndBuildSameBranchOnUpstream "${SHARE_UPSTREAM_REPO}" "-P$BUILD_PROFILE -Pags -Dlicense.failOnNotUptodateHeader=true -Ddocker.quay-expires.value=NEVER ${REPO_IMAGE} -Ddependency.alfresco-community-repo.version=${COM_DEPENDENCY_VERSION} -Ddependency.alfresco-enterprise-repo.version=${ENT_DEPENDENCY_VERSION}" +else + pullUpstreamTagAndBuildDockerImage "${SHARE_UPSTREAM_REPO}" "${SHARE_DEPENDENCY_VERSION}" "-P$BUILD_PROFILE -Pags -Dlicense.failOnNotUptodateHeader=true -Ddocker.quay-expires.value=NEVER -Ddependency.alfresco-community-repo.version=${COM_DEPENDENCY_VERSION} -Ddependency.alfresco-enterprise-repo.version=${ENT_DEPENDENCY_VERSION}" +fi + +# Build the current project +mvn -B -ntp -V -q install -DskipTests -Dmaven.javadoc.skip=true -P${BUILD_PROFILE} -Pags ${REPO_IMAGE} ${SHARE_IMAGE} + +popd +set +vex +echo "=========================== Finishing Build Script ==========================" + diff --git a/scripts/ci/build_functions.sh b/scripts/ci/build_functions.sh new file mode 100644 index 0000000000..ad072ccb81 --- /dev/null +++ b/scripts/ci/build_functions.sh @@ -0,0 +1,222 @@ +#!/usr/bin/env bash +set +vx + +function isPullRequestBuild() { + test "${PULL_REQUEST}" != "false" +} + +function isBranchBuild() { + test "${PULL_REQUEST}" = "false" +} + +function cloneRepo() { + local REPO="${1}" + local TAG_OR_BRANCH="${2}" + + printf "Cloning \"%s\" on %s\n" "${TAG_OR_BRANCH}" "${REPO}" + + # clone the repository branch/tag + pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" >/dev/null + + rm -rf "$(basename "${REPO%.git}")" + + git clone -b "${TAG_OR_BRANCH}" --depth=1 "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REPO}" + + popd >/dev/null +} + +function retrievePomParentVersion() { + local REPO="${1}" + + if [ -z "${REPO}" ]; then + pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null + else + pushd "$(dirname "${BASH_SOURCE[0]}")/../../../$(basename "${REPO%.git}")" >/dev/null + fi + + sed -n '//,/<\/parent>/p' pom.xml \ + | sed -n '//,/<\/version>/p' \ + | tr -d '\n' \ + | grep -oP '(?<=).*(?=)' \ + | xargs + + popd >/dev/null +} + +function retrievePomProperty() { + local KEY="${1}" + local REPO="${2}" + + if [ -z "${REPO}" ]; then + pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null + else + pushd "$(dirname "${BASH_SOURCE[0]}")/../../../$(basename "${REPO%.git}")" >/dev/null + fi + + sed -n '//,/<\/properties>/p' pom.xml \ + | sed -n "/<${KEY}>/,/<\/${KEY}>/p" \ + | tr -d '\n' \ + | grep -oP "(?<=<${KEY}>).*(?=)" \ + | xargs + + popd >/dev/null +} + +function evaluatePomProperty() { + local KEY="${1}" + + pushd "$(dirname "${BASH_SOURCE[0]}")/../../" >/dev/null + + mvn -B -ntp -q help:evaluate -Dexpression="${KEY}" -DforceStdout + + popd >/dev/null +} + +function remoteBranchExists() { + local REMOTE_REPO="${1}" + local BRANCH="${2}" + + git ls-remote --exit-code --heads "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REMOTE_REPO}" "${BRANCH_NAME}" &>/dev/null +} + +function identifyUpstreamSourceBranch() { + local UPSTREAM_REPO="${1}" + + # otherwise use the current branch name (or in case of PRs, the target branch name) + if remoteBranchExists "${UPSTREAM_REPO}" "${BRANCH_NAME}" ; then + echo "${BRANCH_NAME}" + exit 0 + fi + + # if none of the previous exists, use the "master" branch + echo "master" +} + +function pullUpstreamTag() { + local UPSTREAM_REPO="${1}" + local TAG="${2}" + + cloneRepo "${UPSTREAM_REPO}" "${TAG}" +} + +function pullSameBranch() { + local UPSTREAM_REPO="${1}" + + local SOURCE_BRANCH="$(identifyUpstreamSourceBranch "${UPSTREAM_REPO}")" + + cloneRepo "${UPSTREAM_REPO}" "${SOURCE_BRANCH}" +} + +function buildUpstreamTag() { + local UPSTREAM_REPO="${1}" + local TAG="${2}" + local EXTRA_BUILD_ARGUMENTS="${3}" + + pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" + + cd "$(basename "${UPSTREAM_REPO%.git}")" + + mvn -B -ntp -V clean package -DskipTests -Dmaven.javadoc.skip=true "-Dimage.tag=${TAG}" ${EXTRA_BUILD_ARGUMENTS} + + popd +} + +function buildSameBranchOnUpstream() { + local UPSTREAM_REPO="${1}" + local EXTRA_BUILD_ARGUMENTS="${2}" + + pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" + + cd "$(basename "${UPSTREAM_REPO%.git}")" + + mvn -B -ntp -V -q clean install -DskipTests -Dmaven.javadoc.skip=true ${EXTRA_BUILD_ARGUMENTS} + mvn -B -ntp -V -q install -DskipTests -f packaging/tests/pom.xml + + popd +} + +function pullUpstreamTagAndBuildDockerImage() { + local UPSTREAM_REPO="${1}" + local TAG="${2}" + local EXTRA_BUILD_ARGUMENTS="${3}" + + cloneRepo "${UPSTREAM_REPO}" "${TAG}" + + pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" + + cd "$(basename "${UPSTREAM_REPO%.git}")" + + mvn -B -ntp -V clean package -DskipTests -Dmaven.javadoc.skip=true "-Dimage.tag=${TAG}" ${EXTRA_BUILD_ARGUMENTS} + + popd +} + +function pullAndBuildSameBranchOnUpstream() { + local UPSTREAM_REPO="${1}" + local EXTRA_BUILD_ARGUMENTS="${2}" + + local SOURCE_BRANCH="$(identifyUpstreamSourceBranch "${UPSTREAM_REPO}")" + + cloneRepo "${UPSTREAM_REPO}" "${SOURCE_BRANCH}" + + pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" + + cd "$(basename "${UPSTREAM_REPO%.git}")" + + mvn -B -ntp -V -q clean install -DskipTests -Dmaven.javadoc.skip=true ${EXTRA_BUILD_ARGUMENTS} + mvn -B -ntp -V -q install -DskipTests -f packaging/tests/pom.xml + + popd +} + +function retieveLatestTag() { + local REPO="${1}" + local BRANCH="${2}" + + local LOCAL_PATH="/tmp/$(basename "${REPO%.git}")" + + git clone -q -b "${BRANCH_NAME}" "https://${GIT_USERNAME}:${GIT_PASSWORD}@${REPO}" "${LOCAL_PATH}" + + pushd "${LOCAL_PATH}" >/dev/null + git describe --abbrev=0 --tags + popd >/dev/null + + rm -rf "${LOCAL_PATH}" +} + +function copyArtifactToAnotherRepo() { + local GROUP_ID="${1}" + local ARTIFACT_ID="${2}" + local VERSION="${3}" + local PACKAGING="${4}" + local SETTINGS_SERVER_ID="${5}" + local NEXUS_REPO="${6}" + + local ARTIFACT_PATH="$(echo ${GROUP_ID}/${ARTIFACT_ID} | sed 's/\./\//g')" + local LOCAL_PATH="${HOME}/.m2/repository/${ARTIFACT_PATH}" + local TMP_PATH="/tmp/${ARTIFACT_ID}" + + # Download the artifact. Make sure we are not using a cached version + rm -rf "${LOCAL_PATH}" + mvn org.apache.maven.plugins:maven-dependency-plugin:get \ + -Dartifact=${GROUP_ID}:${ARTIFACT_ID}:${VERSION}:${PACKAGING} \ + -Dtransitive=false + ls -l "${LOCAL_PATH}/${VERSION}" + + # The local maven repo must not contain the downloaded artifacts otherwise the upload can fail + rm -rf "${TMP_PATH}" + mv "${LOCAL_PATH}/${VERSION}" "${TMP_PATH}" + + # Upload the artifact + mvn deploy:deploy-file \ + -Dfile="${TMP_PATH}/${ARTIFACT_ID}-${VERSION}.${PACKAGING}" \ + -DrepositoryId=${SETTINGS_SERVER_ID} \ + -Durl="${NEXUS_REPO}" \ + -DgroupId="${GROUP_ID}" \ + -DartifactId="${ARTIFACT_ID}" \ + -Dversion="${VERSION}" \ + -Dpackaging=${PACKAGING} +} + + +set -vx diff --git a/scripts/ci/cleanup_cache.sh b/scripts/ci/cleanup_cache.sh new file mode 100644 index 0000000000..33b940e2cd --- /dev/null +++ b/scripts/ci/cleanup_cache.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -ev + +rm -rf "${HOME}/.m2/repository/org/alfresco/acs-community-packaging" +rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-community-repo" +rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-community-repo-*" +rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-core" +rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-data-model" +rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-enterprise-remote-api" +rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-enterprise-repo-*" +rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-enterprise-repository" +rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-remote-api" +rm -rf "${HOME}/.m2/repository/org/alfresco/alfresco-repository" +rm -rf "${HOME}/.m2/repository/org/alfresco/content-services" +rm -rf "${HOME}/.m2/repository/org/alfresco/content-services*" +rm -rf "${HOME}/.m2/repository/org/alfresco/content-services-community" +rm -rf "${HOME}/.m2/repository/org/alfresco/tas/alfresco-community-repo-*-test" +rm -rf "${HOME}/.m2/repository/org/alfresco/tas/alfresco-enterprise-repo-*-test" + diff --git a/scripts/ci/copy_ags_to_release_bucket.sh b/scripts/ci/copy_ags_to_release_bucket.sh new file mode 100644 index 0000000000..bc27aef847 --- /dev/null +++ b/scripts/ci/copy_ags_to_release_bucket.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +echo "=========================== Starting Copy to Release Bucket Script ===========================" +PS4="\[\e[35m\]+ \[\e[m\]" +set -vex + +# +# Copy from S3 Release bucket to S3 eu.dl bucket +# + +if [ -z "${RELEASE_VERSION}" ]; then + echo "Please provide a RELEASE_VERSION in the format - (e.g. 7.1.0-A2)" + exit 1 +fi + +SOURCE="s3://alfresco-artefacts-staging/enterprise/RM/${RELEASE_VERSION}" +DESTINATION="s3://eu.dl.alfresco.com/release/enterprise/RM/${RELEASE_VERSION}" + +printf "\n%s\n%s\n" "${SOURCE}" "${DESTINATION}" + +aws s3 cp --acl private --recursive --copy-props none "${SOURCE}" "${DESTINATION}" + +set +vex +echo "=========================== Finishing Copy to Release Bucket Script ==========================" diff --git a/scripts/ci/copy_share_image_to_docker_hub.sh b/scripts/ci/copy_share_image_to_docker_hub.sh new file mode 100644 index 0000000000..44c43d17ec --- /dev/null +++ b/scripts/ci/copy_share_image_to_docker_hub.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +echo "=========================== Starting Copy Share Image To Dockerhub Script ===========================" +PS4="\[\e[35m\]+ \[\e[m\]" +set +e -v -x +pushd "$(dirname "${BASH_SOURCE[0]}")/../" + +# +# Copy Image from Quay to dockerhub +# + +TAG_NAME=${RELEASE_VERSION} +SOURCE_IMAGE=quay.io/alfresco/alfresco-share +TARGET_IMAGE=docker.io/alfresco/alfresco-share + +echo "${QUAY_PASSWORD}" | docker login -u="${QUAY_USERNAME}" --password-stdin quay.io +echo "${DOCKERHUB_PASSWORD}" | docker login -u="${DOCKERHUB_USERNAME}" --password-stdin docker.io + +docker buildx imagetools create -t $TARGET_IMAGE:$TAG_NAME $SOURCE_IMAGE:$TAG_NAME + +popd +set +vex +echo "=========================== Finishing Copy Share Image To Dockerhub Script ==========================" + +exit ${SUCCESS} \ No newline at end of file diff --git a/scripts/ci/copy_share_to_release_bucket.sh b/scripts/ci/copy_share_to_release_bucket.sh new file mode 100644 index 0000000000..7b515d6ea1 --- /dev/null +++ b/scripts/ci/copy_share_to_release_bucket.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +echo "=========================== Starting Copy to Release Bucket Script ===========================" +PS4="\[\e[35m\]+ \[\e[m\]" +set -vex + +# +# Copy from S3 Release bucket to S3 eu.dl bucket +# + +if [ -z "${RELEASE_VERSION}" ]; then + echo "Please provide a RELEASE_VERSION in the format - (e.g. 7.1.0-A2)" + exit 1 +fi + +SOURCE="s3://alfresco-artefacts-staging/share/${RELEASE_VERSION}" +DESTINATION="s3://eu.dl.alfresco.com/release/share/${RELEASE_VERSION}" + +printf "\n%s\n%s\n" "${SOURCE}" "${DESTINATION}" + +aws s3 cp --acl private --recursive --copy-props none "${SOURCE}" "${DESTINATION}" + +set +vex +echo "=========================== Finishing Copy to Release Bucket Script ==========================" diff --git a/scripts/ci/copy_to_release_bucket.sh b/scripts/ci/copy_to_release_bucket.sh new file mode 100755 index 0000000000..cad3beb817 --- /dev/null +++ b/scripts/ci/copy_to_release_bucket.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +echo "=========================== Starting Copy to Release Bucket Script ===========================" +PS4="\[\e[35m\]+ \[\e[m\]" +set -vex + +BUILD_NUMBER=$1 + +# +# Copy from S3 Release bucket to S3 eu.dl bucket +# + +if [ -z "${RELEASE_VERSION}" ]; then + echo "Please provide a RELEASE_VERSION in the format - (e.g. 7.1.0-A2)" + exit 1 +fi + +SOURCE="s3://alfresco-artefacts-staging/alfresco-content-services/release/${BRANCH_NAME}/${BUILD_NUMBER}" +DESTINATION="s3://eu.dl.alfresco.com/release/enterprise/ACS/${RELEASE_VERSION:0:3}/${RELEASE_VERSION}/${BUILD_NUMBER}" + +printf "\n%s\n%s\n" "${SOURCE}" "${DESTINATION}" + +aws s3 cp --acl private --recursive --copy-props none "${SOURCE}" "${DESTINATION}" + +set +vex +echo "=========================== Finishing Copy to Release Bucket Script ==========================" diff --git a/scripts/ci/init.sh b/scripts/ci/init.sh new file mode 100644 index 0000000000..3e1b8eb234 --- /dev/null +++ b/scripts/ci/init.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +echo "=========================== Starting Init Script ===========================" +PS4="\[\e[35m\]+ \[\e[m\]" +set -vex +pushd "$(dirname "${BASH_SOURCE[0]}")/../../" + +# Maven Setup +find "${HOME}/.m2/repository/" -type d -name "*-SNAPSHOT*" | xargs -r -l rm -rf + +# Docker Logins +echo "${DOCKERHUB_PASSWORD}" | docker login -u="${DOCKERHUB_USERNAME}" --password-stdin +echo "${QUAY_PASSWORD}" | docker login -u="${QUAY_USERNAME}" --password-stdin quay.io + +# Git Setup +# This avoids the build failing due to messages about line endings. +git config --global core.safecrlf false + +popd +set +vex +echo "=========================== Finishing Init Script ==========================" + diff --git a/scripts/ci/maven_publish.sh b/scripts/ci/maven_publish.sh new file mode 100755 index 0000000000..d83dbba890 --- /dev/null +++ b/scripts/ci/maven_publish.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +echo "=========================== Starting Publish Script ===========================" +# Republishes the maven artifacts in the Enterprise Releases repository. + +PS4="\[\e[35m\]+ \[\e[m\]" +set -vex +pushd "$(dirname "${BASH_SOURCE[0]}")/../../" + +source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh" + +if [ -z "${RELEASE_VERSION}" ]; then + echo "Please provide a Release version in the format - (e.g. 7.1.0-A2)" + exit 1 +fi + +# Checkout the tag. +git checkout "${RELEASE_VERSION}" + +# Rebuild the artifacts and publish them to enterprise-releases. +mvn -B \ + -ntp \ + -Ppublish,all-tas-tests,pipeline,ags \ + -DaltDeploymentRepository=alfresco-enterprise-releases::default::https://artifacts.alfresco.com/nexus/content/repositories/enterprise-releases \ + -DskipTests \ + clean deploy + +popd +set +vex +echo "=========================== Finishing Release Script ==========================" + + diff --git a/scripts/ci/maven_release.sh b/scripts/ci/maven_release.sh new file mode 100755 index 0000000000..9346df8518 --- /dev/null +++ b/scripts/ci/maven_release.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +echo "=========================== Starting Release Script ===========================" +PS4="\[\e[35m\]+ \[\e[m\]" +set -vex + +BUILD_NUMBER=$1 + +pushd "$(dirname "${BASH_SOURCE[0]}")/../../" + +source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh" + +if [ -z "${RELEASE_VERSION}" ] || [ -z "${DEVELOPMENT_VERSION}" ]; then + echo "Please provide a Release and Development version in the format - (e.g. 7.1.0-A2)" + exit 1 +fi + +# Use full history for release +git checkout -B "${BRANCH_NAME}" + +mvn -B \ + -ntp \ + -Prelease,all-tas-tests,pipeline -Pags \ + -DreleaseVersion="${RELEASE_VERSION}" \ + -DdevelopmentVersion="${DEVELOPMENT_VERSION}" \ + "-Darguments=-Prelease,all-tas-tests,pipeline -Pags -DskipTests -Dbuild-number=${BUILD_NUMBER}" \ + release:clean release:prepare release:perform \ + -DscmCommentPrefix="[maven-release-plugin][skip ci] " \ + -Dusername="${GIT_USERNAME}" \ + -Dpassword="${GIT_PASSWORD}" + + + +# The alfresco-content-services-share-distribution was in the Nexus 'Releases' repository prior to 7.1.0, which was visible to Community. +copyArtifactToAnotherRepo org.alfresco alfresco-content-services-share-distribution ${RELEASE_VERSION} zip \ + alfresco-enterprise-releases https://nexus.alfresco.com/nexus/content/repositories/releases/ + +popd +set +vex +echo "=========================== Finishing Release Script ==========================" + diff --git a/scripts/ci/prepare_staging_deploy.sh b/scripts/ci/prepare_staging_deploy.sh new file mode 100755 index 0000000000..d0ceccd0b9 --- /dev/null +++ b/scripts/ci/prepare_staging_deploy.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +echo "========================== Starting Prepare Staging Deploy Script ===========================" +PS4="\[\e[35m\]+ \[\e[m\]" +set -vex +pushd "$(dirname "${BASH_SOURCE[0]}")/../../" + +# Identify latest annotated tag (latest version) +export VERSION=$(git describe --abbrev=0 --tags) + +# Get third party license scripts. +git clone --depth=1 https://github.com/Alfresco/third-party-license-overrides.git + +# Move the final artifacts to a single folder (deploy_dir) to be copied to S3 +mkdir -p deploy_dir +cp distribution/target/alfresco.war deploy_dir +cp distribution/target/*-distribution*.zip deploy_dir +# Create third party license csv file and add it to the deploy directory. +unzip deploy_dir/*-distribution*.zip -d deploy_dir/acs +zippaths="" +for file in `find deploy_dir/acs -name "*.amp" -o -name "*.war" -not -name "ROOT.war" -not -name "_vti_bin.war"` +do + zippaths+="$file|" +done +zippaths=${zippaths::-1} +python3 ./third-party-license-overrides/thirdPartyLicenseCSVCreator.py --zippaths "${zippaths}" --version "${VERSION}" --combined --output "deploy_dir" +rm -rf deploy_dir/acs +echo "Local deploy directory content:" +ls -lA deploy_dir + +# Create deploy directory for Share. +mkdir -p deploy_dir_share +cp distribution-share/target/*.war deploy_dir_share +cp distribution-share/target/*.zip deploy_dir_share +# Generate third party license csv for Share. +python3 ./third-party-license-overrides/thirdPartyLicenseCSVCreator.py --zip deploy_dir_share/*.war --version "${VERSION}" --combined --output "deploy_dir_share" +echo "Local Share deploy directory content:" +ls -lA deploy_dir_share + +# Create deploy directory for AGS. +mkdir -p deploy_dir_ags +cp distribution-ags/target/*.zip deploy_dir_ags +# Generate third party license csv for AGS. +unzip deploy_dir_ags/*.zip -d deploy_dir_ags/ags +zippaths="" +for file in `find deploy_dir_ags/ags -name "*.amp" -o -name "*.war"` +do + zippaths+="$file|" +done +zippaths=${zippaths::-1} +python3 ./third-party-license-overrides/thirdPartyLicenseCSVCreator.py --zippaths ${zippaths} --version "${VERSION}" --combined --output "deploy_dir_ags" +rm -rf deploy_dir_ags/ags +echo "Local AGS deploy directory content:" +ls -lA deploy_dir_ags + +# Tidy up. +rm -rf ./third-party-license-overrides + +popd +set +vex +echo "========================== Finishing Prepare Staging Deploy Script ==========================" diff --git a/scripts/ci/source_clear.sh b/scripts/ci/source_clear.sh new file mode 100644 index 0000000000..62d1568bc8 --- /dev/null +++ b/scripts/ci/source_clear.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +echo "=========================== Starting SourceClear Script ===========================" +PS4="\[\e[35m\]+ \[\e[m\]" +set +e -v -x +pushd "$(dirname "${BASH_SOURCE[0]}")/../../" + +mvn -B -ntp -q clean install \ + -DskipTests \ + -Dmaven.javadoc.skip=true \ + com.srcclr:srcclr-maven-plugin:scan \ + -Dcom.srcclr.apiToken=${SRCCLR_API_TOKEN} > scan.log + +SUCCESS=$? # this will read exit code of the previous command + +if [ -z "$VERACODE_FAILS_BUILD" ] || [ "$VERACODE_FAILS_BUILD" = false ] ; then + SUCCESS=0 +fi + +cat scan.log | grep -e 'Full Report Details' -e 'Failed' + +popd +set +vex +echo "=========================== Finishing SourceClear Script ==========================" + +exit ${SUCCESS} \ No newline at end of file diff --git a/scripts/ci/update_downstream.sh b/scripts/ci/update_downstream.sh new file mode 100644 index 0000000000..05ad5494a4 --- /dev/null +++ b/scripts/ci/update_downstream.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash +echo "=========================== Starting Update Downstream Script ===========================" +PS4="\[\e[35m\]+ \[\e[m\]" +set -vex +pushd "$(dirname "${BASH_SOURCE[0]}")/../../" + +source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh" + +#Fetch the latest changes, as GHA will only checkout the PR commit +git fetch origin "${BRANCH_NAME}" +git checkout "${BRANCH_NAME}" +git pull + +# Retrieve the latest (just released) latest tag on the current branch +VERSION="$(git describe --abbrev=0 --tags)" + +# Retrieve the Community Repo version +COM_VERSION="$(evaluatePomProperty "dependency.alfresco-community-repo.version")" + +# Retrieve the Enterprise Share version +SHA_VERSION="$(evaluatePomProperty "dependency.alfresco-enterprise-share.version")" + +# Retrieve the release and development versions as they are normally the same in community packaging +RELEASE_VERSION=$(grep RELEASE_VERSION: .github/workflows/master_release.yml | sed 's/.*RELEASE_VERSION: \(.*\)/\1/') +DEVELOPMENT_VERSION=$(grep DEVELOPMENT_VERSION: .github/workflows/master_release.yml | sed 's/.*DEVELOPMENT_VERSION: \(.*\)/\1/') + +DOWNSTREAM_REPO="github.com/Alfresco/acs-community-packaging.git" + +cloneRepo "${DOWNSTREAM_REPO}" "${BRANCH_NAME}" + +cd "$(dirname "${BASH_SOURCE[0]}")/../../../$(basename "${DOWNSTREAM_REPO%.git}")" + +# Update parent version +mvn -B versions:update-parent versions:commit "-DparentVersion=[${COM_VERSION}]" + +# Update dependency version +mvn -B versions:set-property versions:commit \ + -Dproperty=dependency.alfresco-community-repo.version \ + "-DnewVersion=${COM_VERSION}" + +mvn -B versions:set-property versions:commit \ + -Dproperty=dependency.alfresco-community-share.version \ + "-DnewVersion=${SHA_VERSION}" + +mvn -B versions:set-property versions:commit \ + -Dproperty=dependency.acs-packaging.version \ + "-DnewVersion=${VERSION}" + +sed -i "s/.*RELEASE_VERSION: .*/ RELEASE_VERSION: $RELEASE_VERSION/" .github/workflows/ci.yml +sed -i "s/.*DEVELOPMENT_VERSION: .*/ DEVELOPMENT_VERSION: $DEVELOPMENT_VERSION/" .github/workflows/ci.yml + +set +e +echo "${COMMIT_MESSAGE}" | grep '\[publish\]' +if [ "$?" -eq 0 ] +then + COMMIT_DIRECTIVES="[release][publish]" +else + COMMIT_DIRECTIVES="[release]" +fi +set -e +# Commit changes +git status +git --no-pager diff pom.xml +git add pom.xml +git --no-pager diff pom.xml +git add .github/workflows/ci.yml + +if git status --untracked-files=no --porcelain | grep -q '^' ; then + git commit -m "${COMMIT_DIRECTIVES} ${VERSION} + + Update upstream versions + - alfresco-community-repo: ${COM_VERSION} + - alfresco-enterprise-share: ${SHA_VERSION} + - acs-packaging: ${VERSION} + - RELEASE_VERSION: ${RELEASE_VERSION} + - DEVELOPMENT_VERSION: ${DEVELOPMENT_VERSION}" + git push +else + echo "Dependencies are already up to date." + git status +fi + + +popd +set +vex +echo "=========================== Finishing Update Downstream Script ==========================" + diff --git a/scripts/ci/verify_release_tag.sh b/scripts/ci/verify_release_tag.sh new file mode 100755 index 0000000000..e0a9a1efa3 --- /dev/null +++ b/scripts/ci/verify_release_tag.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +echo "=========================== Starting Verify Release Tag Script ===========================" +PS4="\[\e[35m\]+ \[\e[m\]" +set -vex +pushd "$(dirname "${BASH_SOURCE[0]}")/../../" + +# +# Check that the version to be released does not already have a docker tag. +# + +if [ -z "${RELEASE_VERSION}" ]; then + echo "Please provide a RELEASE_VERSION in the format - (e.g. 7.1.0-A2)" + exit 1 +fi + +if git rev-parse "${RELEASE_VERSION}^{tag}" &>/dev/null ; then + echo "The RELEASE_VERSION tag \"${RELEASE_VERSION}\" already exists in the git project" + exit 1 +fi + +# get the image name from the pom file +ALFRESCO_DOCKER_IMAGE="$(mvn -B -q help:evaluate -f ./docker-alfresco/pom.xml -Dexpression=image.name -DforceStdout)" +DOCKER_IMAGE_FULL_NAME="${ALFRESCO_DOCKER_IMAGE}:${RELEASE_VERSION}" + +function docker_image_exists() { + local IMAGE_FULL_NAME="${1}"; shift + local WAIT_TIME="${1:-5}" + local SEARCH_TERM='Pulling|is up to date|not found' + + echo "Looking to see if ${IMAGE_FULL_NAME} already exists..." + local RESULT=$( (timeout --preserve-status "${WAIT_TIME}" docker 2>&1 pull "${IMAGE_FULL_NAME}" &) | grep -v 'Pulling repository' | grep -E -o "${SEARCH_TERM}") + + test "${RESULT}" || { echo "Timed out too soon. Try using a wait_time greater than ${WAIT_TIME}..."; return 1 ;} + if echo "${RESULT}" | grep -vq 'not found'; then + true + else + false + fi +} + +if docker_image_exists "${DOCKER_IMAGE_FULL_NAME}" ; then + echo "Tag ${RELEASE_VERSION} already pushed, release process will interrupt." + exit 1 +else + echo "The ${RELEASE_VERSION} tag was not found" +fi + + +popd +set +vex +echo "=========================== Finishing Verify Release Tag Script ==========================" + diff --git a/scripts/dev/find-fix.py b/scripts/dev/find-fix.py new file mode 100755 index 0000000000..beb8653e5d --- /dev/null +++ b/scripts/dev/find-fix.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import argparse, os, re, subprocess +from collections import defaultdict + +script_path = os.path.dirname(os.path.realpath(__file__)) +root_dir = os.path.dirname(os.path.dirname(os.path.dirname(script_path))) + +projects = ['alfresco-community-repo', 'alfresco-enterprise-repo', 'alfresco-enterprise-share', 'acs-community-packaging', 'acs-packaging'] +project_dependencies = {'alfresco-community-repo': ['alfresco-enterprise-repo', 'acs-community-packaging'], 'alfresco-enterprise-repo': ['acs-packaging'], 'alfresco-enterprise-share': ['acs-packaging']} +project_dir = {project: os.path.join(root_dir, project) for project in projects} +version_string = {project: '{{}}'.format(project) for project in projects} + +parser = argparse.ArgumentParser(description='Find the tags that contain commits referencing a ticket.') +parser.add_argument('-j', '--jira', help='The ticket number to search for.', required=True) +parser.add_argument('-a', '--all', action='store_true', help='Display all releases containing fix.') +parser.add_argument('-r', '--release', action='store_true', help='Only consider full releases.') +parser.add_argument('-p', '--packaged', action='store_true', help='Include information about how the commit is packaged.') +parser.add_argument('-s', '--skipfetch', action='store_true', help='Skip the git fetch step - only include commits that are stored locally.') +args = parser.parse_args() + +# The filter to use to avoid considering test tags. +version_filter = r'^[0-9]+(\.[0-9]+)*$' if args.release else r'^[0-9]+(\.[0-9]+)*(-(A|M|RC)[0-9]+)?$' + +def run_command(command_parts, project): + """Run the command and return the output string.""" + output = subprocess.run(command_parts, cwd=project_dir[project], capture_output=True) + return output.stdout.decode('utf-8') + +def run_list_command(command_parts, project): + """Run the command and return the lines of the output as a list of strings.""" + output = run_command(command_parts, project).strip().split('\n') + if '' in output: + output.remove('') + return output + +def compare_version_part(a_part, b_part): + """Compare two parts of a version number and return the difference (taking into account + versions like 7.0.0-M1).""" + try: + a_bits = a_part.split('-') + b_bits = b_part.split('-') + version_difference = int(a_bits[0]) - int(b_bits[0]) + if version_difference != 0 or (len(a_bits) == 1 and len(b_bits) == 1): + return version_difference + if len(a_bits) != len(b_bits): + # Fewer parts indicates a later version (e.g. '7.0.0' is later than '7.0.0-M1') + return len(b_bits) - len(a_bits) + # If letter doesn't match then we can't compare the versions. + a_letter = a_bits[1][0] + b_letter = b_bits[1][0] + if a_letter != b_letter: + return 0 + # Try to get number from after M, A or RC and compare this. + a_number_start = [char.isdigit() for char in a_bits[1]].index(True) + b_number_start = [char.isdigit() for char in b_bits[1]].index(True) + return int(a_bits[1][a_number_start:]) - int(b_bits[1][b_number_start:]) + except ValueError: + # If the strings aren't in the format we're expecting then we can't compare them. + return 0 + +def tag_before(tag_a, tag_b): + """Return True if the version number from tag_a is lower than tag_b.""" + a_parts = list(tag_a.split('.')) + b_parts = list(tag_b.split('.')) + for part_index, b_part in enumerate(b_parts): + if len(a_parts) <= part_index: + return True + difference = compare_version_part(a_parts[part_index], b_part) + if difference < 0: + return True + elif difference > 0: + return False + return len(a_parts) <= len(b_parts) + +def reduce_tags(tags): + """Filter a set of tags to return only those that aren't descendents from others in the list.""" + reduced_tags = [] + for tag_a in tags: + include = True + for tag_b in tags: + if tag_a == tag_b: + continue + if not tag_before(tag_a, tag_b): + include = False + break + if include: + reduced_tags.append(tag_a) + return reduced_tags + +def find_tags_containing(project, commit): + """Find all tags containing the given commit. Returns the full list and a condensed list (excluding tags 'after' other tags in the list).""" + tags = run_list_command(['git', 'tag', '--contains', commit], project) + # The packaging projects had a different format for older tags. + if project in ['acs-packaging', 'acs-community-packaging']: + # Remove the prefix 'acs-packaging-' if it's present. + tags = list(map(lambda tag: tag.replace('{}-'.format(project), ''), tags)) + # Exclude tags that aren't just chains of numbers with an optional suffix. + tags = list(filter(lambda tag: re.match(version_filter, tag), tags)) + # Filter out tags that are before other tags. + reduced_tags = reduce_tags(tags) + return tags, reduced_tags + +for project in projects: + if not args.skipfetch: + run_command(['git', 'fetch'], project) + commits = run_list_command(['git', 'rev-list', '--all', '--grep', args.jira], project) + for original_commit in commits: + tags, reduced_tags = find_tags_containing(project, original_commit) + tag_info = ', '.join(tags if args.all else reduced_tags) + packaging_info = '' + if args.packaged: + pairs = [(project, tag) for tag in reduced_tags] + packaged = defaultdict(set) + while pairs: + dependency, tag = pairs.pop() + if dependency not in project_dependencies.keys(): + packaged[dependency].add(tag) + else: + # Try to find pairs from next project up. + for ancestor_project in project_dependencies[dependency]: + commits = run_list_command(['git', 'log', '--all', '--pretty=format:%h', '-S', version_string[dependency].format(tag), '--', 'pom.xml'], ancestor_project) + for commit in commits: + _, found_tags = find_tags_containing(ancestor_project, commit) + pairs += [(ancestor_project, found_tag) for found_tag in found_tags] + pairs = list(set(pairs)) + if packaged: + packaged_set = set() + for packaging_project, packaged_tags in packaged.items(): + for packaged_tag in reduce_tags(packaged_tags): + packaged_set.add((packaging_project, packaged_tag)) + packaging_info = ' ({})'.format(', '.join('{}:{}'.format(*pair) for pair in packaged_set)) + print('{:.7s} is in {}: {}{}'.format(original_commit, project, tag_info, packaging_info)) diff --git a/scripts/dev/newReleaseBranch.sh b/scripts/dev/newReleaseBranch.sh new file mode 100644 index 0000000000..a6203ec760 --- /dev/null +++ b/scripts/dev/newReleaseBranch.sh @@ -0,0 +1,717 @@ +#!/usr/bin/env bash + +set -o errexit + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="${SCRIPT_DIR}/../../.." + +usage() { + cat << ??? 1>&2; + +Creates HotFix and ServicePack (.N) branches for repo, share and packaging projects, and updates the master +or ServicePack branches ready for the next release. + +Usage: $0 [-v ] [-h] [-l] [-t] [-c] [-s] + : The version just released. Used in the new HotFix Branch name release/. + Must contain 3 integers separated by dots. + -v : Overrides the next development version on master so that the major version may be changed. + Ignored if the master branch is not going to be modified. Must contain 3 integers separated by dots. + -h: Display this help + -l: Output extra logging + -t: use test branches: release/test/master and release/test/X.x.x + -c: cleanup (delete) local test release/test/X.x.x branches that are about to be created or modified. + -s: skip the push to the remote git repository + +Examples: + 1. After the release of 23.1.0 from the master branch: + $ $0 23.1.0 + Creates the HotFix branch for 23.1.0, creates the 23.1.N ServicePack branch and modifies the master branch for + use by the next minor version 23.2.0. + + 2. After the release of 23.1.1 from the ServicePack branch release/23.1.N: + $ $0 23.1.1 + Creates the HotFix branch for 23.1.1 and modifies the 23.1.N ServicePack branch for use by the next version 23.1.2 + + 3. After the release of 23.1.2 from the ServicePack branch release/23.1.N + $ $0 23.1.2 + Creates the HotFix branch for 23.1.2 and modifies the 23.1.N ServicePack branch for use by the next version 23.1.3 + + 4. Switching to the next major version: + $ $0 23.2.0 -v 25.1.0 + Creates the HotFix branch for 23.2.0, creates the 23.2.N ServicePack branch and modifies the master branch for + use by the next Hot Fix major version 25.1.0. +??? +} + +readCommandLineArgs() { + hotFixVersion="${1}" + if [ -z "${hotFixVersion}" ] + then + usage + exit 1 + fi + shift 1 + + masterVersion="" + doPush="true" + doTest="" + doCleanup="" + loggingOut="/dev/null" + prefix="" + while getopts "v:stclh" arg; do + case $arg in + v) + masterVersion=${OPTARG} + ;; + l) + loggingOut=`tty` + prefix="== " + ;; + t) + doTest="true" + ;; + c) + doCleanup="true" + ;; + s) + doPush="" + ;; + h | *) + usage + exit 0 + ;; + esac + done + shift $((OPTIND-1)) + + if [ "$#" != "0" ]; then + usage + exit 1 + fi +} + +getVersionMajor() { + echo "${1}" | sed -n "s/^\([0-9]*\)\.[0-9]*\.[0-9]*$/\1/p" +} + +getVersionMinor() { + echo "${1}" | sed -n "s/^[0-9]*\.\([0-9]*\)\.[0-9]*$/\1/p" +} + +getVersionRevision() { + echo "${1}" | sed -n "s/^[0-9]*\.[0-9]*\.\([0-9]*\)$/\1/p" +} + +increment() { + local number="${1}" + echo "${number} + 1" | bc +} + +function readTopLevelTag() { + local tagName="${1}" + local pomFile="${2}" + # Might be possible to generalise this function to accept an XPath so it could be used in place of sed commands + + # Read the file with an IFS (Input Field Separator) of the start of XML tag character < + local IFS=\> + local depth=-99 + while read -d \< ENTITY CONTENT + do + if [[ $ENTITY == project\ * ]] # outer tag + then + depth=0 + elif [[ $ENTITY == /* ]] # end tag + then + ((depth=depth-1)) + else # start tag + ((depth=depth+1)) + fi + + if [[ $ENTITY = "${tagName}" ]] && [[ $depth == 1 ]] ; then + echo $CONTENT + exit + fi + done < $pomFile + exit 1 +} + +getPomVersion() { + # Same as slower/simpler: "mvn help:evaluate -Dexpression=project.version" + readTopLevelTag version pom.xml +} + +getPomMajor() { + getPomVersion | sed -n "s/^\([0-9]*\).*/\1/p" +} + +getPomMinor() { + getPomVersion | sed -n "s/^[0-9]*\.\([0-9]*\).*/\1/p" +} + +getPomLabel() { + getPomVersion | sed -n "s/^[0-9]*\.[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/p" +} + +setPomVersion() { + local pomVersion="${1}" + local profiles="${2}" + + echo "${prefix} set pom version ${pomVersion} using profiles: ${profiles}" + mvn versions:set -DnewVersion="${pomVersion}" -DgenerateBackupPoms=false -P"${profiles}" &>${loggingOut} +} + +getPomProperty() { + local project="${1}" + local property="${2}" + + grep ${property} ${ROOT_DIR}/${project}/pom.xml | sed "s|^.*<[^>]*>\([^<]*\)]*>.*$|\1|g" +} + +setScmTag() { + local newBranch="${1}" + local tag="${2}" + + if [[ "${newBranch}" == "NewBranch" ]] + then + echo "${prefix} set ${tag}" + ed -s pom.xml &>${loggingOut} << EOF +/ +/.*<\/tag>/s//${tag}<\/tag>/ +wq +EOF + fi +} + +getSchema() { + grep '^version\.schema=\d*.*$' repository/src/main/resources/alfresco/repository.properties | sed 's/.*=\(\d*\)/\1/' +} + +setSchema() { + local schema="${1}" + + echo "${prefix} setSchema ${schema}" + ed -s repository/src/main/resources/alfresco/repository.properties &>${loggingOut} << EOF +/^version\.schema=\d*.*$/s//version.schema=${schema}/ +wq +EOF +} + +getCurrentProject() { + local pwd=`pwd` + basename ${pwd} +} + +setAcsVersionLabelInEnterpriseRepo() { + local version="${1}" + local branchType="${2}" + + if [[ `getCurrentProject` == "alfresco-enterprise-repo" ]] + then + if [[ "${branchType}" == "HotFix" ]] + then + echo "${prefix} set " + ed -s pom.xml &>${loggingOut} << EOF +/.*acs.version.label.*$/s// .1<\/acs.version.label> / +wq +EOF + else + echo "${prefix} set " + ed -s pom.xml &>${loggingOut} << EOF +/.*acs.version.label.*$/s// / +wq +EOF + fi + fi +} + +setAcsVersionInCommunityRepo() { + local version="${1}" + + if [[ `getCurrentProject` == "alfresco-community-repo" ]] + then + local versionMajor=`getVersionMajor "${version}"` + local versionMinor=`getVersionMinor "${version}"` + local versionRevision=`getVersionRevision "${version}"` + echo "${prefix} set ${versionMajor} ${versionMinor} ${versionRevision}" + ed -s pom.xml &>${loggingOut} << EOF +/.*acs.version.major.*$/s// ${versionMajor}<\/acs.version.major>/ +/.*acs.version.minor.*$/s// ${versionMinor}<\/acs.version.minor>/ +/.*acs.version.revision.*$/s// ${versionRevision}<\/acs.version.revision>/ +wq +EOF + fi +} + +# Tried using maven properties in this test file, but they are not currently being replaced by the build, so need to +# edit them in this script for now. +setAgsTestVersionPropertiesInCommunityRepo() { + local version="${1}" + + if [[ `getCurrentProject` == "alfresco-community-repo" ]] + then + local versionMajor=`getVersionMajor "${version}"` + local versionMinor=`getVersionMinor "${version}"` + local versionRevision=`getVersionRevision "${version}"` + echo "${prefix} set AGS test version.properties: version.major version.minor version.revision ${versionMajor} ${versionMinor} ${versionRevision}" + ed -s amps/ags/rm-community/rm-community-repo/test/resources/alfresco/version.properties &>${loggingOut} << EOF +/.*version.major.*$/s//version.major=${versionMajor}/ +/.*version.minor.*$/s//version.minor=${versionMinor}/ +/.*version.revision.*$/s//version.revision=${versionRevision}/ +wq +EOF + fi +} + +setAcsVersionInShare() { + local version="${1}" + + if [[ `getCurrentProject` == "alfresco-enterprise-share" ]] + then + local versionMajor=`getVersionMajor "${version}"` + local versionMinor=`getVersionMinor "${version}"` + local versionRevision=`getVersionRevision "${version}"` + echo "${prefix} set ${versionMajor} ${versionMinor} ${versionRevision}" + ed -s pom.xml &>${loggingOut} << EOF +/.*version.major.*$/s// ${versionMajor}<\/version.major>/ +/.*version.minor.*$/s// ${versionMinor}<\/version.minor>/ +/.*version.revision.*$/s// ${versionRevision}<\/version.revision>/ +wq +EOF + fi +} + +setNextReleaseVersion() { + local version="${1}" + + echo "${prefix} set RELEASE_VERSION: ${version}" + if [[ `getCurrentProject` == "acs-community-packaging" ]] + then + ed -s .github/workflows/ci.yml &>${loggingOut} << EOF +/.*RELEASE_VERSION.*$/s// RELEASE_VERSION: ${version}/ +wq +EOF + else + ed -s .github/workflows/master_release.yml &>${loggingOut} << EOF +/.*RELEASE_VERSION.*$/s// RELEASE_VERSION: ${version}/ +wq +EOF + fi +} + +setStartWithRealVersion() { + local version="${1}" + + echo "${prefix} set # ... start with real version ${version}" + if [[ `getCurrentProject` == "acs-community-packaging" ]] + then + ed -s .github/workflows/ci.yml &>${loggingOut} << EOF +/.*start with real version.*$/s// # Release version has to start with real version (${version}-....) for the docker image to build successfully./ +wq +EOF + else + ed -s .github/workflows/master_release.yml &>${loggingOut} << EOF +/.*start with real version.*$/s// # Release version has to start with real version (${version}-....) for the docker image to build successfully./ +wq +EOF + fi +} + +setNextDevelopmentVersion() { + local version="${1}" + + echo "${prefix} set DEVELOPMENT_VERSION: ${version}" + if [[ `getCurrentProject` == "acs-community-packaging" ]] + then + ed -s .github/workflows/ci.yml &>${loggingOut} << EOF +/.*DEVELOPMENT_VERSION.*$/s// DEVELOPMENT_VERSION: ${version}/ +wq +EOF + else + ed -s .github/workflows/master_release.yml &>${loggingOut} << EOF +/.*DEVELOPMENT_VERSION.*$/s// DEVELOPMENT_VERSION: ${version}/ +wq +EOF + fi +} + +setVersionInPackaging() { + local version="${1}" + local branchType="${2}" + local projectType="${3}" + + if [[ "${projectType}" == "Packaging" ]] + then + if [[ "${branchType}" == "HotFix" ]] + then + setNextReleaseVersion "${version}.1" + setNextDevelopmentVersion "${version}.2-SNAPSHOT" + else + setStartWithRealVersion "${version}" + setNextReleaseVersion "${version}-A1" + setNextDevelopmentVersion "${version}-SNAPSHOT" + fi + fi +} + +setUpstreamVersionsInCommunityPackaging() { + local nextCommunityRepoVersion="${1}" + local nextEnterpriseShareVersion="${2}" + + if [[ `getCurrentProject` == "acs-community-packaging" ]] + then + echo "${prefix} set parent pom ${nextCommunityRepoVersion}" + echo "${prefix} set ${nextCommunityRepoVersion}" + echo "${prefix} set ${nextEnterpriseShareVersion}" + # Do not change the as we will need a version of the share distribution that + # exists, if we want to do a test build. acs-packaging will update it when a release is made. + ed -s pom.xml &>${loggingOut} << EOF +/ .*$/s// ${nextCommunityRepoVersion}<\/version>/ +/.*dependency.alfresco-community-repo.version.*$/s// ${nextCommunityRepoVersion}<\/dependency.alfresco-community-repo.version>/ +/.*dependency.alfresco-community-share.version.*$/s// ${nextEnterpriseShareVersion}<\/dependency.alfresco-community-share.version>/ +wq +EOF + fi +} + +# Each version of the Repo has a schema number stored in it. When we need to patch something, generally the database, +# we increment the schema by one and create a patch with that number. As a result it is possible for the repo to do the +# patching on startup. So that we have enough space between versions each major or minor version uses the next multiple +# of 1000 and each service pack uses the next multiple of 100. Actually patches don't have to have unique numbers, but +# it does make it simpler to understand what is going to happen. The following code does this calculation with 1000 or +# 100 being passed in as an argument. +incrementSchema() { + local schemaMultiple="${1}" + + if [[ `getCurrentProject` == "alfresco-community-repo" && "${schemaMultiple}" -gt 0 ]] + then + local schema=`getSchema` + schema=`echo "(${schema} / ${schemaMultiple} + 1) * ${schemaMultiple}" | bc` + setSchema "${schema}" + fi +} + +checkout() { + local project="${1}" + local branch="${2}" + + echo "${prefix} Checkout ${project} ${branch}" + + cd "${ROOT_DIR}/${project}/" + git fetch &>${loggingOut} + git checkout "${branch}" &>${loggingOut} +} + +createBranchFromTag() { + local project="${1}" + local tag="${2}" + local branch="${3}" + + echo "${prefix} Create ${project} branch ${branch} from tag ${tag}" + + cd "${ROOT_DIR}/${project}/" + git fetch &>${loggingOut} + git checkout "${tag}" &>${loggingOut} + git switch -c "${branch}" &>${loggingOut} +} + +modifyPomVersion() { + local version="${1}" + local branchType="${2}" + local profiles="${3}" + local projectType="${4}" + + if [[ "${projectType}" == "Packaging" ]] + then + if [[ "${branchType}" == "HotFix" ]] + then + pomVersion="${version}.1" + else + pomVersion="${version}" + fi + else + local versionMajor=`getVersionMajor "${version}"` + if [[ "${versionMajor}" -lt 23 ]] + then + pomMajor=`getPomMajor` + if [[ "${branchType}" == "HotFix" ]] + then + pomMinor=`getPomMinor` + pomMinor=`increment "${pomMinor}"` + pomVersion="${pomMajor}.${pomMinor}" + else + if [[ "${branchType}" == "Master" ]] + then + # Allow for two service packs before the next release off master. + # Prior to 23.1, the pom version of repo and share projects had a fixed number followed by a dot and an + # incrementing number. For example ACS 7.0.0 used 8.N, ACS 7.1.0 used 11.N, ACS 7.2.0 used 14.N. To allow + # for a couple of service packs between these it would jump two numbers. ACS 7.1.1 used 12.N. Had there been + # an ACS 7.1.2 it would have used 13.N. Not that we have done it for years, if there was a need for a third + # service pack we would have had to do something special and go down another level. For example ACS 7.1.3 + # might have used 13.300.N + pomMajor=`increment "${pomMajor}"` + pomMajor=`increment "${pomMajor}"` + fi + pomMajor=`increment "${pomMajor}"` + pomVersion="${pomMajor}.1" + fi + else + if [[ "${branchType}" == "HotFix" ]] + then + pomLabel=`getPomLabel` + pomLabel=`increment "${pomLabel}"` + else + pomLabel="1" + fi + pomVersion="${version}.${pomLabel}" + fi + fi + + if [[ `getCurrentProject` == "alfresco-community-repo" ]] + then + nextCommunityRepoVersion="${pomVersion}" + elif [[ `getCurrentProject` == "alfresco-enterprise-share" ]] + then + nextEnterpriseShareVersion="${pomVersion}" + fi + + pomVersion="${pomVersion}-SNAPSHOT" + setPomVersion "${pomVersion}" "${profiles}" +} + +modifyProject() { + local version="${1}" + local branchType="${2}" + local schemaMultiple="${3}" + local profiles="${4}" + local projectType="${5}" + local newBranch="${6}" + + modifyPomVersion "${version}" "${branchType}" "${profiles}" "${projectType}" + setScmTag "${newBranch}" HEAD + incrementSchema "${schemaMultiple}" + setAcsVersionInCommunityRepo "${version}" + setAgsTestVersionPropertiesInCommunityRepo "${version}" + setAcsVersionLabelInEnterpriseRepo "${version}" "${branchType}" + setAcsVersionInShare "${version}" + setVersionInPackaging "${version}" "${branchType}" "${projectType}" + setUpstreamVersionsInCommunityPackaging "${nextCommunityRepoVersion}" "${nextEnterpriseShareVersion}" +} + +commitAndPush() { + local message="${1}" + + echo "${prefix} git commit" + git commit --all -m "${message}" &>${loggingOut} + if [[ -n "${doPush}" ]] + then + echo "${prefix} git push" + git push &>${loggingOut} + else + echo "${prefix} # git push" + fi +} + +createProjectBranchesFromAcsVersion() { + local hotFixVersion="${1}" + local branch="${2}" + local version="${3}" + local branchType="${4}" + local schemaMultiple="${5}" + local message="${6}" + + createBranchFromTag acs-packaging "${hotFixVersion}" "${branch}" + modifyProject "${version}" "${branchType}" "${schemaMultiple}" dev Packaging NewBranch + commitAndPush "${message} [skip ci]" + + shareVersion=`getPomProperty acs-packaging ""` + createBranchFromTag alfresco-enterprise-share "${shareVersion}" "${branch}" + modifyProject "${version}" "${branchType}" "${schemaMultiple}" ags Library NewBranch + commitAndPush "${message} [skip ci]" + + enterpriseRepoVersion=`getPomProperty acs-packaging ""` + createBranchFromTag alfresco-enterprise-repo "${enterpriseRepoVersion}" "${branch}" + modifyProject "${version}" "${branchType}" "${schemaMultiple}" ags Library NewBranch + commitAndPush "${message} [skip ci]" + + communityRepoVersion=`getPomProperty alfresco-enterprise-repo ""` + createBranchFromTag alfresco-community-repo "${communityRepoVersion}" "${branch}" + modifyProject "${version}" "${branchType}" "${schemaMultiple}" ags Library NewBranch + commitAndPush "${message}" + + createBranchFromTag acs-community-packaging "${hotFixVersion}" "${branch}" + modifyProject "${version}" "${branchType}" "${schemaMultiple}" dev Packaging NewBranch + commitAndPush "${message} [skip ci]" +} + +modifyOriginalProjectBranchesForNextRelease() { + local branch="${1}" + local version="${2}" + local branchType="${3}" + local schemaMultiple="${4}" + local message="${5}" + + checkout acs-packaging "${branch}" + modifyProject "${version}" "${branchType}" "${schemaMultiple}" dev Packaging OriginalBranch + commitAndPush "${message} [skip ci]" + + checkout alfresco-enterprise-share "${branch}" + modifyProject "${version}" "${branchType}" "${schemaMultiple}" ags Library OriginalBranch + commitAndPush "${message} [skip ci]" + + checkout alfresco-enterprise-repo "${branch}" + modifyProject "${version}" "${branchType}" "${schemaMultiple}" ags Library OriginalBranch + commitAndPush "${message} [skip ci]" + + checkout alfresco-community-repo "${branch}" + modifyProject "${version}" "${branchType}" "${schemaMultiple}" ags Library OriginalBranch + commitAndPush "${message}" + + checkout acs-community-packaging "${branch}" + modifyProject "${version}" "${branchType}" "${schemaMultiple}" dev Packaging OriginalBranch + commitAndPush "${message} [skip ci]" +} + +calculateBranchVersions() { + + # HotFix version + hotFixMajor=`getVersionMajor "${hotFixVersion}"` + hotFixMinor=`getVersionMinor "${hotFixVersion}"` + hotFixRevision=`getVersionRevision "${hotFixVersion}"` + if [[ "${hotFixVersion}" != "${hotFixMajor}.${hotFixMinor}.${hotFixRevision}" ]] + then + echo 'The is invalid. Must contain 3 integers separated by dots.' + exit 1 + fi + + # ServicePack version + servicePackMajor="${hotFixMajor}" + servicePackMinor="${hotFixMinor}" + servicePackRevision=`increment "${hotFixRevision}"` + servicePackVersion="${servicePackMajor}.${servicePackMinor}.${servicePackRevision}" + + # Master version + if [ -z "${masterVersion}" ] + then + masterMajor="${hotFixMajor}" + masterMinor=`increment "${hotFixMinor}"` + masterRevision="0" + masterVersion="${masterMajor}.${masterMinor}.${masterRevision}" + else + masterMajor=`getVersionMajor "${masterVersion}"` + masterMinor=`getVersionMinor "${masterVersion}"` + masterRevision=`getVersionRevision "${masterVersion}"` + if [[ "${masterVersion}" != "${masterMajor}.${masterMinor}.${masterRevision}" ]] + then + echo 'The is invalid. Must contain 3 integers separated by dots.' + exit 1 + fi + fi + + # Branches + if [[ -n "${doTest}" ]] + then + masterBranch="release/test/master" + hotFixBranch="release/test/${hotFixVersion}" + servicePackBranch="release/test/${hotFixMajor}.${hotFixMinor}.N" + else + masterBranch="master" + hotFixBranch="release/${hotFixVersion}" + servicePackBranch="release/${hotFixMajor}.${hotFixMinor}.N" + fi +} + +cleanUpTestBranches() { + local project="${1}" + + if [[ "${hotFixRevision}" == "0" ]] + then + echo "${prefix}Clean up ${hotFixBranch} and ${servicePackBranch} on ${project}" + cd "${ROOT_DIR}/${project}/" + git checkout . &>${loggingOut} + git checkout "${masterBranch}" &>${loggingOut} + git branch -D "${hotFixBranch}" &>${loggingOut} + git branch -D "${servicePackBranch}" &>${loggingOut} + else + echo "${prefix}Clean up ${hotFixBranch} on ${project}" + cd "${ROOT_DIR}/${project}/" + git checkout . &>${loggingOut} + git checkout "${servicePackBranch}" &>${loggingOut} + git branch -D "${hotFixBranch}" &>${loggingOut} + fi +} + +cleanUpTestProjectBranches() { + + if [[ -n "${doCleanup}" && -n "${doTest}" ]] + then + echo + set +o errexit + cleanUpTestBranches alfresco-community-repo + cleanUpTestBranches alfresco-enterprise-repo + cleanUpTestBranches alfresco-enterprise-share + cleanUpTestBranches acs-community-packaging + cleanUpTestBranches acs-packaging + set -o errexit + fi +} + +createHotFixProjectBranches() { + local hotFixVersion="${1}" + local hotFixBranch="${2}" + + echo + echo "${prefix}Create the HotFix branches" + createProjectBranchesFromAcsVersion "${hotFixVersion}" "${hotFixBranch}" \ + "${hotFixVersion}" HotFix 0 \ + "Create HotFix branch for ${hotFixVersion}" +} + +createServicePackProjectBranches() { + local hotFixVersion="${1}" + local servicePackBranch="${2}" + local servicePackVersion="${3}" + + echo + echo "${prefix}Create the ServicePack branches" + createProjectBranchesFromAcsVersion "${hotFixVersion}" "${servicePackBranch}" \ + "${servicePackVersion}" ServicePack 100 \ + "Create ServicePack branch ${servicePackBranch}" +} + +modifyOriginalProjectBranches() { + local branchType="${1}" + local branch="${2}" + local version="${3}" + local schemaMultiple="${4}" + + echo + echo "${prefix}Modify the ${branchType} branches" + modifyOriginalProjectBranchesForNextRelease "${branch}" \ + "${version}" "${branchType}" "${schemaMultiple}" \ + "Update ${branchType} branch to ${version}" +} + +createAndModifyProjectBranches() { + createHotFixProjectBranches "${hotFixVersion}" "${hotFixBranch}" + if [[ "${hotFixRevision}" == "0" ]] + then + createServicePackProjectBranches "${hotFixVersion}" "${servicePackBranch}" "${servicePackVersion}" + modifyOriginalProjectBranches Master "${masterBranch}" "${masterVersion}" 1000 + else + modifyOriginalProjectBranches ServicePack "${servicePackBranch}" "${servicePackVersion}" 100 + fi +} + +main() { + readCommandLineArgs "$@" + calculateBranchVersions + + cleanUpTestProjectBranches + + createAndModifyProjectBranches + + echo + echo Done +} + +main "$@" \ No newline at end of file From 61c6a13983dbcf282e95f2016a138eaa435796ee Mon Sep 17 00:00:00 2001 From: Eva Vasques Date: Tue, 10 Oct 2023 13:18:28 +0100 Subject: [PATCH 3/6] Correct CI references --- docs/build_and_release.md | 4 +- scripts/dev/dev_functions.sh | 4 +- scripts/dev/linkPoms.sh | 191 ++++++++++++++++++++++-------- scripts/dev/unlinkPoms.sh | 5 +- tests/pipeline-all-amps/README.md | 6 +- 5 files changed, 152 insertions(+), 58 deletions(-) mode change 100644 => 100755 scripts/dev/linkPoms.sh mode change 100644 => 100755 scripts/dev/unlinkPoms.sh diff --git a/docs/build_and_release.md b/docs/build_and_release.md index 3330f09a09..b85234c999 100644 --- a/docs/build_and_release.md +++ b/docs/build_and_release.md @@ -1,6 +1,6 @@ # Build -The `acs-packaging` project uses _Travis CI_. \ -The `.travis.yml` config file can be found in the root of the repository. +The `acs-packaging` project uses _GitHub Actions_. \ +The `.ci.yml` config file can be found in the .github/workflows/ folder. ## Stages diff --git a/scripts/dev/dev_functions.sh b/scripts/dev/dev_functions.sh index 51665650ae..15e44536ba 100644 --- a/scripts/dev/dev_functions.sh +++ b/scripts/dev/dev_functions.sh @@ -4,7 +4,7 @@ function updatePomParent() { local PROJECT="$1" local PARENT_POM_VERSION="$2" - if [ -d "${ROOT_DIR}/${PROJECT}" ] + if [ -d "${ROOT_DIR}/${PROJECT}" -a -n "${PARENT_POM_VERSION}" ] then # Cannot use "mvn versions:update-parent" as the version must exist before it can be set. The ed command is also faster. pushd "${ROOT_DIR}/${PROJECT}" &>/dev/null @@ -30,7 +30,7 @@ function updatePomProperty() { local PROPERTY_VALUE="$2" local PROPERTY_NAME="$3" - if [ -d "${ROOT_DIR}/${PROJECT}" ] + if [ -d "${ROOT_DIR}/${PROJECT}" -a -n "${PROPERTY_VALUE}" ] then # Can use "mvn versions:set-property", but ed is so much faster. # mvn -B versions:set-property versions:commit -Dproperty="${PROPERTY_NAME}" "-DnewVersion=${PROPERTY_VALUE}" diff --git a/scripts/dev/linkPoms.sh b/scripts/dev/linkPoms.sh old mode 100644 new mode 100755 index b53fb367d5..709eaeb9fc --- a/scripts/dev/linkPoms.sh +++ b/scripts/dev/linkPoms.sh @@ -2,15 +2,19 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="${SCRIPT_DIR}/../../.." +ENV_FILE=".linkPoms.env" +ENV_PATH="${ROOT_DIR}/${ENV_FILE}" +PROJECT_LIST="alfresco-community-repo alfresco-enterprise-repo alfresco-enterprise-share acs-packaging acs-community-packaging" source "$(dirname "${BASH_SOURCE[0]}")/dev_functions.sh" usage() { echo "Updates the downstream projects with the versions of the upstream projects. Reversed by unlinkPoms.sh" 1>&2; echo 1>&2; - echo "Usage: $0 [-b ] [-mpxuh]" 1>&2; + echo "Usage: $0 [-b ] [-mpfxuh]" 1>&2; echo " -m: Checkout master of each project" 1>&2; echo " -b: Checkout the of each project or master if is blank" 1>&2; + echo " -f: Fetch before checking out the branch" 1>&2; echo " -p: Pull the latest version of each project" 1>&2; echo " -x: Skip the extract of values from each project" 1>&2; echo " -u: Skip the update of values in each project" 1>&2; @@ -38,41 +42,117 @@ function checkout() { fi } -function pull_latest() { - local PROJECT="${1}" +function update_repository() { + local UPDATE_COMMAND="${1}" + local PROJECT="${2}" if [ -d "${ROOT_DIR}/${PROJECT}" ] then pushd "${ROOT_DIR}/${PROJECT}" &>/dev/null - git pull &>/tmp/$$.log + git "${UPDATE_COMMAND}" &>/tmp/$$.log if [ $? -ne 0 ] then echo - echo "\"git pull\" failed on ${PROJECT}" + echo "\"git ${UPDATE_COMMAND}\" failed on ${PROJECT}" cat "/tmp/$$.log" exit 1 fi - echo "${PROJECT} is now using latest" + echo "${PROJECT} has been updated using \"git ${UPDATE_COMMAND}\"" popd &>/dev/null fi } +function readTopLevelTag() { + local TAG_NAME="${1}" + local POM_FILE="${2}" + # Might be possible to generalise this function to accept an XPath so it could be used in place of sed commands + + # Read the file with an IFS (Input Field Separator) of the start of XML tag character < + local IFS=\> + local DEPTH=-99 + while read -d \< ENTITY CONTENT + do + if [[ $ENTITY == project\ * ]] # outer tag + then + DEPTH=0 + elif [[ $ENTITY == /* ]] # end tag + then + ((DEPTH=DEPTH-1)) + else # start tag + ((DEPTH=DEPTH+1)) + fi + + if [[ $ENTITY = "${TAG_NAME}" ]] && [[ $DEPTH == 1 ]] ; then + echo $CONTENT + exit + fi + done < $POM_FILE + exit 1 +} + +function exportPomVersion() { + local PROJECT="${1}" + local ENV_NAME="${2}" + + if [ -d "${ROOT_DIR}/${PROJECT}" ] + then + pushd "${ROOT_DIR}/${PROJECT}" &>/dev/null + # Same as slower/simpler: "mvn help:evaluate -Dexpression=project.version" + VERSION=$(readTopLevelTag version pom.xml) + if [ $? -ne 0 ] + then + echo + echo "\"readTopLevelTagContent version pom.xml\" failed on ${PROJECT}" + exit 1 + fi + echo "export ${ENV_NAME}=${VERSION}" >> "${ENV_PATH}" + popd &>/dev/null + fi +} + +function exportPomParent() { + local PROJECT="${1}" + local ENV_NAME="${2}" + + if [ -d "${ROOT_DIR}/${PROJECT}" ] + then + pushd "${ROOT_DIR}/${PROJECT}" &>/dev/null + # Same as slower/simpler: "mvn help:evaluate -Dexpression=project.parent.version" + PROPERTY_VALUE=$(sed -n '//,/<\/parent>/p' pom.xml | sed -n "s/.*\(.*\)<\/version>/\1/p" | sed 's/\r//g') + if [ $? -ne 0 ] + then + echo + echo "\"sed -n '//,/<\/parent>/p' pom.xml | sed -n \\\"s/.*\(.*\)<\/version>/\1/p\\\" | sed 's/\r//g'\" failed on ${PROJECT}" + exit 1 + fi + echo "export ${ENV_NAME}=${PROPERTY_VALUE}" >> "${ENV_PATH}" + popd &>/dev/null + fi +} + +# Original version was simpler/slower: exportPomPropertyOrig project.parent.version function exportPomProperty() { - local PROJECT="$1" - local ENV_NAME="$2" - local PROPERTY_NAME="$3" + local PROJECT="${1}" + local ENV_NAME="${2}" + local PROPERTY_NAME="${3}" - if [ -d "${ROOT_DIR}/${PROJECT}" ] - then - pushd "${ROOT_DIR}/${PROJECT}" &>/dev/null - PROPERTY_VALUE=$(mvn help:evaluate -Dexpression="${PROPERTY_NAME}" -q -DforceStdout) - echo "export ${ENV_NAME}=${PROPERTY_VALUE}" - popd &>/dev/null - >&2 echo "${ENV_NAME}=${PROPERTY_VALUE}" + if [ -d "${ROOT_DIR}/${PROJECT}" ] + then + pushd "${ROOT_DIR}/${PROJECT}" &>/dev/null + # Same as slower/simpler: "mvn help:evaluate -Dexpression=${PROPERTY_NAME}" + PROPERTY_VALUE=$(sed -n '//,/<\/properties>/p' pom.xml | sed -n "s/.*<${PROPERTY_NAME}>\(.*\)<\/${PROPERTY_NAME}>/\1/p" | sed 's/\r//g') + if [ $? -ne 0 ] + then + echo + echo "\"sed -n '//,/<\/properties>/p' pom.xml | sed -n \\\"s/.*<${PROPERTY_NAME}>\(.*\)<\/${PROPERTY_NAME}>/\1/p\\\" | sed 's/\r//g'\" failed on ${PROJECT}" + exit 1 fi + echo "export ${ENV_NAME}=${PROPERTY_VALUE}" >> "${ENV_PATH}" + popd &>/dev/null + fi } -while getopts "b:mpxuh" arg; do +while getopts "b:mpfxuh" arg; do case $arg in b) B_FLAG_SET="true" @@ -83,6 +163,12 @@ while getopts "b:mpxuh" arg; do p) # git pull after git checkout ;; + f) + for project in ${PROJECT_LIST} + do + update_repository fetch "${project}" + done + ;; x) SKIP_EXPORT="true" ;; @@ -101,64 +187,71 @@ then exit 1 fi OPTIND=1 -while getopts "b:mpxuh" arg; do +while getopts "b:mpfxuh" arg; do case $arg in b) BRANCH="${OPTARG:-master}" - checkout alfresco-community-repo "${BRANCH}" - checkout alfresco-enterprise-repo "${BRANCH}" - checkout alfresco-enterprise-share "${BRANCH}" - checkout acs-packaging "${BRANCH}" - checkout acs-community-packaging "${BRANCH}" ;; m) BRANCH="master" - checkout alfresco-community-repo "${BRANCH}" - checkout alfresco-enterprise-repo "${BRANCH}" - checkout alfresco-enterprise-share "${BRANCH}" - checkout acs-packaging "${BRANCH}" - checkout acs-community-packaging "${BRANCH}" ;; esac done +if [ -n "${BRANCH}" ] +then + for project in ${PROJECT_LIST} + do + checkout "${project}" "${BRANCH}" + done +fi OPTIND=1 -while getopts "b:mpxuh" arg; do +while getopts "b:mpfxuh" arg; do case $arg in p) - pull_latest alfresco-community-repo - pull_latest alfresco-enterprise-repo - pull_latest alfresco-enterprise-share - pull_latest acs-packaging - pull_latest acs-community-packaging + for project in ${PROJECT_LIST} + do + update_repository pull "${project}" + done ;; esac done if [ -z ${SKIP_EXPORT+x} ] then - exportPomProperty alfresco-community-repo COM_R_VERSION project.version > .pomLink.env + rm -f "${ENV_FILE}" + + exportPomVersion alfresco-community-repo COM_R_VERSION - exportPomProperty alfresco-enterprise-repo ENT_R_VERSION project.version >> .pomLink.env - exportPomProperty alfresco-enterprise-repo ENT_R_PARENT project.parent.version >> .pomLink.env - exportPomProperty alfresco-enterprise-repo ENT_R_DEP_COM_R dependency.alfresco-community-repo.version >> .pomLink.env + exportPomVersion alfresco-enterprise-repo ENT_R_VERSION + exportPomParent alfresco-enterprise-repo ENT_R_PARENT + exportPomProperty alfresco-enterprise-repo ENT_R_DEP_COM_R dependency.alfresco-community-repo.version - exportPomProperty alfresco-enterprise-share ENT_S_VERSION project.version >> .pomLink.env - exportPomProperty alfresco-enterprise-share ENT_S_DEP_COM_R dependency.alfresco-community-repo.version >> .pomLink.env - exportPomProperty alfresco-enterprise-share ENT_S_DEP_ENT_R dependency.alfresco-enterprise-repo.version >> .pomLink.env + exportPomVersion alfresco-enterprise-share ENT_S_VERSION + exportPomProperty alfresco-enterprise-share ENT_S_DEP_COM_R dependency.alfresco-community-repo.version + exportPomProperty alfresco-enterprise-share ENT_S_DEP_ENT_R dependency.alfresco-enterprise-repo.version - exportPomProperty acs-packaging ENT_P_PARENT project.parent.version >> .pomLink.env - exportPomProperty acs-packaging ENT_P_DEP_ENT_R dependency.alfresco-enterprise-repo.version >> .pomLink.env - exportPomProperty acs-packaging ENT_P_DEP_ENT_S dependency.alfresco-enterprise-share.version >> .pomLink.env + exportPomVersion acs-packaging ENT_P_VERSION + exportPomParent acs-packaging ENT_P_PARENT + exportPomProperty acs-packaging ENT_P_DEP_ENT_R dependency.alfresco-enterprise-repo.version + exportPomProperty acs-packaging ENT_P_DEP_ENT_S dependency.alfresco-enterprise-share.version - exportPomProperty acs-community-packaging COM_P_PARENT project.parent.version >> .pomLink.env - exportPomProperty acs-community-packaging COM_P_DEP_COM_R dependency.alfresco-community-repo.version >> .pomLink.env - exportPomProperty acs-community-packaging COM_P_DEP_COM_S dependency.alfresco-community-share.version >> .pomLink.env - echo + exportPomVersion acs-packaging COM_P_VERSION + exportPomParent acs-community-packaging COM_P_PARENT + exportPomProperty acs-community-packaging COM_P_DEP_COM_R dependency.alfresco-community-repo.version + exportPomProperty acs-community-packaging COM_P_DEP_COM_S dependency.alfresco-community-share.version + + cat "${ENV_FILE}" fi if [ -z ${SKIP_UPDATE+x} ] then - source .pomLink.env + if [ ! -f "${ENV_FILE}" ] + then + echo ""${ENV_FILE}" does not exist." + exit 1 + fi + + source "${ENV_FILE}" updatePomParent alfresco-enterprise-repo "$COM_R_VERSION" updatePomProperty alfresco-enterprise-repo "$COM_R_VERSION" dependency.alfresco-community-repo.version diff --git a/scripts/dev/unlinkPoms.sh b/scripts/dev/unlinkPoms.sh old mode 100644 new mode 100755 index 4d90250833..00aee317d1 --- a/scripts/dev/unlinkPoms.sh +++ b/scripts/dev/unlinkPoms.sh @@ -3,11 +3,12 @@ set -o errexit SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="${SCRIPT_DIR}/../../.." +ENV_FILE=".linkPoms.env" source "$(dirname "${BASH_SOURCE[0]}")/dev_functions.sh" usage() { - echo "Reverts changes made by linkPoms.sh using values stored in .pomLink.env" 1>&2; + echo "Reverts changes made by linkPoms.sh using values stored in ${ENV_FILE}" 1>&2; echo 1>&2; echo "Usage: $0 [-h]" 1>&2; echo " -h: Display this help" 1>&2; @@ -26,7 +27,7 @@ while getopts "lh" arg; do esac done -source .pomLink.env +source ${ENV_FILE} updatePomParent alfresco-enterprise-repo "$ENT_R_PARENT" updatePomProperty alfresco-enterprise-repo "$ENT_R_DEP_COM_R" dependency.alfresco-community-repo.version diff --git a/tests/pipeline-all-amps/README.md b/tests/pipeline-all-amps/README.md index 221dd76d0a..f32faac127 100644 --- a/tests/pipeline-all-amps/README.md +++ b/tests/pipeline-all-amps/README.md @@ -2,10 +2,10 @@ The [pipeline-all-amps](../pipeline-all-amps) module pushes repo and share images with extra amps applied on top for use by the CI/CD single pipeline process. -## Travis job to test and push docker images +## Github Actions job to test and push docker images -The acs-packaging repo [travis](../../.travis.yml) job `"Pipeline All AMPs tests and push docker images"` publishes internally the new docker images for repo and share -with travis build number +The acs-packaging repo [Github Actions](../../.github/workflows/ci.yml) job `"Pipeline All AMPs tests and push docker images"` publishes internally the new docker images for repo and share +with GHA build number Example: alfresco/alfresco-pipeline-all-amps-repo:3102:7.0.0. From e7f36c26acaff616624a3fa103a23c2b81d88fb3 Mon Sep 17 00:00:00 2001 From: Eva Vasques Date: Tue, 10 Oct 2023 14:17:06 +0100 Subject: [PATCH 4/6] Remove elastic upgrade tests that were not on travis --- .github/workflows/ci.yml | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 474218eb4f..76fbd3e5cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -272,40 +272,6 @@ jobs: - name: "Clean Maven cache" run: bash ./scripts/ci/cleanup_cache.sh - upgrade_tas_tests: - name: Upgrade Elasticsearch TAS tests - runs-on: ubuntu-latest - if: > - !contains(github.event.head_commit.message, '[skip search]') && - !contains(github.event.head_commit.message, '[skip tests]') - steps: - - uses: actions/checkout@v3 - with: - persist-credentials: false - - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.35.2 - - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v1.35.2 - - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.35.2 - with: - java-version: ${{ env.JAVA_VERSION }} - - name: "Build" - timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} - run: | - bash ./scripts/ci/init.sh - bash ./scripts/ci/build.sh - - name: "Configure AWS credentials" - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_S3_ACSLICENSE_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_S3_ACSLICENSE_SECRET_ACCESS_KEY }} - aws-region: ${{ env.AWS_REGION }} - - name: "Copy Licence" - run: aws s3 cp ${ALF_LICENCE_S3_PATH} ${ALF_LICENCE_LOCAL_PATH} - - name: "Run tests" - timeout-minutes: 30 - run: mvn -B install -ntp -pl ":content-repository-elasticsearch-test" -am -Pall-tas-tests,elastic-upgrade -Denvironment=default -DrunBugs=false "-Dsearch.engine.type=elasticsearch" - - name: "Clean Maven cache" - run: bash ./scripts/ci/cleanup_cache.sh - all_amps_tests: name: "All AMPs tests" runs-on: ubuntu-latest From 59836574c728d1568799f9e9df919d6b50fffbef Mon Sep 17 00:00:00 2001 From: Eva Vasques Date: Tue, 10 Oct 2023 14:17:36 +0100 Subject: [PATCH 5/6] Add tas-distribution-zip to tests --- tests/pom.xml | 1 + tests/tas-distribution-zip/pom.xml | 76 +++++++++ .../CheckDistributionZipContents.java | 156 ++++++++++++++++++ .../src/test/resources/distribution-suite.xml | 9 + 4 files changed, 242 insertions(+) create mode 100644 tests/tas-distribution-zip/pom.xml create mode 100644 tests/tas-distribution-zip/src/test/java/org/alfresco/distribution/CheckDistributionZipContents.java create mode 100644 tests/tas-distribution-zip/src/test/resources/distribution-suite.xml diff --git a/tests/pom.xml b/tests/pom.xml index d99404b21f..12e3162f1e 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -19,6 +19,7 @@ tas-sync-service tas-all-amps tas-elasticsearch + tas-distribution-zip diff --git a/tests/tas-distribution-zip/pom.xml b/tests/tas-distribution-zip/pom.xml new file mode 100644 index 0000000000..f8818d6d13 --- /dev/null +++ b/tests/tas-distribution-zip/pom.xml @@ -0,0 +1,76 @@ + + + 4.0.0 + org.alfresco.tas + content-repository-distribution-test + Distribution test + jar + + + org.alfresco + content-repository-tests + 7.1.0.5-SNAPSHOT + + + + 3.13.2 + ${project.basedir}/src/test/resources/distribution-suite.xml + + + + + org.assertj + assertj-core + 3.22.0 + test + + + org.alfresco.tas + restapi + test + + + org.apache.maven + maven-model + 3.8.4 + + + + + + run-distribution-zip-contents-check + + ${project.basedir}/src/test/resources/distribution-suite.xml + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${suiteXmlFile} + + + --illegal-access=warn + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + + diff --git a/tests/tas-distribution-zip/src/test/java/org/alfresco/distribution/CheckDistributionZipContents.java b/tests/tas-distribution-zip/src/test/java/org/alfresco/distribution/CheckDistributionZipContents.java new file mode 100644 index 0000000000..f1223969cb --- /dev/null +++ b/tests/tas-distribution-zip/src/test/java/org/alfresco/distribution/CheckDistributionZipContents.java @@ -0,0 +1,156 @@ +/* + * #%L + * Alfresco Remote API + * %% + * Copyright (C) 2005 - 2021 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.distribution; + +import org.testng.annotations.Test; +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.File; +import java.io.FileReader; +import java.io.FilenameFilter; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; + +public class CheckDistributionZipContents +{ + public static final String ACS_PREFIX = "alfresco-content-services-distribution"; + public static final String ACS_DIR_NAME = "distribution"; + public static final String AGS_PREFIX = "alfresco-governance-services-enterprise"; + public static final String AGS_DIR_NAME = "distribution-ags"; + public static final String SHARE_PREFIX = "alfresco-content-services-share-distribution"; + public static final String SHARE_DIR_NAME = "distribution-share"; + public static final String FORMAT = ".zip"; + + @Test + public void testAcsDistributionZipContents() throws Exception + { + File filesList[] = getDistributionZip(ACS_DIR_NAME, ACS_PREFIX); + for (File file : filesList) + { + List zipEntries = getZipEntries(file.getAbsolutePath()); + assertThat(zipEntries). + contains( + "keystore/metadata-keystore/keystore-passwords.properties", + "keystore/metadata-keystore/keystore", + "keystore/generate_keystores.bat", + "keystore/generate_keystores.sh", + "bin/alfresco-mmt.jar", + "bin/apply_amps.bat", + "bin/apply_amps.sh", + "web-server/webapps/ROOT.war", + "web-server/webapps/alfresco.war", + "web-server/webapps/share.war", + "web-server/webapps/_vti_bin.war", + "web-server/conf/Catalina/localhost/share.xml", + "web-server/conf/Catalina/localhost/alfresco.xml", + "amps/alfresco-share-services.amp" + ); + } + } + + @Test + public void testAgsDistributionZipContents() throws Exception + { + String repoVersion = getPomValues().getProperties().getProperty("dependency.alfresco-enterprise-repo.version"); + String shareVersion = getPomValues().getProperties().getProperty("dependency.alfresco-enterprise-share.version"); + File filesList[] = getDistributionZip(AGS_DIR_NAME, AGS_PREFIX); + for (File file : filesList) + { + List zipEntries = getZipEntries(file.getAbsolutePath()); + assertThat(zipEntries). + contains( + "alfresco-governance-services-enterprise-repo-" + repoVersion + ".amp", + "alfresco-governance-services-enterprise-rest-api-explorer-" + repoVersion + ".war", + "alfresco-governance-services-enterprise-share-" + shareVersion + ".amp" + ); + } + } + + @Test + public void testShareDistributionZipContents() throws Exception + { + String projectVersion = getPomValues().getVersion(); + File filesList[] = getDistributionZip(SHARE_DIR_NAME, SHARE_PREFIX); + for (File file : filesList) + { + List zipEntries = getZipEntries(file.getAbsolutePath()); + assertThat(zipEntries). + contains( + "alfresco-content-services-share-distribution-" + projectVersion + "/bin/alfresco-mmt.jar", + "alfresco-content-services-share-distribution-" + projectVersion + "/web-server/conf/Catalina/localhost/share.xml", + "alfresco-content-services-share-distribution-" + projectVersion + "/web-server/webapps/share.war", + "alfresco-content-services-share-distribution-" + projectVersion + "/alfresco-share-encryption/alfresco-share-encryption.jar", + "alfresco-content-services-share-distribution-" + projectVersion + "/amps/alfresco-share-services.amp" + ); + } + } + + private File[] getDistributionZip(String dirName, String prefix) throws Exception + { + String resourcePath = Paths.get("").toAbsolutePath().getParent().getParent().toString() + "/" + dirName + "/" + "target" + "/"; + File distributionZip = new File(resourcePath); + FilenameFilter zipFileFilter = (dir, name) -> { + if (name.startsWith(prefix) && name.endsWith(FORMAT)) + { + return true; + } + else + { + return false; + } + }; + + return distributionZip.listFiles(zipFileFilter); + } + + private List getZipEntries(String filePath) throws Exception + { + List zipEntries = new ArrayList<>(); + ZipFile zipFile = new ZipFile(new File(filePath)); + Enumeration entries = zipFile.entries(); + while (entries.hasMoreElements()) + { + ZipEntry entry = entries.nextElement(); + zipEntries.add(entry.toString()); + } + return zipEntries; + } + + private Model getPomValues() throws Exception + { + String parentPom = Paths.get("").toAbsolutePath().getParent().getParent().toString() + "/pom.xml"; + MavenXpp3Reader reader = new MavenXpp3Reader(); + Model model = reader.read(new FileReader(parentPom)); + return model; + } +} diff --git a/tests/tas-distribution-zip/src/test/resources/distribution-suite.xml b/tests/tas-distribution-zip/src/test/resources/distribution-suite.xml new file mode 100644 index 0000000000..5d509c8c3a --- /dev/null +++ b/tests/tas-distribution-zip/src/test/resources/distribution-suite.xml @@ -0,0 +1,9 @@ + + + + + + + + + From 478303664243ad0846972bc0b314e28590f1602a Mon Sep 17 00:00:00 2001 From: Eva Vasques Date: Tue, 10 Oct 2023 15:10:31 +0100 Subject: [PATCH 6/6] Trigger [tas] tests