Skip to content

Commit

Permalink
Update automation (#114)
Browse files Browse the repository at this point in the history
* rename testing.yml to sync-default.yml
because that's what it does, it doesn't test

* bump checkout version

* bump ssh-add version

* give prs read access
so we can get the pull request number

* add contents perms

* drop php 8.0 testing
default upstream php is 8.1 so we can not test older than that

* fix typo

* allow deletion of test sage directory if on ci

* don't fail fast if one of the tests fails

* wait for the operation to complete

* allow steps in the build artifact step to fail

* check for an existing named multidev before creating

* silence the workflow wait

* use latest stable node

* drop php 7.4 tests
bedrock no longer supports

* rename workflow

* use the right command

* update circle image

* better handling for multidev matching

* use latest lts

* use current node version

* switch lint/test to pull request

* bump node setup earleir

* just wait 15 seconds

* don't cache dependencies

* add composer diff

* update php requirement

* run composer update instead of install
make sure we're getting the latest stuff

* only run check-commits on release pushes
when deploy-public-upstream is run

* move stuff around

* move the filter back into the deploy-public-upstream job

* filter check-commits on release, too

* add specific triggers for pull_request

* remove write permission for composer-diff

Co-authored-by: Phil Tyler <[email protected]>

---------

Co-authored-by: Phil Tyler <[email protected]>
  • Loading branch information
jazzsequence and pwtyler authored Apr 8, 2024
1 parent 2b6c488 commit 988a03f
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 17 deletions.
12 changes: 8 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 2.1
executors:
deployer:
docker:
- image: cimg/base:2020.12
- image: cimg/base:current

jobs:
deploy-public-upstream:
Expand Down Expand Up @@ -50,11 +50,15 @@ workflows:
version: 2
deploy-public-upstream:
jobs:
- check-commits:
filters:
branches:
only:
- release
- deploy-public-upstream:
requires:
- check-commits
filters:
branches:
only:
- release
check-commits:
jobs:
- check-commits
16 changes: 11 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
name: CI
name: Lint and Test

on: [push]
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['7.4', '8.0', '8.1']
php-version: ['8.0', '8.1', '8.2', '8.3']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -31,7 +37,7 @@ jobs:
run: composer validate --no-check-all

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
run: composer update --no-progress --prefer-dist --optimize-autoloader

- name: Run lints
run: composer lint
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/composer-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Composer Diff
on:
pull_request:
paths:
- 'composer.lock'
permissions:
pull-requests: write
jobs:
composer-diff:
name: Composer Diff
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate composer diff
id: composer_diff
uses: IonBazan/composer-diff-action@v1
- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.composer_diff.outputs.composer_diff_exit_code != 0 }}
with:
header: composer-diff
message: |
<strong>Composer Changes</strong>
${{ steps.composer_diff.outputs.composer_diff }}
29 changes: 24 additions & 5 deletions .github/workflows/sage-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: Sage Install Tests
permissions:
pull-requests: read
contents: read
on:
push:
paths:
Expand All @@ -14,14 +17,15 @@ jobs:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
php-version: [8.0, 8.1, 8.2, 8.3]
php-version: [8.1, 8.2, 8.3]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install SSH keys
uses: webfactory/ssh-agent@v0.8.0
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Get and Set PR number
Expand All @@ -35,6 +39,10 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: current
- name: Generate multidev name
id: generate_name
run: |
Expand Down Expand Up @@ -94,7 +102,18 @@ jobs:
echo "Deleting existing sage-test..."
rm -rf web/app/themes/sage-test
fi
echo "Checking for existing multidev..."
multidevs=$(terminus env:list wpcm-sage-install-tests --format=json --fields=id)
# Use jq to check if the key exists in the JSON
match_exists=$(echo "$json_output" | jq --arg id "$multidev_name" 'any(.[]; .id == $id)')
if [ "$match_exists" == "true" ]; then
echo "Environment $multidev_name exists."
terminus multidev:delete --delete-branch --yes wpcm-sage-install-tests.$multidev_name
else
echo "Environment $multidev_name does not exist."
fi
terminus multidev:create wpcm-sage-install-tests.dev $multidev_name
terminus workflow:wait wpcm-sage-install-tests."$multidev_name" --quiet --max=15
echo "Checking out multidev..."
git fetch --all
git checkout $multidev_name
Expand All @@ -113,7 +132,7 @@ jobs:
- name: Install Composer Dependencies
run: |
cd ~/pantheon-local-copies/wpcm-sage-install-tests
composer install
composer update
- name: Run Sage Install Script
env:
SAGENAME: sage-test
Expand All @@ -133,7 +152,7 @@ jobs:
if: always()
run: |
cd ~/pantheon-local-copies/wpcm-sage-install-tests
git fetch --tags origin
# Allow these to fail.
git fetch --tags origin || true
git tag -d pantheon_build_artifacts_$multidev_name || true
git push origin --delete pantheon_build_artifacts_$multidev_name || true
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
}
],
"require": {
"php": ">=7.4",
"php": ">=8.0",
"composer/installers": "^2.2",
"vlucas/phpdotenv": "^5.5",
"oscarotero/env": "^2.1",
Expand Down
6 changes: 5 additions & 1 deletion private/scripts/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,14 @@ function update_php() {
# Install sage and related dependencies.
function install_sage_theme() {
# Check if the directory $sagedir is empty. If it's not, bail.
echo "Checking if ${sagedir} is exists and if it's empty."
echo "Checking if ${sagedir} exists and if it's empty."

if [ "$(ls -A "$sagedir")" ]; then
echo "${red}Directory not empty!${normal}"
if [ "$is_ci" -eq 1 ]; then
echo "${yellow}Removing ${sagedir} for CI tests.${normal}"
rm -rf "$sagedir"
fi
echo "Trying to install into ${sagedir}. Exiting."
exit 1;
fi
Expand Down

0 comments on commit 988a03f

Please sign in to comment.