Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/13 GitHub action #15

Merged
merged 28 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0001c47
fixes #13: Add a github action for feature branches.
mattsqd Jul 30, 2024
e02dbb2
fixes #13: Don't ignore composer.lock any more so that composer lock …
mattsqd Jul 30, 2024
b80f491
fixes #13: Switch order of commands since composer lock is definitely…
mattsqd Jul 30, 2024
4035927
fixes #13: Action checkout v3 is deprecated.
mattsqd Jul 30, 2024
5310add
fixes #13: Action cache v3 is deprecated.
mattsqd Jul 30, 2024
ed699dc
fixes #13: Fix bash warning about unary.
mattsqd Jul 30, 2024
831bc07
fixes #13: Initialize the status vars and check which version of PHP …
mattsqd Jul 31, 2024
d2e2790
fixes #13: Instead of using composer.lock for key of cache, use compo…
mattsqd Jul 31, 2024
f73c1cf
fixes #13: Use setup-php instead of composer action so that PHP versi…
mattsqd Jul 31, 2024
721bd06
fixes #13: Closed statement.
mattsqd Jul 31, 2024
b2aafa8
fixes #13: Setup PHP first so we can get composer cache dir.
mattsqd Jul 31, 2024
33f5266
fixes #13: Change the name of the steps and workflow and re-commit co…
mattsqd Jul 31, 2024
fcf1cd6
fixes #13: Change the name of the steps and workflow and re-commit co…
mattsqd Jul 31, 2024
32dc9df
fixes #13: Match on feature/** instead of feature/*.
mattsqd Jul 31, 2024
8c2e3e0
fixes #13: Run on any pull request.
mattsqd Jul 31, 2024
73dc19c
fixes #13: Try to see if we can get current branch.
mattsqd Jul 31, 2024
dbfebab
fixes #13: Allow passing current branch to validate commits.
mattsqd Jul 31, 2024
032bfed
fixes #13: Pass current branch to validate commit messages.
mattsqd Jul 31, 2024
a4ed823
fixes #13: If not using HEAD, tag on origin/ to the current branch.
mattsqd Jul 31, 2024
aafc56a
fixes #13: If not using HEAD, fetch the current branch.
mattsqd Jul 31, 2024
03b6219
fixes #13: Accidentally used $target_branch, and if fetching current …
mattsqd Jul 31, 2024
da24b92
fixes #13: Removed debugging and added proper comments.
mattsqd Jul 31, 2024
603312f
fixes #13: Added a bad commit message on purpose.
mattsqd Jul 31, 2024
562c3d8
fixes #13: If a null value is given to $replace, don't let it get pas…
mattsqd Jul 31, 2024
607f923
fixes #13: Init robo if a RoboFile does not exist.
mattsqd Jul 31, 2024
82a660a
fixes #13: Fixed coding standards error.
mattsqd Jul 31, 2024
0a3b324
fixes #13: Removed debug php version.
mattsqd Jul 31, 2024
d80df4b
fixes #13: Added current-branch to robo.example.yml file.
mattsqd Jul 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/run-validation.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
vendor/
composer.lock
# Ignore ide files
.vscode/
/.idea/
Loading