Skip to content

Commit

Permalink
Qual: Add actions-lint to pre-commit
Browse files Browse the repository at this point in the history
# Qual: Add actions-lint to pre-commit

This finds issues with actions.
Fixed exakat.
  • Loading branch information
mdeweerd committed Oct 3, 2024
1 parent 7f946dc commit 587b292
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 23 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/cache-clean-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ jobs:
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH=refs/pull/${{ github.event.pull_request.number }}/merge
REPO="${{ github.repository }}"
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
cacheKeysForPR=$(gh actions-cache list -R "$REPO" -B "$BRANCH" | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
gh actions-cache delete "$cacheKey" -R "$REPO" -B "$BRANCH" --confirm
done
echo "Done"
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ jobs:


# Note (not tested, from https://github.com/orgs/community/discussions/38361)
# To cancel jobs if one failes, the following action may help
# To cancel jobs if one fails, the following action may help
# - if: "failure()"
# uses: "andymckay/[email protected]"
5 changes: 2 additions & 3 deletions .github/workflows/exakat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ name: "Exakat analysis"
on:
# execute once a month, the 1st
schedule:
- cron: "0 20 1 * *"
- cron: "0 20 1 * *"
workflow_dispatch:
branches:
- develop

permissions:
contents: read
Expand All @@ -19,6 +17,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 1
ref: develop
- name: Exakat
uses: docker://exakat/exakat-ga
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/phan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ concurrency:
cancel-in-progress: true
env:
gh_event: ${{ inputs.gh_event || github.event_name }}
PHAN_CONFIG: >
${{ 'dev/tools/phan/config.php' }}
PHAN_CONFIG: dev/tools/phan/config.php
PHAN_BASELINE: dev/tools/phan/baseline.txt
PHAN_MIN_PHP: 7.0
PHAN_QUICK: ${{ github.event.schedule && '' || '--quick' }}
Expand All @@ -43,7 +42,8 @@ jobs:
tools: cs2pr,phan
- name: Run Phan analysis
run: |
phan $PHAN_QUICK -k $PHAN_CONFIG -B $PHAN_BASELINE --analyze-twice --minimum-target-php-version $PHAN_MIN_PHP --output-mode=checkstyle -o _phan.xml
# shellcheck disable=2086
phan $PHAN_QUICK -k "$PHAN_CONFIG" -B "$PHAN_BASELINE" --analyze-twice --minimum-target-php-version "$PHAN_MIN_PHP" --output-mode=checkstyle -o _phan.xml
- name: Add results to PR
if: ${{ always() }}
run: |
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
run: |
set -o pipefail
pre-commit gc
pre-commit run --show-diff-on-failure --color=always --all-files | tee ${RAW_LOG}
pre-commit run --show-diff-on-failure --color=always --all-files | tee "${RAW_LOG}"
# The next uses git, which is slow for a bit repo.
# - name: Get all changed php files (if PR)
Expand Down Expand Up @@ -105,7 +105,8 @@ jobs:
ALL_CHANGED_FILES: ${{ steps.changed-php.outputs.all_changed_files }}
run: |
set -o pipefail
pre-commit run php-cs --files ${ALL_CHANGED_FILES} | tee -a ${RAW_LOG}
# shellcheck disable=2086
pre-commit run php-cs --files ${ALL_CHANGED_FILES} | tee -a "${RAW_LOG}"
- name: Run some pre-commit hooks on all files on push to "main" branches
if: |
Expand All @@ -117,8 +118,8 @@ jobs:
run: |
set -o pipefail
ln -sf ~/.cache .cache # Absolute path in .pre-commit-config.yaml
pre-commit run --hook-stage manual -a php-cs-with-cache | tee -a ${RAW_LOG}
pre-commit run --hook-stage manual -a sqlfluff-lint | tee -a ${RAW_LOG}
pre-commit run --hook-stage manual -a php-cs-with-cache | tee -a "${RAW_LOG}"
pre-commit run --hook-stage manual -a sqlfluff-lint | tee -a "${RAW_LOG}"
ls -l ~/.cache/pre-commit/
- name: Convert Raw Log to Annotations
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
KEY_ROOT: ${{ matrix.os }}-${{ env.ckey }}-${{ matrix.php_version }}
with:
# See https://github.com/actions/cache/issues/1275#issuecomment-1925217178
enableCrossOsArchive: true
enableCrossOsArchive: true
path: |
./db_init.sql
./db_init.sql.md5
Expand Down Expand Up @@ -114,6 +114,7 @@ jobs:
# Note this is bash (MSYS) on Windows
shell: bash
run: |
# shellcheck disable=SC2129
ECHO "#[group]Directory contents to verify cache files, ..."
ls -l
ECHO "#[endgroup]"
Expand All @@ -128,10 +129,12 @@ jobs:
ls -l
ECHO "#[endgroup]"
# Export some tool paths to reuse the from CMD shell.
echo "TAIL=$(cygpath -w "$(which tail)")" >> "$GITHUB_ENV"
echo "GREP=$(cygpath -w "$(which grep)")" >> "$GITHUB_ENV"
echo "TEE=$(cygpath -w "$(which tee)")" >> "$GITHUB_ENV"
echo "BASEDIR=$(realpath .)" >> "$GITHUB_ENV"
{
echo "TAIL=$(cygpath -w "$(which tail)")"
echo "GREP=$(cygpath -w "$(which grep)")"
echo "TEE=$(cygpath -w "$(which tee)")"
echo "BASEDIR=$(realpath .)"
} >> "$GITHUB_ENV"
- name: Run PHPUnit tests
# continue-on-error: true
Expand Down Expand Up @@ -184,7 +187,7 @@ jobs:
if: ${{ ! cancelled() }}
with:
# See https://github.com/actions/cache/issues/1275#issuecomment-1925217178
enableCrossOsArchive: true
enableCrossOsArchive: true
key: ${{ steps.cache.outputs.cache-primary-key }}
path: |
./db_init.sql
Expand Down
8 changes: 7 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
exclude: (?x)^( htdocs/includes/ckeditor/.*|(\.[^/]*/.*))$
exclude: (?x)^( htdocs/includes/ckeditor/.*|(\.(?!github/workflows)[^/]*/.*))$
repos:
# Several miscellaneous checks and fix (on yaml files, end of files fix)
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -64,6 +64,12 @@ repos:
hooks:
- id: gitleaks

# Check github actions
- repo: https://github.com/rhysd/actionlint
rev: v1.7.3
hooks:
- id: actionlint

# Beautify shell scripts
- repo: https://github.com/lovesegfault/beautysh.git
rev: v6.2.1
Expand Down

0 comments on commit 587b292

Please sign in to comment.