CD-511 Demo content and Github Actions #57
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lighthouse CI | |
on: | |
pull_request: | |
types: [labeled] | |
jobs: | |
setup: | |
if: ${{ github.event.label.name == 'performance' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
id: checkout | |
uses: actions/checkout@v3 | |
- name: Extract PHP Version | |
id: php | |
uses: docker://ghcr.io/un-ocha/actions:extract-php-version-main | |
with: | |
docker_file: 'docker/Dockerfile' | |
docker_image: 'public.ecr.aws/unocha/php-k8s' | |
- name: Setup PHP with PECL extension | |
uses: shivammathur/setup-php@v2 | |
if: ${{ !env.ACT }} | |
with: | |
php-version: ${{ steps.php.outputs.php_version }} | |
tools: composer | |
env: | |
fail-fast: true | |
- name: Setup PHP with PECL extension locally | |
uses: shivammathur/setup-php@v2 | |
if: ${{ env.ACT }} | |
with: | |
php-version: ${{ steps.php.outputs.php_version }} | |
tools: composer | |
env: | |
fail-fast: true | |
runner: self-hosted | |
- name: Software versions | |
id: versions | |
uses: cafuego/command-output@main | |
with: | |
run: | | |
php --version && composer --version | |
- name: Composer Validate | |
id: validate | |
uses: cafuego/command-output@main | |
with: | |
run: | | |
composer validate | |
env: | |
fail-fast: true | |
- name: Code Lint | |
id: lint | |
uses: cafuego/command-output@main | |
with: | |
run: | | |
test ! -d ./html/modules/custom || find -L ./html/modules/custom -iregex '.*\.\(php\|module\|inc\|install\)$' -print0 | xargs -0 -n 1 -P 4 php -l | |
test ! -d ./html/themes/custom || find -L ./html/themes/custom -iregex '.*\.\(php\|theme\)$' -print0 | xargs -0 -n 1 -P 4 php -l | |
env: | |
fail-fast: true | |
- name: Configure AWS Credentials | |
id: aws | |
if: ${{ !env.ACT }} | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
aws-access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Login to Public ECR | |
id: aws-login | |
if: ${{ !env.ACT }} | |
uses: docker/login-action@v2.1.0 | |
with: | |
registry: public.ecr.aws | |
username: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }} | |
password: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }} | |
env: | |
AWS_REGION: us-east-1 | |
- name: Build Image | |
id: build | |
uses: cafuego/command-output@main | |
with: | |
run: | | |
make | |
env: | |
fail-fast: true | |
- name: Setup Environment | |
id: docker | |
uses: cafuego/command-output@main | |
with: | |
run: | | |
docker compose -f tests/docker-compose.yml up -d | |
sleep 10 | |
docker ps -a | |
docker compose -f tests/docker-compose.yml exec -w /srv/www -T drupal composer install | |
env: | |
fail-fast: true | |
- name: Install Subtheme | |
id: subtheme | |
uses: cafuego/command-output@main | |
with: | |
run: | | |
docker compose -f tests/docker-compose.yml exec -w /srv/www -T drupal /usr/bin/composer run sub-theme | |
- name: PHPCS | |
id: phpcs | |
uses: cafuego/command-output@main | |
with: | |
run: | | |
docker compose -f tests/docker-compose.yml exec -u appuser -w /srv/www -T drupal phpcs -p --report=full --standard=phpcs.xml ./html/modules/custom ./html/themes/custom | |
env: | |
fail-fast: true | |
- name: Install Environment | |
id: install | |
uses: cafuego/command-output@main | |
with: | |
run: | | |
docker compose -f tests/docker-compose.yml exec -T drupal drush -y si --existing-config minimal install_configure_form.enable_update_status_emails=NULL | |
env: | |
fail-fast: true | |
- name: Debug vendor | |
if: contains(github.event.pull_request.labels.*.name, 'performance') | |
uses: cafuego/command-output@main | |
with: | |
run: ls -al | |
- name: Run tests | |
id: tests | |
uses: cafuego/command-output@main | |
with: | |
run: | | |
docker compose -f tests/docker-compose.yml exec -T drupal drush -y en dblog | |
docker compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/sites/default/files /srv/www/html/sites/default/private | |
docker compose -f tests/docker-compose.yml exec -T drupal mkdir -p /srv/www/html/build/logs | |
docker compose -f tests/docker-compose.yml exec -T drupal chmod -R 777 /srv/www/html/build/logs | |
env: | |
fail-fast: true | |
- name: Install demo content | |
id: content | |
uses: cafuego/command-output@main | |
with: | |
run: | | |
docker-compose -f tests/docker-compose.yml exec -T drupal drush -y en unocha_demo_content | |
curl -v http://127.0.0.1:8080/demo | |
env: | |
fail-fast: true | |
- name: Copy Coveralls | |
id: copy_coveralls | |
if: success() | |
run: docker cp "$(docker compose -f tests/docker-compose.yml ps -q drupal)":/srv/www/html/build/logs/clover.xml . || echo "skip=true" >> "$GITHUB_OUTPUT" | |
- name: Monitor coverage | |
id: coveralls | |
if: ${{ steps.copy_coveralls.outputs.skip != 'true' }} | |
uses: slavcodev/coverage-monitor-action@v1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
coverage_path: "clover.xml" | |
threshold_alert: 0 | |
threshold_warning: 50 | |
threshold_metric: "lines" | |
comment_footer: false | |
- name: DB Logs | |
id: dblog | |
if: failure() | |
uses: cafuego/command-output@main | |
with: | |
run: | | |
docker compose -f tests/docker-compose.yml exec -T drupal drush watchdog:show | |
- name: Find Comment | |
uses: peter-evans/find-comment@v2 | |
if: ${{ !env.ACT }} | |
id: fc | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: Build output | |
- name: Create or update comment | |
uses: peter-evans/create-or-update-comment@v2 | |
if: ${{ !env.ACT }} | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
### Build output | |
#### Composer Validate `${{ steps.validate.outcome }}` | |
#### PHP Lint `${{ steps.lint.outcome }}` | |
#### Docker Build `${{ steps.build.outcome }}` | |
#### Environment Setup `${{ steps.docker.outcome }}` | |
#### Site Install `${{ steps.install.outcome }}` | |
#### PHP Code Sniffer `${{ steps.phpcs.outcome }}` | |
<details><summary>Software Versions</summary> | |
<code>${{ steps.versions.outputs.stdout }}</code> | |
</details> | |
<details><summary>Drupal Logs</summary> | |
<code>${{ steps.dblog.outputs.stdout }}</code> | |
</details> | |
*Pusher: @${{ github.actor }}, Action: `${{ github.event_name }}`, Workflow: `${{ github.workflow }}`* | |
edit-mode: replace | |
- name: Debug Server | |
if: contains(github.event.pull_request.labels.*.name, 'performance') | |
uses: cafuego/command-output@main | |
with: | |
run: | | |
docker ps -a | |
docker compose -f tests/docker-compose.yml exec -T drupal drush rs 127.0.0.1:8080 | |
curl -v http://127.0.0.1:8080/demo | |
env: | |
fail-fast: true | |
- name: Audit URLs using Lighthouse | |
# Run Lighthouse if the PR has the label "performance" | |
if: contains(github.event.pull_request.labels.*.name, 'performance') | |
uses: treosh/lighthouse-ci-action@10.1.0 | |
with: | |
urls: | | |
http://127.0.0.1:8080/demo | |
budgetPath: .github/workflows/lighthouse-budget.json # test performance budgets | |
configPath: .github/workflows/lighthouserc.js | |
uploadArtifacts: true # save results as an action artifacts | |
temporaryPublicStorage: true # upload lighthouse report to the temporary storage | |
- name: Clean up | |
id: docker-clean-up | |
if: ${{ env.ACT }} | |
uses: cafuego/command-output@main | |
with: | |
run: | | |
docker compose -f tests/docker-compose.yml down | |
env: | |
fail-fast: true |