From ab2c4336da73ad24e5e272ec65d543d16ca827c8 Mon Sep 17 00:00:00 2001 From: Peter Somogyvari Date: Wed, 3 Apr 2024 06:35:37 -0700 Subject: [PATCH] ci(github): refactor ActionLint job to use the official installer 1. Previously we just winged it with a bash script downloading another bash script to unzip the actionlint binaries. 2. From now on we'll use the GitHub action from the marketplace which has a lot of configuration options exposed in a convenient way such as what type of warnings to ignore, what version of actionlint to install, etc. Signed-off-by: Peter Somogyvari --- .github/workflows/actionlint.yaml | 75 +++++++++++++++++++++++++++---- 1 file changed, 66 insertions(+), 9 deletions(-) diff --git a/.github/workflows/actionlint.yaml b/.github/workflows/actionlint.yaml index b6f2f467f87..e4ed3d33508 100644 --- a/.github/workflows/actionlint.yaml +++ b/.github/workflows/actionlint.yaml @@ -3,14 +3,71 @@ on: workflow_call: jobs: - actionlint: + Lint_GitHub_Actions: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v4.1.1 - - name: Download actionlint - id: get_actionlint - run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/v1.6.25/scripts/download-actionlint.bash) - shell: bash - - name: Check workflow files - run: ${{ steps.get_actionlint.outputs.executable }} -color - shell: bash + - name: git_clone + uses: actions/checkout@v4.1.1 + + # We need to wipe the root package.json file because the installation of actionlint fails otherwise like this: + # + # npm ERR! code ERESOLVE + # npm ERR! ERESOLVE could not resolve + # npm ERR! + # npm ERR! While resolving: react-scripts@5.0.1 + # npm ERR! Found: typescript@5.3.3 + # npm ERR! node_modules/typescript + # npm ERR! dev typescript@"5.3.3" from the root project + # npm ERR! peerOptional typescript@">=3.7.2" from tap@16.3.8 + # npm ERR! node_modules/tap + # npm ERR! dev tap@"16.3.8" from the root project + # npm ERR! 25 more (ts-jest, @hyperledger/cactus-plugin-satp-hermes, ...) + # npm ERR! + # npm ERR! Could not resolve dependency: + # npm ERR! peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1 + # npm ERR! node_modules/react-scripts + # npm ERR! react-scripts@"5.0.1" from @hyperledger/cacti-example-cbdc-bridging-frontend@2.0.0-alpha.2 + # npm ERR! examples/cactus-example-cbdc-bridging-frontend + # npm ERR! @hyperledger/cacti-example-cbdc-bridging-frontend@2.0.0-alpha.2 + # npm ERR! node_modules/@hyperledger/cacti-example-cbdc-bridging-frontend + # npm ERR! workspace examples/cactus-example-cbdc-bridging-frontend from the root project + # npm ERR! + # npm ERR! Conflicting peer dependency: typescript@4.9.5 + # npm ERR! node_modules/typescript + # npm ERR! peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1 + # npm ERR! node_modules/react-scripts + # npm ERR! react-scripts@"5.0.1" from @hyperledger/cacti-example-cbdc-bridging-frontend@2.0.0-alpha.2 + # npm ERR! examples/cactus-example-cbdc-bridging-frontend + # npm ERR! @hyperledger/cacti-example-cbdc-bridging-frontend@2.0.0-alpha.2 + # npm ERR! node_modules/@hyperledger/cacti-example-cbdc-bridging-frontend + # npm ERR! workspace examples/cactus-example-cbdc-bridging-frontend from the root project + # npm ERR! + # npm ERR! Fix the upstream dependency conflict, or retry + # npm ERR! this command with --force or --legacy-peer-deps + # npm ERR! to accept an incorrect (and potentially broken) dependency resolution. + - name: wipe_root_package_json + run: rm -rf packages/ examples/ extensions/ package.json + + - name: actionlint + id: actionlint #optional, id required only when outputs are used in the workflow steps later + uses: raven-actions/actionlint@v1.0.3 + with: + # working-directory: ".github/" + version: 1.6.27 + # matcher: false # optional + cache: false # Do not use the tools-cache action because it crashes during installation + # fail-on-error: false # optional + # files: ".github/*.yml, .github/*.yaml" # optional, example on how to grab all .yml and .yaml files from the test directory + # flags: "-ignore SC2086" # optional + + - name: actionlint_summary + if: ${{ steps.actionlint.outputs.exit-code != 0 }} # example usage, do echo only when actionlint action failed + run: | + echo "Used actionlint version ${{ steps.actionlint.outputs.version-semver }}" + echo "Used actionlint release ${{ steps.actionlint.outputs.version-tag }}" + echo "actionlint ended with ${{ steps.actionlint.outputs.exit-code }} exit code" + echo "actionlint ended because '${{ steps.actionlint.outputs.exit-message }}'" + echo "actionlint found ${{ steps.actionlint.outputs.total-errors }} errors" + echo "actionlint checked ${{ steps.actionlint.outputs.total-files }} files" + echo "actionlint cache used: ${{ steps.actionlint.outputs.cache-hit }}" + exit ${{ steps.actionlint.outputs.exit-code }}