mirror of
https://github.com/ivuorinen/actions.git
synced 2026-03-11 18:57:56 +00:00
fix: improve cache key quality across actions
Address cache key quality issues identified during code review.
php-composer:
- Remove unused cache-directories input and handling code
- Simplify cache paths to vendor + ~/.composer/cache only
- Eliminate empty path issue when cache-directories was default empty
npm-publish:
- Remove redundant -npm- segment from cache key
- Change: runner.os-npm-publish-{manager}-npm-{hash}
- To: runner.os-npm-publish-{manager}-{hash}
go-lint:
- Add ~/.cache/go-build to cached paths
- Now caches both golangci-lint and Go build artifacts
- Improves Go build performance
Result: Cleaner cache keys and better caching coverage
This commit is contained in:
@@ -220,7 +220,9 @@ runs:
|
|||||||
if: inputs.cache == 'true'
|
if: inputs.cache == 'true'
|
||||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/golangci-lint
|
path: |
|
||||||
|
~/.cache/golangci-lint
|
||||||
|
~/.cache/go-build
|
||||||
key: ${{ runner.os }}-golangci-${{ inputs.golangci-lint-version }}-${{ hashFiles('go.sum', inputs.config-file) }}
|
key: ${{ runner.os }}-golangci-${{ inputs.golangci-lint-version }}-${{ hashFiles('go.sum', inputs.config-file) }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-golangci-${{ inputs.golangci-lint-version }}-
|
${{ runner.os }}-golangci-${{ inputs.golangci-lint-version }}-
|
||||||
|
|||||||
@@ -109,9 +109,8 @@ runs:
|
|||||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||||
with:
|
with:
|
||||||
path: node_modules
|
path: node_modules
|
||||||
key: ${{ runner.os }}-npm-publish-${{ steps.node-setup.outputs.package-manager }}-npm-${{ hashFiles('package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb') }}
|
key: ${{ runner.os }}-npm-publish-${{ steps.node-setup.outputs.package-manager }}-${{ hashFiles('package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-npm-publish-${{ steps.node-setup.outputs.package-manager }}-npm-
|
|
||||||
${{ runner.os }}-npm-publish-${{ steps.node-setup.outputs.package-manager }}-
|
${{ runner.os }}-npm-publish-${{ steps.node-setup.outputs.package-manager }}-
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
|
|||||||
@@ -8,17 +8,16 @@ Runs Composer install on a repository with advanced caching and configuration.
|
|||||||
|
|
||||||
### Inputs
|
### Inputs
|
||||||
|
|
||||||
| name | description | required | default |
|
| name | description | required | default |
|
||||||
|---------------------|---------------------------------------------------------------|----------|-----------------------------------------------------|
|
|--------------------|---------------------------------------------------------------|----------|-----------------------------------------------------|
|
||||||
| `php` | <p>PHP Version to use.</p> | `true` | `8.4` |
|
| `php` | <p>PHP Version to use.</p> | `true` | `8.4` |
|
||||||
| `extensions` | <p>Comma-separated list of PHP extensions to install</p> | `false` | `mbstring, xml, zip, curl, json` |
|
| `extensions` | <p>Comma-separated list of PHP extensions to install</p> | `false` | `mbstring, xml, zip, curl, json` |
|
||||||
| `tools` | <p>Comma-separated list of Composer tools to install</p> | `false` | `composer:v2` |
|
| `tools` | <p>Comma-separated list of Composer tools to install</p> | `false` | `composer:v2` |
|
||||||
| `args` | <p>Arguments to pass to Composer.</p> | `false` | `--no-progress --prefer-dist --optimize-autoloader` |
|
| `args` | <p>Arguments to pass to Composer.</p> | `false` | `--no-progress --prefer-dist --optimize-autoloader` |
|
||||||
| `composer-version` | <p>Composer version to use (1 or 2)</p> | `false` | `2` |
|
| `composer-version` | <p>Composer version to use (1 or 2)</p> | `false` | `2` |
|
||||||
| `stability` | <p>Minimum stability (stable, RC, beta, alpha, dev)</p> | `false` | `stable` |
|
| `stability` | <p>Minimum stability (stable, RC, beta, alpha, dev)</p> | `false` | `stable` |
|
||||||
| `cache-directories` | <p>Additional directories to cache (comma-separated)</p> | `false` | `""` |
|
| `token` | <p>GitHub token for private repository access</p> | `false` | `""` |
|
||||||
| `token` | <p>GitHub token for private repository access</p> | `false` | `""` |
|
| `max-retries` | <p>Maximum number of retry attempts for Composer commands</p> | `false` | `3` |
|
||||||
| `max-retries` | <p>Maximum number of retry attempts for Composer commands</p> | `false` | `3` |
|
|
||||||
|
|
||||||
### Outputs
|
### Outputs
|
||||||
|
|
||||||
@@ -74,12 +73,6 @@ This action is a `composite` action.
|
|||||||
# Required: false
|
# Required: false
|
||||||
# Default: stable
|
# Default: stable
|
||||||
|
|
||||||
cache-directories:
|
|
||||||
# Additional directories to cache (comma-separated)
|
|
||||||
#
|
|
||||||
# Required: false
|
|
||||||
# Default: ""
|
|
||||||
|
|
||||||
token:
|
token:
|
||||||
# GitHub token for private repository access
|
# GitHub token for private repository access
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -35,10 +35,6 @@ inputs:
|
|||||||
description: 'Minimum stability (stable, RC, beta, alpha, dev)'
|
description: 'Minimum stability (stable, RC, beta, alpha, dev)'
|
||||||
required: false
|
required: false
|
||||||
default: 'stable'
|
default: 'stable'
|
||||||
cache-directories:
|
|
||||||
description: 'Additional directories to cache (comma-separated)'
|
|
||||||
required: false
|
|
||||||
default: ''
|
|
||||||
token:
|
token:
|
||||||
description: 'GitHub token for private repository access'
|
description: 'GitHub token for private repository access'
|
||||||
required: false
|
required: false
|
||||||
@@ -98,20 +94,11 @@ runs:
|
|||||||
id: hash
|
id: hash
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
CACHE_DIRECTORIES: ${{ inputs.cache-directories }}
|
|
||||||
COMPOSER_LOCK_HASH: ${{ hashFiles('**/composer.lock') }}
|
COMPOSER_LOCK_HASH: ${{ hashFiles('**/composer.lock') }}
|
||||||
COMPOSER_JSON_HASH: ${{ hashFiles('**/composer.json') }}
|
COMPOSER_JSON_HASH: ${{ hashFiles('**/composer.json') }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Function to calculate directory hash
|
|
||||||
calculate_dir_hash() {
|
|
||||||
local dir=$1
|
|
||||||
if [ -d "$dir" ]; then
|
|
||||||
find "$dir" -type f -exec sha256sum {} \; | sort | sha256sum | cut -d' ' -f1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get composer.lock hash or composer.json hash
|
# Get composer.lock hash or composer.json hash
|
||||||
if [ -f composer.lock ]; then
|
if [ -f composer.lock ]; then
|
||||||
echo "lock=$COMPOSER_LOCK_HASH" >> $GITHUB_OUTPUT
|
echo "lock=$COMPOSER_LOCK_HASH" >> $GITHUB_OUTPUT
|
||||||
@@ -119,17 +106,6 @@ runs:
|
|||||||
echo "lock=$COMPOSER_JSON_HASH" >> $GITHUB_OUTPUT
|
echo "lock=$COMPOSER_JSON_HASH" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Calculate additional directory hashes
|
|
||||||
if [ -n "$CACHE_DIRECTORIES" ]; then
|
|
||||||
IFS=',' read -ra DIRS <<< "$CACHE_DIRECTORIES"
|
|
||||||
for dir in "${DIRS[@]}"; do
|
|
||||||
dir_hash=$(calculate_dir_hash "$dir")
|
|
||||||
if [ -n "$dir_hash" ]; then
|
|
||||||
echo "${dir}_hash=$dir_hash" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Configure Composer
|
- name: Configure Composer
|
||||||
id: composer
|
id: composer
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -181,7 +157,6 @@ runs:
|
|||||||
path: |
|
path: |
|
||||||
vendor
|
vendor
|
||||||
~/.composer/cache
|
~/.composer/cache
|
||||||
${{ inputs.cache-directories }}
|
|
||||||
key: ${{ runner.os }}-php-${{ inputs.php }}-composer-${{ inputs.composer-version }}-composer-${{ hashFiles('composer.lock', 'composer.json') }}
|
key: ${{ runner.os }}-php-${{ inputs.php }}-composer-${{ inputs.composer-version }}-composer-${{ hashFiles('composer.lock', 'composer.json') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-php-${{ inputs.php }}-composer-${{ inputs.composer-version }}-composer-
|
${{ runner.os }}-php-${{ inputs.php }}-composer-${{ inputs.composer-version }}-composer-
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Validation rules for php-composer action
|
# Validation rules for php-composer action
|
||||||
# Generated by update-validators.py v1.0.0 - DO NOT EDIT MANUALLY
|
# Generated by update-validators.py v1.0.0 - DO NOT EDIT MANUALLY
|
||||||
# Schema version: 1.0
|
# Schema version: 1.0
|
||||||
# Coverage: 56% (5/9 inputs)
|
# Coverage: 50% (4/8 inputs)
|
||||||
#
|
#
|
||||||
# This file defines validation rules for the php-composer GitHub Action.
|
# This file defines validation rules for the php-composer GitHub Action.
|
||||||
# Rules are automatically applied by validate-inputs action when this
|
# Rules are automatically applied by validate-inputs action when this
|
||||||
@@ -17,7 +17,6 @@ required_inputs:
|
|||||||
- php
|
- php
|
||||||
optional_inputs:
|
optional_inputs:
|
||||||
- args
|
- args
|
||||||
- cache-directories
|
|
||||||
- composer-version
|
- composer-version
|
||||||
- extensions
|
- extensions
|
||||||
- max-retries
|
- max-retries
|
||||||
@@ -25,18 +24,17 @@ optional_inputs:
|
|||||||
- token
|
- token
|
||||||
- tools
|
- tools
|
||||||
conventions:
|
conventions:
|
||||||
cache-directories: boolean
|
|
||||||
composer-version: semantic_version
|
composer-version: semantic_version
|
||||||
max-retries: numeric_range_1_10
|
max-retries: numeric_range_1_10
|
||||||
php: semantic_version
|
php: semantic_version
|
||||||
token: github_token
|
token: github_token
|
||||||
overrides: {}
|
overrides: {}
|
||||||
statistics:
|
statistics:
|
||||||
total_inputs: 9
|
total_inputs: 8
|
||||||
validated_inputs: 5
|
validated_inputs: 4
|
||||||
skipped_inputs: 0
|
skipped_inputs: 0
|
||||||
coverage_percentage: 56
|
coverage_percentage: 50
|
||||||
validation_coverage: 56
|
validation_coverage: 50
|
||||||
auto_detected: true
|
auto_detected: true
|
||||||
manual_review_required: true
|
manual_review_required: true
|
||||||
quality_indicators:
|
quality_indicators:
|
||||||
|
|||||||
Reference in New Issue
Block a user