diff --git a/.github/workflows/adf_alpha.yml b/.github/workflows/adf_alpha.yml deleted file mode 100644 index 9d69f9f308..0000000000 --- a/.github/workflows/adf_alpha.yml +++ /dev/null @@ -1,98 +0,0 @@ -name: "upstream adf" - -on: - workflow_call: - inputs: - repo_to_update: - description: Repository to update - type: string - required: false - default: alfresco-applications - workflow_dispatch: - inputs: - cluster_operation: - description: trigger adf test - type: choice - required: true - options: - - TRIGGER_ALPHA_ADF - default: TRIGGER_ALPHA_ADF - repo_to_update: - description: Repository to update - type: choice - required: true - options: - - all - - alfresco-content-app - - alfresco-applications - - alfresco-apps - default: all - -env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - GITHUB_BRANCH: ${{ github.ref_name }} - GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} - GH_BUILD_DIR: ${{ github.workspace }} - GH_COMMIT: ${{ github.sha }} - BUILD_ID: ${{ github.run_id }} - GH_RUN_NUMBER: ${{ github.run_attempt }} - GH_BUILD_NUMBER: ${{ github.run_id }} - JOB_ID: ${{ github.run_id }} - PROXY_HOST_BPM: ${{ secrets.E2E_HOST }} - E2E_HOST_APA: ${{ secrets.E2E_HOST_APA }} - E2E_HOST: ${{ secrets.E2E_HOST }} - E2E_USERNAME: ${{ secrets.E2E_ADMIN_EMAIL_IDENTITY }} - E2E_PASSWORD: ${{ secrets.E2E_PASSWORD }} - E2E_ADMIN_EMAIL_IDENTITY: ${{ secrets.E2E_ADMIN_EMAIL_IDENTITY }} - E2E_ADMIN_PASSWORD_IDENTITY: ${{ secrets.E2E_ADMIN_PASSWORD_IDENTITY }} - USERNAME_ADF: ${{ secrets.E2E_USERNAME }} - PASSWORD_ADF: ${{ secrets.E2E_PASSWORD }} - URL_HOST_ADF: ${{ secrets.URL_HOST_ADF }} - IDENTITY_ADMIN_EMAIL: ${{ secrets.E2E_ADMIN_EMAIL_IDENTITY }} - IDENTITY_ADMIN_PASSWORD: ${{ secrets.E2E_ADMIN_PASSWORD_IDENTITY }} - AWS_S3_BUCKET_ACTIVITI_LICENSE: ${{ secrets.AWS_S3_BUCKET_ACTIVITI_LICENSE }} - HOST_SSO: ${{ secrets.HOST_SSO }} - LOG_LEVEL: "ERROR" - E2E_LOG_LEVEL: "ERROR" - E2E_MODELER_USERNAME: ${{ secrets.E2E_MODELER_USERNAME }} - E2E_MODELER_PASSWORD: ${{ secrets.E2E_MODELER_PASSWORD }} - EXTERNAL_ACS_HOST: ${{ secrets.EXTERNAL_ACS_HOST }} - E2E_DEVOPS_USERNAME: ${{ secrets.E2E_DEVOPS_USERNAME }} - E2E_DEVOPS_PASSWORD: ${{ secrets.E2E_DEVOPS_PASSWORD }} - USERNAME_SUPER_ADMIN_ADF: ${{ secrets.USERNAME_SUPER_ADMIN_ADF }} - PASSWORD_SUPER_ADMIN_ADF: ${{ secrets.PASSWORD_SUPER_ADMIN_ADF }} - HR_USER: ${{ secrets.HR_USER }} - HR_USER_PASSWORD: ${{ secrets.HR_USER_PASSWORD }} - NPM_REGISTRY_ADDRESS: ${{ secrets.NPM_REGISTRY_ADDRESS }} - NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} - DOCKER_REPOSITORY_USER: ${{ secrets.DOCKER_REPOSITORY_USER }} - DOCKER_REPOSITORY_PASSWORD: ${{ secrets.DOCKER_REPOSITORY_PASSWORD }} - DOCKER_REPOSITORY_DOMAIN: ${{ secrets.DOCKER_REPOSITORY_DOMAIN }} - DOCKER_REPOSITORY_STORYBOOK: "${{ secrets.DOCKER_REPOSITORY_DOMAIN }}/alfresco/storybook" - DOCKER_REPOSITORY: "${{ secrets.DOCKER_REPOSITORY_DOMAIN }}/alfresco/demo-shell" - NODE_OPTIONS: "--max-old-space-size=5120" - GH_PACKAGES_READ_ONLY_TOKEN: "${{ secrets.HYLAND_GH_PACKAGES_READ_ONLY_TOKEN }}" - -jobs: - trigger_adf: - name: trigger adf - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: install NPM - uses: actions/setup-node@v3 - with: - node-version-file: '.nvmrc' - cache-dependency-path: package-lock.json - - name: Trigger Alpha ADF child build - shell: bash - if: ${{ contains(github.event.head_commit.message, '[trigger adf]') || inputs.cluster_operation == 'TRIGGER_ALPHA_ADF' || github.event.schedule == '0 12 * * *' }} - run: | - npm install github-api - ./scripts/github/update/update-project.sh -p $GH_BUILD_NUMBER -t $GH_TOKEN -v alpha -c $GH_COMMIT -r ${{ inputs.repo_to_update }} - exit $? - diff --git a/.github/workflows/cron-upstream.yml b/.github/workflows/cron-upstream.yml deleted file mode 100644 index 895e776c93..0000000000 --- a/.github/workflows/cron-upstream.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: "cron upstream daily" - -on: - schedule: - - cron: '0 12 * * *' - -jobs: - adf-upstream-alpha-alfresco-aca: - name: trigger upstream alpha for alfresco-content-app - uses: ./.github/workflows/adf_alpha.yml - secrets: inherit - with: - repo_to_update: alfresco-content-app - - adf-upstream-alpha-alfresco-apps: - name: trigger upstream alpha for alfresco-applications - uses: ./.github/workflows/adf_alpha.yml - secrets: inherit - with: - repo_to_update: alfresco-applications diff --git a/scripts/github/update/pr-creator.js b/scripts/github/update/pr-creator.js deleted file mode 100644 index acd307ec48..0000000000 --- a/scripts/github/update/pr-creator.js +++ /dev/null @@ -1,135 +0,0 @@ -const GitHub = require('github-api'); -let program = require('commander'); - -const ORGANISATION = 'Alfresco'; -const ORIGIN_REPO = 'alfresco-ng2-components'; -const ATTEMPT_MSG = [ - `Could you check it please? 🤖`, - `Emm did you forget? 🤡`, - `Where are you? 🤷`, - `We are going to die!! 👻`, - `I guess the Apocalypse happened and I am alone 👽` -]; - -GIVE_UP_MSG = `I gave up, it will be fix eventually 🔴`; - -class PrCreator { - constructor(githubUser, githubRepo, token, commit) { - this.github = new GitHub({token}); - this.repoOrigin = this.github.getRepo(githubUser, ORIGIN_REPO); - this.repoDestination = this.github.getRepo(githubUser, githubRepo); - this.issue = this.github.getIssues(githubUser, githubRepo); - this.commit = commit; - } - - async createOrUpdate(title, head, base, commit) { - const { data: prs } = await this.repoDestination.listPullRequests({ state: 'open', head: `${ORGANISATION}:${head}`, base }); - - if (prs.length < 1) { - const { data: pr } = await this.repoDestination.createPullRequest({ title, head, base, body: `sha:${commit}` }); - return pr.number; - } else { - const upstreamPrOpen = prs[0]; - // override the title to contains the latest adf dep number - await this.repoDestination.updatePullRequest(upstreamPrOpen.number, { title, body: `sha:${commit}` }); - return upstreamPrOpen.number; - } - - } - - async fetchContributors(shaFrom, shaTo) { - const mapAuthors = new Map(); - let upstreamShaFound = true; - const listCommits = await this.repoOrigin.listCommits(({sha: shaFrom})) - let index = 0; - while(upstreamShaFound) { - if (listCommits.data[index].sha === shaTo ) { - upstreamShaFound = false; - } else { - mapAuthors.set(listCommits.data[index].author.login, listCommits.data[index].commit.author.name); - } - index++; - } - return mapAuthors; - } - - async createComment(issueOrPrNumber, head, base, shaOriginHead ) { - const shaTo = await this.getShaTo(head, base); - const contributors = await this.fetchContributors(shaOriginHead, shaTo); - const attemptCount = await this.getCommentAmount(issueOrPrNumber); - const commentMsg = this.createCommentBody(contributors, attemptCount); - await this.issue.createIssueComment(issueOrPrNumber, commentMsg); - } - - createCommentBody(contributors, attemptCount) { - const flattenedContributors = this.flattenContributors(contributors); - const attemptMsg = attemptCount <= 5 ? ATTEMPT_MSG[attemptCount] : GIVE_UP_MSG - const tmpl = ` Attempt: ${attemptCount+1} - you are part of the contributors: - ${flattenedContributors} - ${attemptMsg} - `; - return tmpl; - } - - flattenContributors(contributors) { - let names = []; - for (let key of contributors.keys()) { - names.push(`@${key}`) - } - return names.join(', '); - } - - async getShaTo(head, base) { - const { data: closedUpstreamPRs } = await this.repoDestination.listPullRequests({ state: 'closed', head: `${ORGANISATION}:${head}`, base }); - const latestClosedUpstream = closedUpstreamPRs[0]; - const shaTo = latestClosedUpstream.body.split(':')[1].trim(); - return shaTo; - } - - async getCommentAmount(issueOrPrNumber) { - const { data: listComments } = await this.issue.listIssueComments(issueOrPrNumber); - return listComments.length; - } -} - -async function main() { - - program - .version('0.1.0') - .option('--host [type]', 'Remote environment host adf.lab.com ') - .option('-t, --token [type]', 'token') - .option('-h, --head [type]', 'head') - .option('-r, --repo [type]', 'repo') - .option('-c, --commit [type]', 'commit') - .option('-title, --title [type]', 'title') - .parse(process.argv); - - const { token, title, head, repo, commit } = program, - prCreator = new PrCreator(ORGANISATION, repo, token, commit); - - if (!token || !head || !title) { - throw new Error('Each of the parameters have to be provided. --token, --title, --head'); - } - const baseBranchName = 'develop'; - - const prNumber = await prCreator.createOrUpdate(title, head, baseBranchName, commit); - await prCreator.createComment(prNumber, head, baseBranchName, commit); - - return prNumber; -} - -main() - .then(prNumber => { - console.log("======= PR Created ========="); - - console.log(prNumber) - process.exit(0); - }) - .catch(error => { - - console.error("======= Impossible create PR ========="); - console.error(error.response.status); - console.error(error.response.statusText); - process.exit(1); - }); diff --git a/scripts/github/update/update-project.sh b/scripts/github/update/update-project.sh deleted file mode 100755 index a3d278492d..0000000000 --- a/scripts/github/update/update-project.sh +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env bash - -git config --global user.name "alfresco-build" -git config --global user.email "alfresco-build@hyland.com" - -BUILD_PIPELINE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -REPO_DIR="$BUILD_PIPELINE_DIR/../.." - -TEMP_GENERATOR_DIR=".tmp-generator"; -BRANCH_TO_CREATE="update-alfresco-dependencies" -TOKEN="" -PR_NUMBER="" -DRY_RUN="false" - -show_help() { - echo "Usage: create-updatebranch.sh" - echo "" - echo "-t or --token: Github ouath token" - echo "-p or --pr: Originating jsapi PR number" - echo "-v or --version version to update" - echo "-d or --dry-run: The script won't execute critical operation, just simulate them" - echo "-r or --repo: Repository to update" -} - -set_token() { - TOKEN=$1 -} - -set_pr() { - PR_NUMBER=$1 -} - -version() { - VERSION=$1 -} - -set_commit() { - COMMIT=$1 -} - -set_dryrun() { - - DRY_RUN="true" - -} - -set_repo() { - REPO=$1 -} - -update_dependency() { - PKG=$1 - PKG_VERSION=$(npm view $PKG@$VERSION version) - echo "Update $PKG to $PKG_VERSION in $NAME_REPO" - - for i in $(find . ! -path "*/node_modules/*" -name "package-lock.json" | xargs grep -l $PKG); do - directory=$(dirname $i) - echo "Update $PKG in $directory" - ( cd $directory ; npm i --ignore-scripts $PKG@$PKG_VERSION --save-exact) - done - - git add . - git commit -n -m "[ci:force][auto-commit] Update $PKG to $PKG_VERSION for branch: $BRANCH_TO_CREATE originated from $PKG PR: $PR_NUMBER" -} - -update_js_dependency() { - PKG=$1 - PKG_VERSION=$2 - echo "Update $PKG to $PKG_VERSION in $NAME_REPO" - - for i in $(find . ! -path "*/node_modules/*" -name "package-lock.json" | xargs grep -l $PKG); do - directory=$(dirname $i) - echo "Update $PKG in $directory" - ( cd $directory ; npm i --ignore-scripts --save-exact $PKG@$PKG_VERSION) - done - - git add . - git commit -n -m "[ci:force][auto-commit] Update $PKG to $PKG_VERSION for branch: $BRANCH_TO_CREATE originated from $PKG PR: $PR_NUMBER" -} - -update() { - NAME_REPO=$1 - PKG_VERSION=$(npm view @alfresco/adf-core@$VERSION version) - - echo "Update dependencies for repo: $NAME_REPO" - git clone https://$TOKEN@github.com/Alfresco/$NAME_REPO.git $TEMP_GENERATOR_DIR - cd $TEMP_GENERATOR_DIR - - git fetch - - # Checkout branch if exist, otherwise create it - BRANCH_CREATED=false - if git checkout $BRANCH_TO_CREATE 2>/dev/null ; then - git reset --hard origin/develop - else - BRANCH_CREATED=true - git checkout -b $BRANCH_TO_CREATE origin/develop - fi - - update_js_dependency "@alfresco/js-api" $JS_API_INSTALLED - - update_dependency "@alfresco/adf-extensions" - update_dependency "@alfresco/adf-core" - update_dependency "@alfresco/adf-content-services" - update_dependency "@alfresco/adf-process-services" - update_dependency "@alfresco/adf-process-services-cloud" - update_dependency "@alfresco/adf-cli" - update_dependency "@alfresco/adf-testing" - - if [ "$BRANCH_CREATED" = true ]; then - git push origin $BRANCH_TO_CREATE - else - git push --force origin $BRANCH_TO_CREATE - fi - - node $BUILD_PIPELINE_DIR/pr-creator.js --token=$TOKEN --title="Update branch for ADF ${PKG_VERSION} and JS-API ${JS_API_INSTALLED} [ci:force]" --head=$BRANCH_TO_CREATE --repo=$NAME_REPO --commit=$COMMIT - - cd .. - rm -rf $TEMP_GENERATOR_DIR -} - -while [[ $1 == -* ]]; do - case "$1" in - -h|--help|-\?) show_help; exit 0;; - -t|--token) set_token $2; shift; shift;; - -p|--pr) set_pr $2; shift; shift;; - -v|--version) version $2; shift 2;; - -c|--commit) set_commit $2; shift 2;; - -d|--dry-run) set_dryrun $2; shift; shift;; - -r|--repo) set_repo $2; shift; shift;; - -*) echo "invalid option: $1" 1>&2; show_help; exit 1;; - esac -done - -JS_API_INSTALLED=$(cat package.json | jq -r '.dependencies["@alfresco/js-api"]') -echo "Current installed JS-API $JS_API_INSTALLED" - -cd "$REPO_DIR" - -if [[ (-z "$TOKEN") || (-z "$VERSION") ]] - then - echo "Each of token (-t) pr number (-p) and repo (-r) have to be set. See -help." - exit 1; -fi - -rm -rf $TEMP_GENERATOR_DIR - - -if [ "$DRY_RUN" = "false" ]; then - if [ "$REPO" = "all" ]; then - update "generator-alfresco-adf-app" - update "alfresco-content-app" - update "alfresco-applications" - update "alfresco-apps" - else - update $REPO - fi -else - echo "[dry-run] it would have update repos: $REPO " -fi - -exit $?