Skip to content

Commit

Permalink
[ACA-4652] Run unit tests as one GH job, add e2es as GH job (#2997)
Browse files Browse the repository at this point in the history
* [ACA-4652] Run unit tests as one GH job, add e2es as GH job

* [ACA-4652] Fix yaml syntax

* [ACA-4652] Fix if syntax

* [ACA-4652] Correct syntax

* [ACA-4652] Correct syntax

* [ACA-4652] Each job must contain uses or run

* [ACA-4652] Migrate uploading/downloading build artifacts, migrate before install

* [ACA-4652] Fix bad substitution

* [ACA-4652] Fix string merging in bash

* [ACA-4652] Bash fix

* [ACA-4652] Install aws before downloading/uploading artifacts

* [ACA-4652] Add setup with aws config action

* [ACA-4652] Add aws-region

* [ACA-4652] Use aws default region

* [ACA-4652] Log github event

* [ACA-4652] Log workflow run

* [ACA-4652] Fix commit logging

* [ACA-4652] Use action to get current commit msg

* [ACA-4652] Add correct version of build tools

* [ACA-4652] Get commit msg from env

* [ACA-4652] Get commit msg in the same job

* [ACA-4652] Final commit msg test

* [ACA-4652] Fix logging

* [ACA-4652] Cleanup commit msg, correct s3 bucket

* [link-adf:AAE-12767] Test adf linking

* [link-adf:AAE-12767] Test adf linking finalize

* [link-adf:AAE-12767] Tweak finalize job

* [link-adf:AAE-12767] Get commit msg in before install

* [link-adf:AAE-12767] Add missing adfprod configs

* [ACA-4652] Migrate before and after e2e scripts to GHA

* [ACA-4652] Add before e2e logging

* [ACA-4652] Use new GH secrets

* [ACA-4652] Remove logs, add envsub

* [ACA-4652] Install envsub globally

* [ACA-4652] Log replaced config

* [ACA-4652] Add missing env variable

* [ACA-4652] Add e2e run as GH action

* [ACA-4652] Remove logging, fix download path

* [ACA-4652] Disable protractor smartrunner artifact

* [ACA-4652] Install webdriver-manager

* [ACA-4652] Disable failing download on Travis, npm ci in before e2e

* [ACA-4652] Missing shell

* [ACA-4652] Restore artifact download

* [ACA-4652] Download smartrunner artifact only when present

* [ACA-4652] Check run attempt

* [ACA-4652] Correct attempt check

* [ACA-4652] Stop running e2es in Travis for now

* [ACA-4652] Run Travis e2es again, add test suite id

* [ACA-4652] Add test suite id to after e2e action

* [ACA-4652] Remove additional install

* [ACA-4652] CR fixes, remove some Travis config that is already migrated

* [ACA-4652] Cleanup setup leftover

* [ACA-4652] Propagate aws credentials

* [ACA-4652] Fix aws default region

* [ACA-4652] Misspelled variable fix

* [ACA-4652] Propagate aws region

* [ACA-4652] Rename PR workflow

* [ACA-4652] Download artifact only if bucket exists

* [ACA-4652] Run test even is aws bucket doesn't exist

* [ACA-4652] Fix aws download error

* [ACA-4652] Check if file exists before downloading

* [ACA-4652] Remove uploading/downloading e2e artifact after successful run

* [ACA-4652] Add missing check to finalize stage
  • Loading branch information
MichalKinas committed Mar 2, 2023
1 parent b859489 commit 01f7e3c
Show file tree
Hide file tree
Showing 15 changed files with 559 additions and 275 deletions.
25 changes: 25 additions & 0 deletions .github/actions/adf-linking/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "ADF linking"
description: "ADF linking"

runs:
using: "composite"
steps:
- name: clone and install
shell: bash
run: |
if [[ $COMMIT_MESSAGE == *"[link-adf:"* ]]; then
echo "BUILD_OPTS=--configuration=adfprod,e2e" >> $GITHUB_ENV
echo "TEST_OPTS=--configuration=adfprod" >> $GITHUB_ENV
echo "E2E_PROTRACTOR_OPTS=--with-local-adf" >> $GITHUB_ENV
echo "E2E_TSCONFIG=tsconfig.e2e.adf.json" >> $GITHUB_ENV
BRANCH=`echo $COMMIT_MESSAGE | grep -o "\[link-adf\:[^]]*\]" | sed -e 's#\[link-adf:##g' | sed -e 's#\]##g'`
echo "Checking out ADF's branch: ${BRANCH}" && \
git clone https://github.com/Alfresco/alfresco-ng2-components.git --depth=1 --branch ${BRANCH} ../alfresco-ng2-components
# ADF theming needs it the styling
CWD=`pwd`
cd ../alfresco-ng2-components
npm install @angular/material
cd $CWD
else
echo -e "\e[32mUsing ADF from installed node_modules.\e[0m"
fi ;
30 changes: 30 additions & 0 deletions .github/actions/after-e2e/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "After e2e"
description: "After e2e"

env:
storage_file: "./storage-state/AdminUserState.json"

inputs:
id:
description: 'test suite id'
required: true
type: number
aws-access-key-id:
description: 'aws access key id'
required: true
type: string
aws-secret-access-key:
description: 'aws secret access key'
required: true
type: string
aws-region:
description: 'aws region'
required: true
type: string

runs:
using: "composite"
steps:
- name: Remove storage file
shell: bash
run: rm -f ${{ env.storage_file }}
68 changes: 68 additions & 0 deletions .github/actions/before-e2e/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: "Before e2e"
description: "Before e2e"

inputs:
from:
description: 'path to download the artifact'
required: true
type: string
to:
description: 'path to save artifact to'
required: true
type: string
id:
description: 'test suite id'
required: true
type: number
aws-access-key-id:
description: 'aws access key id'
required: true
type: string
aws-secret-access-key:
description: 'aws secret access key'
required: true
type: string
aws-region:
description: 'aws region'
required: true
type: string

runs:
using: "composite"
steps:
- name: Check content UP
shell: bash
run: ./node_modules/@alfresco/adf-cli/bin/adf-cli check-cs-env --host $APP_CONFIG_ECM_HOST -u $ADMIN_EMAIL -p $ADMIN_PASSWORD || exit 1
- name: Download artifacts
uses: ./.github/actions/download-job-artifact
with:
artifact: ${{ inputs.from }}
output: ${{ inputs.to }}
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: ${{ inputs.aws-region }}
- name: Replace variables in app.config.json
shell: bash
run: |
npm install -g envsub
APP_CONFIG_FILE_PATH="${{ inputs.to }}/app.config.json"
EXTRA_ENV_SETTINGS=""
envsub $EXTRA_ENV_SETTINGS --all $APP_CONFIG_FILE_PATH $APP_CONFIG_FILE_PATH || exit 1
echo -n " \_ Validating replaced config file ... ";
$(npm bin)/ajv validate -s ./node_modules/@alfresco/adf-core/app.config.schema.json -d $APP_CONFIG_FILE_PATH --errors=text --verbose || exit 4
if grep -E -q '\$\{[A-Z0-9_]*\}' $APP_CONFIG_FILE_PATH; then
echo -e "\e[31m \_ ERROR: Variables are still present in the app.config.json file. Some of them might not have default value set.\e[0m";
exit 5;
fi
- name: Update webdriver-manager
shell: bash
run: |
npm install -g webdriver-manager
if [ "$CI" = "true" ]; then
export chrome=$(google-chrome --product-version)
echo "Updating wevdriver-manager with chromedriver: $chrome."
webdriver-manager update --gecko=false --versions.chrome=$chrome
else
echo "Updating wedriver-manager with latest chromedriver, be sure to use evergreen Chrome."
webdriver-manager update --gecko=false
fi
48 changes: 48 additions & 0 deletions .github/actions/before-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "Before install and variables setup"
description: "Before install and variables setup"

inputs:
artifact:
description: 'path to the artifact to archieve (tar.bz2) and upload (like ./dist)'
required: true
type: string
output:
description: 'the S3 object to copy it to, like: s3://bucket-name/folder/whatever.tar.bz2'
required: true
type: string

runs:
using: "composite"
steps:
- uses: Alfresco/alfresco-build-tools/.github/actions/get-commit-message@v1.35.0
- name: setup variables
shell: bash
run: |
echo "BUILD_OPTS=--configuration=production,e2e" >> $GITHUB_ENV
echo "TEST_OPTS=" >> $GITHUB_ENV
echo "E2E_PROTRACTOR_OPTS=" >> $GITHUB_ENV
echo "E2E_TSCONFIG=tsconfig.e2e.json" >> $GITHUB_ENV
echo "GIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "SMART_RUNNER_DIRECTORY=.protractor-smartrunner" >> $GITHUB_ENV
echo "BASE_HASH=.protractor-smartrunner" >> $GITHUB_ENV
echo "HEAD_HASH=HEAD" >> $GITHUB_ENV
- name: setup S3 caching
shell: bash
run: |
S3_DBP_PATH="s3://alfresco-travis-builds/aca"
if [ "${{ github.event_name }}" == "push" ]; then
BRANCH_NAME=${GITHUB_REF##*/}
S3_DBP_ROOT_FOLDER="$S3_DBP_PATH/$BRANCH_NAME"
elif [ "${{ github.event_name }}" == "pull_request" ]; then
BRANCH_NAME=${GITHUB_BASE_REF}
S3_DBP_ROOT_FOLDER="$S3_DBP_PATH/$BRANCH_NAME"
echo "BASE_HASH=origin/$BRANCH_NAME" >> $GITHUB_ENV
elif [ "${TRAVIS_EVENT_TYPE}" == "schedule" ]; then
S3_DBP_ROOT_FOLDER="$S3_DBP_PATH/cron"
else
S3_DBP_ROOT_FOLDER="$S3_DBP_PATH/api"
fi
echo "S3_DBP_FOLDER="$S3_DBP_ROOT_FOLDER/${{ github.run_id }}"" >> $GITHUB_ENV
- name: ADF linking
if: ${{ github.event_name == 'pull_request'}}
uses: ./.github/actions/adf-linking
44 changes: 44 additions & 0 deletions .github/actions/download-job-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "Download build artifacts"
description: "Download build artifacts"

inputs:
artifact:
description: 'path to the s3 artifact (tar.bz2) to download and extract'
required: true
type: string
output:
description: 'directory to extract the archive to'
required: true
type: string
aws-access-key-id:
description: 'aws access key id'
required: true
type: string
aws-secret-access-key:
description: 'aws secret access key'
required: true
type: string
aws-region:
description: 'aws region'
required: true
type: string

runs:
using: "composite"
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: ${{ inputs.aws-region }}
- name: download build artifacts from s3
shell: bash
run: |
test ! -d ${{ inputs.output }} && mkdir -p ${{ inputs.output }}
aws s3 cp ${{ inputs.artifact }} ./s3-artifact.tmp
echo 'artifact download done'
tar -xvf ./s3-artifact.tmp -C ${{ inputs.output }} >&/dev/null
echo 'tar the artifact done'
rm ./s3-artifact.tmp
echo 'remove tmp file'
31 changes: 31 additions & 0 deletions .github/actions/run-e2e/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Run e2e"
description: "Run e2e"

inputs:
options:
description: 'Options'
required: true
type: string
test-runner:
description: 'Test runner'
required: false
type: string
default: 'protractor'

runs:
using: "composite"
steps:
- name: Setup and run with options
shell: bash
run: |
./node_modules/.bin/tsc -p "./e2e/$E2E_TSCONFIG" || exit 1;
./node_modules/.bin/http-server -c-1 $CONTENT_CE_DIST_PATH -p 4200 > /dev/null &\
if [ ${{ inputs.test-runner }} == "playwright" ]; then
echo "Running playwright tests with options ${{ inputs.options }}"
npx playwright test --config ${{ inputs.options }}
else
echo "Running protractor tests with options ${{ inputs.options }}"
echo "./node_modules/.bin/protractor \"./protractor.conf.js\" ${{ inputs.options }} || exit 1"
./node_modules/.bin/protractor "./protractor.conf.js" ${{ inputs.options }} $E2E_PROTRACTOR_OPTS || exit 1
fi
40 changes: 40 additions & 0 deletions .github/actions/upload-job-artifact/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "Upload build artifacts"
description: "Upload build artifacts"

inputs:
artifact:
description: 'path to the artifact to archieve (tar.bz2) and upload (like ./dist)'
required: true
type: string
output:
description: 'the S3 object to copy it to, like: s3://bucket-name/folder/whatever.tar.bz2'
required: true
type: string
aws-access-key-id:
description: 'aws access key id'
required: true
type: string
aws-secret-access-key:
description: 'aws secret access key'
required: true
type: string
aws-region:
description: 'aws region'
required: true
type: string

runs:
using: "composite"
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: ${{ inputs.aws-region }}
- name: upload build artifacts to s3
shell: bash
run: |
tar cvfj ./s3-artifact.tmp -C ${{ inputs.artifact }} `ls ${{ inputs.artifact }}`
aws s3 cp ./s3-artifact.tmp ${{ inputs.output }}
rm ./s3-artifact.tmp
2 changes: 1 addition & 1 deletion .github/workflows/aca-upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: install NPM
uses: actions/setup-node@v3
with:
node-version: 14
node-version-file: '.nvmrc'
cache: 'npm'
- name: Trigger upstream
shell: bash
Expand Down
Loading

0 comments on commit 01f7e3c

Please sign in to comment.