Skip to content

Break ACSF deployment #2860

Break ACSF deployment

Break ACSF deployment #2860

Workflow file for this run

name: Main CI Workflow
on:
push:
branches:
- master
- main
- develop
- 'hotfix/**'
- 'release/**'
- 'feature/**'
- 'prototype/**'
tags:
- '*'
pull_request:
# Only run one instance of this workflow at a time per branch.
concurrency:
group: ${{ github.ref_name }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
build:
name: Build, Test and Upload Artifacts
runs-on: ubuntu-20.04
services:
## Ubuntu 20 comes with mysql 8, so we need a separate service
mysql:
image: mysql:5.7
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: drupal
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
steps:
- name: Setup variables
id: set_vars
run: |
## PUSH
if [ "${{ github.event_name }}" == "push" ]; then
BUILD_NAME=$(sed -E 's/refs\/(heads|tags)\///; s/\//__/g;' <<< $GITHUB_REF)
BRANCH_NAME=$(sed -E 's/refs\/(heads|tags)\///;' <<< $GITHUB_REF)
COMMIT_HASH=$(echo "${GITHUB_SHA}")
## PULL_REQUEST
elif [ "${{ github.event_name }}" == "pull_request" ]; then
BUILD_NAME=$(echo "pr-${{ github.event.pull_request.number }}")
BRANCH_NAME=$(echo "pr-${{ github.event.pull_request.number }}")
COMMIT_HASH=$(echo "${{ github.event.pull_request.head.sha }}")
else
## ERROR
exit 1
fi
## For step checks and artifact deployment path.
## Same for push and PR
export REPO_FULL=${{ github.repository }}
export REPO_RE='([^/]+)/(.*)'
[[ "$REPO_FULL" =~ $REPO_RE ]]
REPO_OWNER=$(echo "${BASH_REMATCH[1]}")
REPO_NAME=$(echo "${BASH_REMATCH[2]}")
## Set step outputs for later use
echo "build_name=${BUILD_NAME}" >> $GITHUB_OUTPUT
echo "branch_name=${BRANCH_NAME}" >> $GITHUB_OUTPUT
echo "commit_hash=${COMMIT_HASH}" >> $GITHUB_OUTPUT
echo "repo_owner=${REPO_OWNER}" >> $GITHUB_OUTPUT
echo "repo_name=${REPO_NAME}" >> $GITHUB_OUTPUT
## This clones and checks out.
- name: Checkout branch from Github
uses: actions/checkout@v4
## Setup node and npm caching.
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '16.13.0'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
registry-url: https://npm.pkg.github.com
scope: '@nciocpl'
- name: Install NPM 8
run: |
npm install -g npm@8.19.4
## Setup PHP and Composer Caching
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
## This list of extensions matches those we install with our docker file, then I removed
## cli, common, fpm cause they would not install, then I removed xdebug cause why?
extensions: bz2, curl, gd, mbstring, memcached, mysql, oauth, opcache, readline, sqlite3, soap, xml
tools: composer:v2
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Composer install
run: |
composer install
- name: Put BLT, Drush, etc. on the path.
run: |
echo "$PWD/vendor/bin" >> $GITHUB_PATH
- name: Setup Env
run: |
## The mynci service creates the drupal DB, we need to make the
## simpletest DB for the phpunit tests by hand here.
mysql -u root -proot --protocol=TCP -e "CREATE DATABASE IF NOT EXISTS simpletest"
mysql -u root -proot --protocol=TCP -e "GRANT ALL ON simpletest.* to 'simpletest'@'%' IDENTIFIED BY 'simpletest'"
## We don't set git info for right now as we are in the NCIOCPL origin right now.
- name: Validate
run: |
blt validate --define drush.alias='${drush.aliases.ci}' --ansi --verbose --no-interaction
- name: Setup App
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
## The setup app script cannot create build.json as we are in the NCIOCPL origin.
blt setup --define drush.alias='${drush.aliases.ci}' --environment=ci --no-interaction --ansi --verbose
- name: Run Front-end Tests
run: |
blt tests:frontend:run --define drush.alias='${drush.aliases.ci}' --define tests.run-server=false --environment=ci --ansi --verbose --no-interaction
- name: Start test server
run: |
## Running drush runserver is equivelent to blt tests:server:start, and is what happens under the hood, except this allows us to bind to all ips on the box.
## blt was not letting us bind to those IPs we wanted.
drush runserver --quiet 0.0.0.0:8888 &
- name: Behavioral Tests
timeout-minutes: 120
run: |
blt tests:cypress:run --define drush.alias='${drush.aliases.ci}' --define tests.run-server=false --environment=ci --ansi --verbose --no-interaction
- name: Upload test screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: cypress-test-screenshots
path: ./tests/cypress/cypress/screenshots
# The weights file is re-generated on every run, but an existing copy is needed in order to help distribute
# test suites between threads. So, we need to restore the file to its original state in order to avoid
# failing the job with modified files.
- name: Reset weights
run: |
git restore --worktree $(find ./tests/cypress/cypress/e2e/ -name parallel-weights.json)
- name: PHP Unit Tests
timeout-minutes: 120
run: |
## Setup Simpletest info for kernel & functional tests
export SIMPLETEST_BASE_URL=http://127.0.0.1:8888
## This URI should be good until GitHub changes to use IPV6 or something stupid.
export SIMPLETEST_DB=mysql://simpletest:simpletest@127.0.0.1:3306/simpletest
## PHP Unit tests do not start the server
## drush rs is equivelent to blt tests:server:start, except it allows us to bind to all ips on the box.
## blt was not letting us bind to those IPs we wanted.
drush rs 0.0.0.0:8888 &
blt custom:paratest --define drush.alias='${drush.aliases.ci}' --environment=ci --define tests.run-server=true -D behat.web-driver=chrome --ansi --verbose
blt tests:server:kill --define drush.alias='${drush.aliases.ci}' --environment=ci --define tests.run-server=true -D behat.web-driver=chrome --ansi --verbose
- name: Build Artifact
env:
NEW_BUILD_DIR: ${{ format('{0}{1}', runner.temp, '/artifact') }}
run: |
blt deploy:check-dirty --ansi --verbose --no-interaction
blt artifact:build -D deploy.dir=${NEW_BUILD_DIR} -D deploy.docroot=${NEW_BUILD_DIR}/docroot --ansi --verbose --no-interaction
- name: Create Build Information
env:
BUILD_INFO: ${{ toJson(steps.set_vars.outputs) }}
NEW_BUILD_DIR: ${{ format('{0}{1}', runner.temp, '/artifact') }}
run: |
echo $BUILD_INFO
echo $BUILD_INFO > ${NEW_BUILD_DIR}/build.json
- name: Setup SSH Keys and known_hosts
run: |
mkdir -p $HOME/.ssh
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.ACE_SSH_KEY }}"
echo ${{ secrets.ACE_KNOWN_HOST }} >> $HOME/.ssh/known_hosts
- name: Setup Git User Name
run: |
git config --global user.name "Github Actions"
git config --global user.email "webcommauto@users.noreply.github.com"
- name: Push Artifact to Acquia
run: ./.github/scripts/push_acquia_git.sh
shell: bash
env:
ACE_GIT_SUBSCRIPTION: ${{ secrets.ACE_GIT_SUBSCRIPTION }}
ACE_GIT_HOST: ${{ secrets.ACE_GIT_HOST }}
ARTIFACT_GIT_DIR: ${{ format('{0}{1}', runner.temp, '/artifact-git') }}
ACE_BRANCH_NAME: ${{ format('gh-build-{0}', steps.set_vars.outputs.build_name) }}
NEW_BUILD_DIR: ${{ format('{0}{1}', runner.temp, '/artifact') }}
## This also uses available envs:
## - GITHUB_REF
## - GITHUB_RUN_ID
## - GITHUB_RUN_NUMBER