Skip to content

Commit

Permalink
Feature/acs 4653 migrate to gha (#1777)
Browse files Browse the repository at this point in the history
* ACS-3841 Migrate to GHA (#1631)

(cherry picked from commit eb6b6a6)
  • Loading branch information
antoniojfelix authored and tpage-alfresco committed Mar 11, 2024
1 parent a041ae9 commit 28f0c42
Show file tree
Hide file tree
Showing 21 changed files with 757 additions and 469 deletions.
File renamed without changes.
528 changes: 528 additions & 0 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions .github/workflows/master_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Master/Release branch workflow

on:
push:
branches:
- master
- release/**

env:
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

jobs:
run_ci:
uses: ./.github/workflows/ci.yml
secrets: inherit
push_to_nexus:
name: "Push to Nexus"
runs-on: ubuntu-latest
needs: [run_ci]
if: >
!failure() &&
!contains(github.event.head_commit.message, '[no release]') &&
github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
- uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]
- uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]
- name: "Init"
run: bash ./scripts/ci/init.sh
- uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]
with:
username: ${{ env.GIT_USERNAME }}
email: ${{ env.GIT_EMAIL }}
global: true
- name: "Release"
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
run: |
bash scripts/ci/verify_release_tag.sh
bash scripts/ci/maven_release.sh
- name: "Clean Maven cache"
run: bash ./scripts/ci/cleanup_cache.sh
update_downstream:
name: "Update alfresco-enterprise-repo"
runs-on: ubuntu-latest
needs: [push_to_nexus]
if: >
!failure() &&
!contains(github.event.head_commit.message, '[no downstream]') &&
github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v3
- uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]
- uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]
- name: "Init"
run: bash ./scripts/ci/init.sh
- uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]
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
415 changes: 0 additions & 415 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# alfresco-community-repo

[![Build Status](https://travis-ci.com/Alfresco/alfresco-community-repo.svg?branch=master)](https://travis-ci.com/Alfresco/alfresco-community-repo)
[![Build Status](https://github.com/Alfresco/alfresco-community-repo/actions/workflows/master_release.yml/badge.svg?branch=7.3.1)](https://github.com/Alfresco/alfresco-community-repo/actions/workflows/master_release.yml)

#### Alfresco Core

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2023 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 <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.utils;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

import org.testng.IMethodInstance;
import org.testng.IMethodInterceptor;
import org.testng.ITestContext;

/**
* A method interceptor that sorts test classes alphabetically.
*
* @author Damian Ujma
*/
public class AlphabeticalPriorityInterceptor implements IMethodInterceptor
{
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods,
ITestContext context)
{
return methods.stream()
.sorted(Comparator.comparing(methodInstance -> methodInstance.getMethod().getTestClass().getName()))
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="TestNG AllTestSuite" configfailurepolicy="continue" verbose="1" time-out="300000">
<test name="restapi">
<listeners>
<listener class-name="org.alfresco.rest.rm.community.utils.AlphabeticalPriorityInterceptor" />
</listeners>
<test name="restapi" preserve-order="false">
<packages>
<package name="org.alfresco.rest.rm.community.*"/>
</packages>
Expand Down
2 changes: 1 addition & 1 deletion amps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</modules>

<!-- When adding a new AMP, create a profile for it here to add the module. The AMPS environment variable may
then be used in aliases to optionally build it. The profile will however need to be added to the Travis
then be used in aliases to optionally build it. The profile will however need to be added to the Github Actions
build scripts. The share-services AMP is build by default as it is very fast. -->
<profiles>
<profile>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
set +vx

function isPullRequestBuild() {
test "${TRAVIS_PULL_REQUEST}" != "false"
test "${PULL_REQUEST}" != "false"
}

function isBranchBuild() {
test "${TRAVIS_PULL_REQUEST}" = "false"
test "${PULL_REQUEST}" = "false"
}

function cloneRepo() {
local REPO="${1}"
local TAG_OR_BRANCH="${2}"

printf "Clonning \"%s\" on %s\n" "${TAG_OR_BRANCH}" "${REPO}"
printf "Cloning \"%s\" on %s\n" "${TAG_OR_BRANCH}" "${REPO}"

# clone the repository branch/tag
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" >/dev/null
Expand Down Expand Up @@ -82,15 +82,9 @@ function remoteBranchExists() {
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}"
if remoteBranchExists "${UPSTREAM_REPO}" "${BRANCH_NAME}" ; then
echo "${BRANCH_NAME}"
exit 0
fi

Expand Down Expand Up @@ -190,4 +184,4 @@ function retieveLatestTag() {
rm -rf "${LOCAL_PATH}"
}

set -vx
set -vx
File renamed without changes.
40 changes: 40 additions & 0 deletions scripts/ci/docker-compose/docker-compose-db.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: "3"

services:
postgres:
profiles: ["postgres"]
image: postgres:${POSTGRES_VERSION}
environment:
- POSTGRES_PASSWORD=alfresco
- POSTGRES_USER=alfresco
- POSTGRES_DB=alfresco
command: postgres -c max_connections=300
ports:
- "5433:5432"
mariadb:
profiles: ["mariadb"]
image: mariadb:${MARIADB_VERSION}
command: --transaction-isolation=READ-COMMITTED --max-connections=300 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
environment:
- MYSQL_ROOT_PASSWORD=alfresco
- MYSQL_USER=alfresco
- MYSQL_DATABASE=alfresco
- MYSQL_PASSWORD=alfresco
ports:
- "3307:3306"
mysql:
profiles: ["mysql"]
image: mysql:${MYSQL_VERSION}
command: --transaction-isolation='READ-COMMITTED'
environment:
- MYSQL_ROOT_PASSWORD=alfresco
- MYSQL_USER=alfresco
- MYSQL_DATABASE=alfresco
- MYSQL_PASSWORD=alfresco
ports:
- "3307:3306"
activemq:
image: alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8
ports:
- "5672:5672" # AMQP
- "61616:61616" # OpenWire
26 changes: 26 additions & 0 deletions scripts/ci/docker-compose/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: "3"

services:
transform-core-aio:
profiles: ["with-transform-core-aio"]
image: alfresco/alfresco-transform-core-aio:${TRANSFORMERS_TAG}
environment:
JAVA_OPTS: " -Xms256m -Xmx256m"
ports:
- "8090:8090"
postgres:
image: postgres:14.4
profiles: ["default", "with-transform-core-aio", "postgres"]
environment:
- POSTGRES_PASSWORD=alfresco
- POSTGRES_USER=alfresco
- POSTGRES_DB=alfresco
command: postgres -c max_connections=300
ports:
- "5433:5432"
activemq:
profiles: ["default", "with-transform-core-aio", "activemq"]
image: alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8
ports:
- "5672:5672" # AMQP
- "61616:61616" # OpenWire
2 changes: 1 addition & 1 deletion scripts/travis/init.sh → scripts/ci/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -vex
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"

# Maven Setup
mkdir -p "${HOME}/.m2" && cp -f .travis.settings.xml "${HOME}/.m2/settings.xml"
mkdir -p "${HOME}/.m2" && cp -f .github/.ci.settings.xml "${HOME}/.m2/settings.xml"
find "${HOME}/.m2/repository/" -type d -name "*-SNAPSHOT*" | xargs -r -l rm -rf

# Docker Logins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,19 @@ PS4="\[\e[35m\]+ \[\e[m\]"
set -vex
pushd "$(dirname "${BASH_SOURCE[0]}")/../../"


# Use full history for release
git checkout -B "${TRAVIS_BRANCH}"
# Add email to link commits to user
git config user.email "${GIT_EMAIL}"
git checkout -B "${BRANCH_NAME}"

# Run the release plugin - with "[skip ci]" in the release commit message
mvn -B \
-Pall-tas-tests \
-Pags \
"-Darguments=-Pall-tas-tests -Pags -DskipTests -Dbuild-number=${TRAVIS_BUILD_NUMBER}" \
"-Darguments=-Pall-tas-tests -Pags -DskipTests -Dbuild-number=${BUILD_NUMBER}" \
release:clean release:prepare release:perform \
-DscmCommentPrefix="[maven-release-plugin][skip ci] " \
-Dusername="${GIT_USERNAME}" \
-Dpassword="${GIT_PASSWORD}"


popd
set +vex
echo "=========================== Finishing Release Script =========================="
Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions scripts/ci/tests/AppContext05TestSuite-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

echo "=========================== Starting AppContext05TestSuite setup ==========================="
PS4="\[\e[35m\]+ \[\e[m\]"
set -vex
pushd "$(dirname "${BASH_SOURCE[0]}")/../../../"

mkdir -p "${HOME}/tmp"
cp repository/src/test/resources/realms/alfresco-realm.json "${HOME}/tmp"
echo "HOST_IP=$(hostname -I | cut -f1 -d' ')" >> $GITHUB_ENV
docker run -d -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -e DB_VENDOR=h2 -p 8999:8080 -e KEYCLOAK_IMPORT=/tmp/alfresco-realm.json -v $HOME/tmp/alfresco-realm.json:/tmp/alfresco-realm.json alfresco/alfresco-identity-service:1.2

popd
set +vex
echo "=========================== Finishing AppContext05TestSuite setup =========================="
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ 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}"
#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 current Community version - latest tag on the current branch
VERSION="$(git describe --abbrev=0 --tags)"

DOWNSTREAM_REPO="github.com/Alfresco/alfresco-enterprise-repo.git"

cloneRepo "${DOWNSTREAM_REPO}" "${TRAVIS_BRANCH}"
cloneRepo "${DOWNSTREAM_REPO}" "${BRANCH_NAME}"

cd "$(dirname "${BASH_SOURCE[0]}")/../../../$(basename "${DOWNSTREAM_REPO%.git}")"

Expand All @@ -33,8 +33,8 @@ git status
git --no-pager diff pom.xml
git add pom.xml

if [[ "${TRAVIS_COMMIT_MESSAGE}" =~ \[force[^\]]*\] ]]; then
FORCE_TOKEN=$(echo "${TRAVIS_COMMIT_MESSAGE}" | sed "s|^.*\(\[force[^]]*\]\).*$|\1|g")
if [[ "${COMMIT_MESSAGE}" =~ \[force[^\]]*\] ]]; then
FORCE_TOKEN=$(echo "${COMMIT_MESSAGE}" | sed "s|^.*\(\[force[^]]*\]\).*$|\1|g")
git commit --allow-empty -m "${FORCE_TOKEN} Update upstream version to ${VERSION}"
git push
elif git status --untracked-files=no --porcelain | grep -q '^' ; then
Expand Down
File renamed without changes.
26 changes: 0 additions & 26 deletions scripts/travis/source_clear.sh

This file was deleted.

0 comments on commit 28f0c42

Please sign in to comment.