Skip to content

Commit

Permalink
Merge pull request ampproject#7649 from ampproject/enhancement/workflows
Browse files Browse the repository at this point in the history
Update `Build, test & measure` workflow
  • Loading branch information
westonruter authored Oct 30, 2023
2 parents ad827ad + c86bdb1 commit 6899eeb
Show file tree
Hide file tree
Showing 26 changed files with 445 additions and 38,168 deletions.
84 changes: 84 additions & 0 deletions .github/actions/determine-changed-files/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Determine count of changed files

description: Determine count of changed files based on the current branch and the base branch

outputs:
count:
description: The count of changed files
value: ${{ steps.determine-file-counts.outputs.count }}
php-count:
description: The count of changed PHP files
value: ${{ steps.determine-file-counts.outputs.php-count }}
css-count:
description: The count of changed CSS files
value: ${{ steps.determine-file-counts.outputs.css-count }}
js-count:
description: The count of changed JS files
value: ${{ steps.determine-file-counts.outputs.js-count }}
gha-workflow-count:
description: The count of changed GHA workflow files
value: ${{ steps.determine-file-counts.outputs.gha-workflow-count }}

runs:
using: 'composite'
steps:
- name: Fetch base branch
# Only fetch base ref if it's a PR.
if: ${{ github.base_ref != null }}
shell: bash
run: git fetch --depth=1 --no-tags origin ${{ github.base_ref }}

- name: Determine modified files for PR
if: ${{ github.base_ref != null }}
shell: bash
run: echo "MODIFIED_FILES=$(git diff --name-only FETCH_HEAD HEAD | base64 -w 0)" >> $GITHUB_ENV

- name: Determine modified files for commit
if: ${{ github.base_ref == null }}
shell: bash
run: echo "MODIFIED_FILES=$(git diff --name-only HEAD~1 HEAD | base64 -w 0)" >> $GITHUB_ENV

- name: Determine if modified files should make the workflow run continue
id: determine-file-counts
shell: bash
run: |
# Get modified files.
MODIFIED_FILES=$(echo "$MODIFIED_FILES" | base64 -d)
# Determine file counts.
FILE_COUNT=$(php -f ./.github/actions/determine-changed-files/determine-modified-files-count.php "$IGNORE_PATH_REGEX" "$MODIFIED_FILES" --invert)
PHP_FILE_COUNT=$(php -f ./.github/actions/determine-changed-files/determine-modified-files-count.php ".+\.php|composer\.(json|lock)|phpstan\.neon\.dist" "$MODIFIED_FILES")
CSS_FILE_COUNT=$(php -f ./.github/actions/determine-changed-files/determine-modified-files-count.php ".+\.s?css|package\.json|package-lock\.json" "$MODIFIED_FILES")
JS_FILE_COUNT=$(php -f ./.github/actions/determine-changed-files/determine-modified-files-count.php ".+\.(js|snap)|package\.json|package-lock\.json" "$MODIFIED_FILES")
GHA_WORKFLOW_COUNT=$(php -f ./.github/actions/determine-changed-files/determine-modified-files-count.php "(\.github\/workflows\/.+\.yml)" "$MODIFIED_FILES")
# Set output variables.
echo "count=$FILE_COUNT" >> $GITHUB_OUTPUT
echo "php-count=$PHP_FILE_COUNT" >> $GITHUB_OUTPUT
echo "css-count=$CSS_FILE_COUNT" >> $GITHUB_OUTPUT
echo "js-count=$JS_FILE_COUNT" >> $GITHUB_OUTPUT
echo "gha-workflow-count=$GHA_WORKFLOW_COUNT" >> $GITHUB_OUTPUT
# Add modified files summary.
echo "# Modified files summary" >> $GITHUB_STEP_SUMMARY
echo "## Modified files" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "$MODIFIED_FILES" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "## Modified files count" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "Total modified files: $FILE_COUNT" >> $GITHUB_STEP_SUMMARY
echo "PHP files: $PHP_FILE_COUNT" >> $GITHUB_STEP_SUMMARY
echo "CSS files: $CSS_FILE_COUNT" >> $GITHUB_STEP_SUMMARY
echo "JS files: $JS_FILE_COUNT" >> $GITHUB_STEP_SUMMARY
echo "GHA workflow files: $GHA_WORKFLOW_COUNT" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
env:
# Ignore Paths:
# - .github/
# - !.github/actions
# - !.github/workflows
# - .github/actions/draft-release/
# - .wordpress-org/
# - docs/
IGNORE_PATH_REGEX: \.github\/(?!actions|workflows)|\.wordpress-org\/|docs\/|\.github\/actions\/draft-release\/
File renamed without changes.
23 changes: 0 additions & 23 deletions .github/actions/draft-release/.eslintrc

This file was deleted.

2 changes: 0 additions & 2 deletions .github/actions/draft-release/.gitattributes

This file was deleted.

25 changes: 0 additions & 25 deletions .github/actions/draft-release/README.md

This file was deleted.

15 changes: 0 additions & 15 deletions .github/actions/draft-release/action.yml

This file was deleted.

Loading

0 comments on commit 6899eeb

Please sign in to comment.