|
| 1 | +--- |
| 2 | +# This workflow executes several linters on changed files based on languages used in your code base whenever |
| 3 | +# you push a code or open a pull request. |
| 4 | +# |
| 5 | +# You can adjust the behavior by modifying this file. |
| 6 | +# For more information, see: |
| 7 | +# https://github.com/super-linter/super-linter |
| 8 | +# Configuration file for super-linter example: |
| 9 | +# .github/super-linter.env |
| 10 | +# Configuration files for individual linters should be placed in .github/linters |
| 11 | + |
| 12 | +name: Lint Code Base |
| 13 | + |
| 14 | +on: |
| 15 | + push: |
| 16 | + branches: |
| 17 | + - '**' |
| 18 | + pull_request: |
| 19 | + branches: |
| 20 | + - '**' |
| 21 | + workflow_dispatch: |
| 22 | + inputs: |
| 23 | + full_scan: |
| 24 | + type: boolean |
| 25 | + default: false |
| 26 | + required: false |
| 27 | + description: "Lint all codebase" |
| 28 | +permissions: |
| 29 | + contents: read |
| 30 | + |
| 31 | +jobs: |
| 32 | + prepare-configs: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - name: "Get the common linters configuration" |
| 36 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 37 | + with: |
| 38 | + ref: main # fix/superlinter-config |
| 39 | + repository: netcracker/.github |
| 40 | + persist-credentials: false |
| 41 | + sparse-checkout: | |
| 42 | + config/linters |
| 43 | + - name: "Upload the common linters configuration" |
| 44 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 45 | + with: |
| 46 | + name: linter-config |
| 47 | + path: "${{ github.workspace }}/config" |
| 48 | + include-hidden-files: true |
| 49 | + run-lint: |
| 50 | + needs: [prepare-configs] |
| 51 | + runs-on: ubuntu-latest |
| 52 | + permissions: |
| 53 | + contents: read |
| 54 | + packages: read |
| 55 | + # To report GitHub Actions status checks |
| 56 | + statuses: write |
| 57 | + steps: |
| 58 | + - name: Checkout code |
| 59 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 60 | + with: |
| 61 | + # Full git history is needed to get a proper list of changed files within `super-linter` |
| 62 | + fetch-depth: 0 |
| 63 | + persist-credentials: false |
| 64 | + - name: "Get the common linters configuration" |
| 65 | + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 |
| 66 | + id: download |
| 67 | + with: |
| 68 | + name: linter-config |
| 69 | + path: /tmp/linter-config |
| 70 | + - name: "Apply the common linters configuration" |
| 71 | + if: ${{ steps.download.outputs.download-path != '' }} |
| 72 | + run: | |
| 73 | + mkdir -p ./.github/linters |
| 74 | + cp --update=none -vRT /tmp/linter-config/linters ./.github/linters |
| 75 | +
|
| 76 | + - name: "Load super-linter environment file" |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + # shellcheck disable=2086 |
| 80 | + if [ -f "${GITHUB_WORKSPACE}/.github/super-linter.env" ]; then |
| 81 | + echo "Applying local linter environment:" |
| 82 | + grep "\S" ${GITHUB_WORKSPACE}/.github/super-linter.env | grep -v "^#" |
| 83 | + grep "\S" ${GITHUB_WORKSPACE}/.github/super-linter.env | grep -v "^#" >> $GITHUB_ENV |
| 84 | + elif [ -f "/tmp/linter-config/linters/super-linter.env" ]; then |
| 85 | + echo "::warning:: Local linter environment file .github/super-linter.env is not found" |
| 86 | + echo "Applying common linter environment:" |
| 87 | + grep "\S" /tmp/linter-config/linters/super-linter.env | grep -v "^#" |
| 88 | + grep "\S" /tmp/linter-config/linters/super-linter.env | grep -v "^#" >> $GITHUB_ENV |
| 89 | + fi |
| 90 | +
|
| 91 | + - name: Lint Code Base |
| 92 | + uses: super-linter/super-linter/slim@ffde3b2b33b745cb612d787f669ef9442b1339a6 # v8.1.0 |
| 93 | + env: |
| 94 | + VALIDATE_ALL_CODEBASE: ${{ inputs.full_scan || false }} |
| 95 | + # To report GitHub Actions status checks |
| 96 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 97 | + DEFAULT_BRANCH: ${{ github.event.pull_request.base.ref || github.event.push.ref }} |
| 98 | + |
0 commit comments