From af2e4fd6820f05c8f2a99a044e87187a1f1ac65c Mon Sep 17 00:00:00 2001 From: Matt Poole Date: Tue, 6 Aug 2024 13:19:55 -0400 Subject: [PATCH] BSD fixes #271: Updated to 1.4.0-alpha release of robovalidate and added github action to validate. --- .github/workflows/run-validation.yml | 67 ++++++++++++++++++++++++++++ composer.lock | 12 ++--- composer.log | 1 + 3 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/run-validation.yml diff --git a/.github/workflows/run-validation.yml b/.github/workflows/run-validation.yml new file mode 100644 index 00000000..54951fed --- /dev/null +++ b/.github/workflows/run-validation.yml @@ -0,0 +1,67 @@ +name: Run validation with RoboValidate + +on: + # Run on any branch so validate branch can always run. + push: + # Commit message validation requires a target branch which is only available in a PR. + pull_request: + +jobs: + validate: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + tools: composer:v2 + # https://github.com/shivammathur/setup-php?tab=readme-ov-file#disable-coverage + coverage: none + + - name: Get composer cache directory + id: composer-cache + 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 Composer dependencies and initialize Robo + run: | + composer install --ignore-platform-reqs --optimize-autoloader --no-progress --no-ansi + # If a Robo command exits with a failure and a RoboFile.php does not exist + # a warning about 'Robo is not initialized here. Please run `robo init` to create a new RoboFile.' + # will be created, which might make users think that is what the error was caused by. + if [ ! -f "RoboFile.php" ]; then + vendor/bin/robo init + fi + + - name: Validate a change to any branch + if: github.event_name == 'push' + run: | + # Initialize status variables to 0 + status1=0 + status2=0 + status3=0 + + # Run all commands and capture their exit statuses + vendor/bin/robo validate:branch-name || status1=$? || status1=0 + vendor/bin/robo validate:composer-lock || status3=$? || status3=0 + vendor/bin/robo validate:coding-standards || status2=$? || status2=0 + + # Exit with a non-zero status if any command failed + if [ "$status1" -ne 0 ] || [ "$status2" -ne 0 ] || [ "$status3" -ne 0 ]; then + exit 1 + fi + + - name: Validate pull requests + if: github.event_name == 'pull_request' + run: | + vendor/bin/robo validate:commit-messages --target-branch="${{ github.base_ref }}" --current-branch="${{ github.head_ref }}" diff --git a/composer.lock b/composer.lock index 4f7ac97c..d54fc1c1 100644 --- a/composer.lock +++ b/composer.lock @@ -6248,16 +6248,16 @@ }, { "name": "mattsqd/robovalidate", - "version": "1.3.0-alpha", + "version": "1.4.0-alpha", "source": { "type": "git", "url": "https://github.com/mattsqd/robovalidate.git", - "reference": "8d7d0b4a20cfaf26444a0744cc76a4907bfbb21f" + "reference": "db39f0605b1a1a2d94f36a57e07237d0f2326217" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mattsqd/robovalidate/zipball/8d7d0b4a20cfaf26444a0744cc76a4907bfbb21f", - "reference": "8d7d0b4a20cfaf26444a0744cc76a4907bfbb21f", + "url": "https://api.github.com/repos/mattsqd/robovalidate/zipball/db39f0605b1a1a2d94f36a57e07237d0f2326217", + "reference": "db39f0605b1a1a2d94f36a57e07237d0f2326217", "shasum": "" }, "require": { @@ -6290,9 +6290,9 @@ "description": "A group of Robo commands that run various validation tasks on local environments or pipelines", "support": { "issues": "https://github.com/mattsqd/robovalidate/issues", - "source": "https://github.com/mattsqd/robovalidate/tree/1.3.0-alpha" + "source": "https://github.com/mattsqd/robovalidate/tree/1.4.0-alpha" }, - "time": "2023-05-30T20:17:14+00:00" + "time": "2024-07-31T17:51:40+00:00" }, { "name": "mck89/peast", diff --git a/composer.log b/composer.log index 885b98e0..f9fe2c1c 100644 --- a/composer.log +++ b/composer.log @@ -32,3 +32,4 @@ d0b264b8bfd2f16b57808145e6c7b950|Matt Poole|feature/BSD-212-smpt-enable|Tue Jul 1cc6d6789783135d19582c52d712125d|Buddy Harlow|feature/BSD-244-blog-images-marked-decorative|Wed Jul 31 14:36:44 EDT 2024|./composer.sh require drupal/decorative_image_widget 4d4eeea0afa18c0874d2696e7ccf9b64|Matt Poole|feature/BSD-244-blog-images-marked-decorative|Wed Jul 31 14:45:51 EDT 2024|./composer.sh require drupal/media_library_edit:^3.0 3257dd27ca54b3c2e8ec96a100874f2a|Matt Poole|feature/BSD-254-update-deps|Wed Jul 31 15:09:47 EDT 2024|./composer.sh update +59d81fa4a3cb5b4021dd9824956e194c|Matt Poole|feature/BSD-271-validation-action|Tue Aug 6 13:13:48 EDT 2024|./composer.sh update mattsqd/robovalidate