From 730304e2936e7afeab4ac5652d448d0ded2fbe4b Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Sat, 5 Apr 2025 14:43:49 +0300 Subject: [PATCH] feat(pr-lint): Update pr-lint/action.yml: Add multi-env detection, update Git config (#98) --- pr-lint/action.yml | 97 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 3 deletions(-) diff --git a/pr-lint/action.yml b/pr-lint/action.yml index b272b34..4bc77ee 100644 --- a/pr-lint/action.yml +++ b/pr-lint/action.yml @@ -12,7 +12,9 @@ branding: runs: using: composite steps: - # Git Checkout + # ╭──────────────────────────────────────────────────────────╮ + # │ Git Checkout │ + # ╰──────────────────────────────────────────────────────────╯ - name: Checkout Code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: @@ -22,11 +24,100 @@ runs: # improve performance fetch-depth: 0 + # ╭──────────────────────────────────────────────────────────╮ + # │ Setup Git configuration │ + # ╰──────────────────────────────────────────────────────────╯ - name: Setup Git Config id: git-config - uses: ivuorinen/actions/set-git-config@main + uses: ivuorinen/actions/set-git-config@d648dba57309a3437c6f7996fdacb478c5a99916 # 25.3.25 - # MegaLinter + # ╭──────────────────────────────────────────────────────────╮ + # │ Install packages for linting │ + # ╰──────────────────────────────────────────────────────────╯ + + # Node.js tests if package.json exists + - name: Detect package.json + id: detect-node + shell: bash + run: | + if [ -f package.json ]; then + echo "found=true" >> $GITHUB_OUTPUT + fi + + - name: Setup Node.js and run tests + if: steps.detect-node.outputs.found == 'true' + uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0 + with: + cache: 'npm' + + - name: Install Node.js dependencies + if: steps.detect-node.outputs.found == 'true' + run: npm ci + + # PHP tests if composer.json exists + - name: Detect composer.json + id: detect-php + shell: bash + run: | + if [ -f composer.json ]; then + echo "found=true" >> $GITHUB_OUTPUT + fi + + - name: Setup PHP + if: steps.detect-php.outputs.found == 'true' + uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # master + with: + tools: composer + coverage: none + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Setup problem matchers for PHP + if: steps.detect-php.outputs.found == 'true' + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + + - name: Install PHP dependencies + if: steps.detect-php.outputs.found == 'true' + run: composer install --no-progress --prefer-dist --no-interaction + + # Python tests if requirements.txt exists + - name: Detect requirements.txt + id: detect-python + shell: bash + run: | + if [ -f requirements.txt ]; then + echo "found=true" >> $GITHUB_OUTPUT + fi + + - name: Setup Python + if: steps.detect-python.outputs.found == 'true' + uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0 + with: + cache: 'pip' + + - name: Install Python dependencies + if: steps.detect-python.outputs.found == 'true' + run: pip install -r requirements.txt + + # Go tests if go.mod exists + - name: Detect go.mod + id: detect-go + shell: bash + run: | + if [ -f go.mod ]; then + echo "found=true" >> $GITHUB_OUTPUT + fi + + - name: Setup Go + if: steps.detect-go.outputs.found == 'true' + uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0 + with: + go-version-file: 'go.mod' + cache: true + + # ╭──────────────────────────────────────────────────────────╮ + # │ MegaLinter │ + # ╰──────────────────────────────────────────────────────────╯ - name: MegaLinter # You can override MegaLinter flavor used to have faster performances # More info at https://megalinter.io/latest/flavors/