Skip to content

Commit

Permalink
Merge branch 'main' into feature/MOOSE-178/glomar-links
Browse files Browse the repository at this point in the history
  • Loading branch information
MlKilderkin authored Jan 13, 2025
2 parents 71ea3ed + 6987633 commit 3fba1b0
Show file tree
Hide file tree
Showing 30 changed files with 818 additions and 477 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"env": {
"browser": true
},
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ],
"rules": {
"no-console": 0,
Expand Down
62 changes: 62 additions & 0 deletions .github/actions/composer-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Composer Install

inputs:
BUILD_FOLDER:
description: 'Folder to run shell commands in.'
required: false
default: ${{ github.workspace }}
COMPOSER_INSTALL_FLAGS:
description: 'Flags to pass to the `composer install` command.'
required: false
default: '--optimize-autoloader --no-dev'
OP_SERVICE_ACCOUNT_TOKEN:
required: true
description: '1Password service account token to use for populating composer auth.json'
OP_VAULT:
description: '1Password vault to use for populating composer auth.json'
required: true
OP_ITEM:
description: '1Password item to use for populating composer auth.json'
required: true

runs:
using: "composite"
steps:
- name: 'Configure PHP environment'
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

- name: 'Get composer cache directory'
working-directory: ${{ inputs.BUILD_FOLDER }}
id: composer-cache
shell: bash
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: 'Cache composer dependencies'
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: 'Install 1Password CLI'
uses: 1password/install-cli-action@v1

- name: 'Create auth.json via 1Password CLI'
working-directory: ${{ inputs.BUILD_FOLDER }}
shell: bash
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ inputs.OP_SERVICE_ACCOUNT_TOKEN }}
OP_VAULT: ${{ inputs.OP_VAULT }}
OP_ITEM: ${{ inputs.OP_ITEM }}
run: op inject -i auth.template.json -o auth.json

- name: 'Install Composer'
working-directory: ${{ inputs.BUILD_FOLDER }}
shell: bash
run: |
composer install ${{ inputs.COMPOSER_INSTALL_FLAGS }}
rm auth.json
14 changes: 10 additions & 4 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ jobs:
name: 'Coding Standards'
uses: ./.github/workflows/phpcs.yml
secrets:
COMPOSER_AUTH_JSON: ${{ secrets.COMPOSER_AUTH_JSON }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
OP_VAULT: ${{ secrets.OP_VAULT }}
OP_ITEM: ${{ secrets.OP_ITEM }}

linting:
name: 'Linting'
Expand All @@ -27,12 +29,16 @@ jobs:
needs: [coding-standards, linting]
uses: ./.github/workflows/static-analysis.yml
secrets:
COMPOSER_AUTH_JSON: ${{ secrets.COMPOSER_AUTH_JSON }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
OP_VAULT: ${{ secrets.OP_VAULT }}
OP_ITEM: ${{ secrets.OP_ITEM }}

# Enable this job if you have PHPUnit tests
# slic:
# name: 'PHP Tests'
# needs: [coding-standards, phpstan, linting]
# uses: ./.github/workflows/php-tests.yml
# secrets:
# COMPOSER_AUTH_JSON: ${{ secrets.COMPOSER_AUTH_JSON }}
# secrets:
# OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
# OP_VAULT: ${{ secrets.OP_VAULT }}
# OP_ITEM: ${{ secrets.OP_ITEM }}
34 changes: 7 additions & 27 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,21 @@ jobs:
DEPLOY_REPO: ${{ secrets.DEV_DEPLOY_REPO }}

steps:

##########
### BUILD: General SquareOne build steps
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: '8.2'
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Get Build Repository
- name: Check out build branch
uses: actions/checkout@v4
with:
path: ${{ env.BUILD_FOLDER }}
ref: ${{github.ref}}

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v4
# Composer install
- name: 'Composer install'
uses: ./.github/actions/composer-install
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

# Install composer: Add env for plugin keys, composer install, and cleanup
- name: Install composer dependencies
working-directory: ${{ env.BUILD_FOLDER }}
run: |
echo '${{ secrets.COMPOSER_AUTH_JSON }}' > auth.json
composer install --optimize-autoloader --ignore-platform-reqs --no-dev
rm auth.json
BUILD_FOLDER: ${{ env.BUILD_FOLDER }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
OP_VAULT: ${{ secrets.OP_VAULT }}
OP_ITEM: ${{ secrets.OP_ITEM }}

# Set up node version
- name: Set up node
Expand Down
33 changes: 7 additions & 26 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,21 @@ jobs:

steps:

##########
### BUILD: General SquareOne build steps
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: '8.2'
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Get Build Repository
- name: Check out build branch
uses: actions/checkout@v4
with:
path: ${{ env.BUILD_FOLDER }}
ref: ${{github.ref}}

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v4
# Composer install
- name: 'Composer install'
uses: ./.github/actions/composer-install
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

# Install composer: Add env for plugin keys, composer install, and cleanup
- name: Install composer dependencies
working-directory: ${{ env.BUILD_FOLDER }}
run: |
echo '${{ secrets.COMPOSER_AUTH_JSON }}' > auth.json
composer install --optimize-autoloader --ignore-platform-reqs --no-dev
rm auth.json
BUILD_FOLDER: ${{ env.BUILD_FOLDER }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
OP_VAULT: ${{ secrets.OP_VAULT }}
OP_ITEM: ${{ secrets.OP_ITEM }}

# Set up node version
- name: Set up node
Expand Down
33 changes: 7 additions & 26 deletions .github/workflows/deploy-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,21 @@ jobs:

steps:

##########
### BUILD: General SquareOne build steps
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: '8.2'
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Get Build Repository
- name: Check out build branch
uses: actions/checkout@v4
with:
path: ${{ env.BUILD_FOLDER }}
ref: ${{github.ref}}

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v4
# Composer install
- name: 'Composer install'
uses: ./.github/actions/composer-install
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

# Install composer: Add env for plugin keys, composer install, and cleanup
- name: Install composer dependencies
working-directory: ${{ env.BUILD_FOLDER }}
run: |
echo '${{ secrets.COMPOSER_AUTH_JSON }}' > auth.json
composer install --optimize-autoloader --ignore-platform-reqs --no-dev
rm auth.json
BUILD_FOLDER: ${{ env.BUILD_FOLDER }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
OP_VAULT: ${{ secrets.OP_VAULT }}
OP_ITEM: ${{ secrets.OP_ITEM }}

# Set up node version
- name: Set up node
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/dokku-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ jobs:
github_pat_token: ${{ secrets.GH_BOT_TOKEN }}
ssh_private_key: ${{ secrets.DOKKU_DEPLOY_KEY }}
slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
composer_auth_json: ${{ secrets.COMPOSER_AUTH_JSON }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
OP_VAULT: ${{ secrets.OP_VAULT }}
OP_ITEM: ${{ secrets.OP_ITEM }}
4 changes: 3 additions & 1 deletion .github/workflows/dokku-review-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ jobs:
github_pat_token: ${{ secrets.GH_BOT_TOKEN }}
ssh_private_key: ${{ secrets.DOKKU_DEPLOY_KEY }}
slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
composer_auth_json: ${{ secrets.COMPOSER_AUTH_JSON }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
OP_VAULT: ${{ secrets.OP_VAULT }}
OP_ITEM: ${{ secrets.OP_ITEM }}

destroy_review_app:
if: (github.event_name == 'pull_request' && github.event.action == 'closed') && contains(github.event.pull_request.labels.*.name, 'Launch Environment')
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- added|modified: 'wp-content/plugins/core/**/*.{pcss,json,js}'
- added|modified: 'wp-content/themes/core/**/*.{pcss,json,js}'
- added|modified: 'wp-content/mu-plugins/**/*.{pcss,json,js}'
- added|modified: '*.{json,js}'
- added|modified: './*.{json,js}'
- name: Set up node
if: steps.changed-files.outputs.linting == 'true'
Expand All @@ -37,4 +37,4 @@ jobs:

- name: Check linting
if: steps.changed-files.outputs.linting == 'true'
run: npm run server-lint
run: npm run lint:server
25 changes: 21 additions & 4 deletions .github/workflows/php-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ name: 'PHP Tests'
on:
workflow_call:
secrets:
COMPOSER_AUTH_JSON:
OP_SERVICE_ACCOUNT_TOKEN:
required: true
description: Composer auth.json
description: 1Password Service Account Token to use for populating composer auth.json
OP_VAULT:
description: 1Password vault to use for populating composer auth.json
OP_ITEM:
description: 1Password item to use for populating composer auth.json

jobs:
test:
Expand All @@ -20,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
env:
build_folder: build
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH_JSON }}
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}

steps:
- name: Checkout the repository
Expand Down Expand Up @@ -100,11 +104,24 @@ jobs:
${SLIC_BIN} info
${SLIC_BIN} config
- name: Install 1Password CLI
if: steps.changed-files.outputs.tests == 'true'
uses: 1password/install-cli-action@v1

- name: Create auth.json via 1Password CLI
if: steps.changed-files.outputs.tests == 'true'
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
OP_VAULT: ${{ secrets.OP_VAULT }}
OP_ITEM: ${{ secrets.OP_ITEM }}
run: op inject -i auth.template.json -o auth.json

- name: Set up site for CI
if: steps.changed-files.outputs.tests == 'true'
run: |
${SLIC_BIN} use site
${SLIC_BIN} composer install --ignore-platform-reqs
${SLIC_BIN} composer install --optimize-autoloader --no-progress
${SLIC_BIN} rm auth.json
- name: Run suite tests
if: steps.changed-files.outputs.tests == 'true'
Expand Down
Loading

0 comments on commit 3fba1b0

Please sign in to comment.