Skip to content

Commit

Permalink
Use new composer lock diff workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
davereid committed Apr 24, 2024
1 parent 68b22ff commit 6eac1f3
Show file tree
Hide file tree
Showing 10 changed files with 246 additions and 15 deletions.
92 changes: 92 additions & 0 deletions .github/actions/drainpipe/ddev/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: 'Install and Start DDEV'
description: 'Installs the latest or specified version of DDEV and starts the project'
inputs:
ssh-private-key:
description: "SSH Private Key"
required: false
ssh-known-hosts:
description: "SSH Known Hosts"
required: false
git-email:
description: "Git e-mail address"
required: false
git-name:
description: "Git name"
required: false
composer-cache-dir:
description: "Composer cache directory, relative to the project workspace. Set to false to disable."
required: false
version:
description: "Override the DDEV version .e.g. '1.19.0'"
required: false
runs:
using: "composite"
steps:
- name: Install and Start DDEV
run: |
curl https://apt.fury.io/drud/gpg.key | sudo apt-key add -
echo "deb https://apt.fury.io/drud/ * *" | sudo tee -a /etc/apt/sources.list.d/ddev.list
sudo apt update
sudo apt install libnss3-tools -y
mkdir -p .ddev/homeadditions/.ssh
# Copy private key
if [ "${{ inputs.ssh-private-key }}" != "" ]; then
echo "${{ inputs.ssh-private-key }}" > .ddev/homeadditions/.ssh/id_rsa
chmod 600 .ddev/homeadditions/.ssh/id_rsa
fi
# Copy known hosts
if [ "${{ inputs.ssh-known-hosts }}" != "" ]; then
echo "${{ inputs.ssh-known-hosts}}" > .ddev/homeadditions/.ssh/known_hosts
chmod 644 .ddev/homeadditions/.ssh/known_hosts
fi
# SSH config file
touch .ddev/homeadditions/.ssh/config
# Disable strict host key checking for Pantheon as ssh-keyscan will not
# return a stable response.
if [ -f "pantheon.yml" ]; then
echo -e "Host *.drush.in\\n\\tStrictHostKeyChecking no\\n\tLogLevel ERROR\\n" >> .ddev/homeadditions/.ssh/config
fi
chmod 600 .ddev/homeadditions/.ssh/config
chmod 700 .ddev/homeadditions/.ssh
# Download and run the DDEV installer
if [ "${{ inputs.version }}" != "" ]; then
sudo apt install -y ddev=${{inputs.version}}
else
sudo apt install -y ddev
fi
# Support local runner https://github.com/nektos/act
if [ "$ACT" != "" ]; then
sudo chown runner:docker /var/run/docker.sock
fi
ddev config global --instrumentation-opt-in=false --omit-containers=ddev-ssh-agent
if [ "${{ inputs.composer-cache-dir }}" != "false" ]; then
# @todo Replace /var/www/html with an environment variable.
CACHE_DIR=".ddev/.drainpipe-composer-cache"
if [ "${{ inputs.composer-cache-dir }}" != "" ]; then
CACHE_DIR="${{ inputs.composer-cache-dir }}"
fi
# Workaround for https://github.com/ddev/ddev/issues/6044
if yq -re .type .ddev/config.yaml; then
ddev config --web-environment-add="COMPOSER_CACHE_DIR=/var/www/html/$CACHE_DIR" --project-type="$(yq -re .type .ddev/config.yaml)"
else
ddev config --web-environment-add="COMPOSER_CACHE_DIR=/var/www/html/$CACHE_DIR"
fi
fi
ddev start
ddev describe
# Copy git credentials
ddev exec "git config --global user.name \"${{ inputs.git-name }}\""
ddev exec "git config --global user.email \"${{ inputs.git-email }}\""
echo "DRAINPIPE_DDEV=true" >> $GITHUB_ENV
shell: bash
17 changes: 17 additions & 0 deletions .github/actions/drainpipe/set-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Set Env'
description: 'Creates some useful environment variables'
inputs:
github-api-token:
description: "GitHub API token"
required: true
github-api-token-username:
description: "GitHub API token username"
required: true
runs:
using: "composite"
steps:
- run: |
echo "Setting Drainpipe environment variables:"
echo "DRAINPIPE_PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')" >> $GITHUB_ENV
echo "DRAINPIPE_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha)" >> $GITHUB_ENV
shell: bash
7 changes: 7 additions & 0 deletions .github/actions/drainpipe/set-env/bash_aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
drainpipe_exec() {
if [ "$DRAINPIPE_DDEV" == "true" ]; then
ddev exec "$@"
else
eval "$@"
fi
}
16 changes: 16 additions & 0 deletions .github/actions/drainpipe/setup-git/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Configure git'
description: 'Configures git username and e-mail address'
inputs:
git-email:
description: "Git e-mail address"
required: true
git-name:
description: "Git name"
required: true
runs:
using: "composite"
steps:
- run: |
git config --global user.email ${{ inputs.git-email }}
git config --global user.name ${{ inputs.git-name }}
shell: bash
26 changes: 26 additions & 0 deletions .github/actions/drainpipe/setup-ssh/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Configure ssh'
description: 'Configures SSH'
inputs:
ssh-private-key:
description: "SSH Private Key"
required: true
ssh-known-hosts:
description: "SSH Known Hosts"
required: false
runs:
using: "composite"
steps:
- run: |
sudo apt-get update
sudo apt-get install -y openssh-client
eval $(ssh-agent -s)
echo "${{ inputs.ssh-private-key }}" | tr -d '\r' | ssh-add -
mkdir -p ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/config
chmod 600 ~/.ssh/config
if [ "${{ inputs.ssh-known-hosts}}" != "" ]; then
echo "${{ inputs.ssh-known-hosts }}" >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
fi
shell: bash
56 changes: 56 additions & 0 deletions .github/workflows/ComposerLockDiff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Composer Lock Diff"

on:
pull_request:
types: [opened, synchronize, reopened]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
Composer-Lock-Diff:
runs-on: ubuntu-22.04
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4

- name: Check if composer.lock was changed
id: composer-lock-changed
uses: tj-actions/changed-files@v44
with:
files: 'composer.lock'

- name: Delete sticky pull request comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: composer-lock-diff
delete: true

- uses: actions/cache@v4
if: ${{ steps.composer-lock-changed.outputs.any_changed == 'true' }}
with:
path: ${{ github.workspace }}/.ddev/.drainpipe-composer-cache
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Generate composer diff
if: ${{ steps.composer-lock-changed.outputs.any_changed == 'true' }}
id: composer-diff
uses: IonBazan/composer-diff-action@v1
with:
base: ${{ github.base_ref || github.ref_name }}
with-platform: true
with-links: true

- name: Post sticky pull request comment
if: ${{ steps.composer-lock-changed.outputs.any_changed == 'true' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: composer-lock-diff
message: |
### Composer package changes
${{ (steps.composer-diff.outcome != 'success' && 'Review any changes to composer.lock manually.') || steps.composer-diff.outputs.composer_diff || 'No changes found' }}
14 changes: 12 additions & 2 deletions .tugboat/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# DO NOT EDIT THIS FILE
# This file is controlled by Drainpipe, run composer install to apply pending
# updates.
# updates. You can add values to the php service using .tugboat/config.override.yml.
#
# Example config.drainpipe-override.yml
# php:
# aliases:
# urls:
# screenshot:
# visualdiff:
services:
php:
http: false
Expand All @@ -20,4 +27,7 @@ services:
image: tugboatqa/mariadb:10.4

redis:
image: tugboatqa/redis:6-bullseye
image: tugboatqa/redis:7-bullseye

elasticsearch:
image: tugboatqa/elasticsearch:7.17.19
5 changes: 5 additions & 0 deletions .tugboat/steps/1-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ docker-php-ext-install gd
# of GD. Lullabot will likely be publishing an ADR recommending it too.
apt-get install -y imagemagick

# Install the PHP redis extension.

yes '' | pecl install -f redis
echo 'extension=redis.so' > /usr/local/etc/php/conf.d/redis.ini

# Install node
apt-get install -y ca-certificates gnupg
mkdir -p /etc/apt/keyrings
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"minimum-stability": "dev",
"require": {
"lullabot/drainpipe": "^3",
"lullabot/drainpipe": "dev-composer-lock-diff-sticky-pr-comment",
"lullabot/drainpipe-dev": "dev-main"
},
"config": {
Expand All @@ -27,7 +27,8 @@
},
"extra": {
"drainpipe": {
"tugboat": {}
"tugboat": {},
"github": ["ComposerLockDiff"]
}
}
}
23 changes: 12 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6eac1f3

Please sign in to comment.