diff --git a/.github/workflows/ciStaticCodeValidation.yml b/.github/workflows/ciStaticCodeValidation.yml index 25f07bc..9e60c30 100644 --- a/.github/workflows/ciStaticCodeValidation.yml +++ b/.github/workflows/ciStaticCodeValidation.yml @@ -41,16 +41,46 @@ jobs: run: | npm ci - - name: "Verify prettier" + - name: "Set variables" + id: paths run: | if [ ${{ inputs.validateEntireRepo }} ]; then - npx prettier . --check + prettierPathsToValidate ='.' + eslintPathsToValidate='.' + sfCodeAnalyzerPathToValidate='src' else - #Find diff - mapfile -t diffed_files_to_lint < <(git diff --name-only --diff-filter=d HEAD~ -- \*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}) - npx prettier "${diffed_files_to_lint[@]}" --check + mapfile -t prettier_diffed_files_to_lint < <(git diff --name-only --diff-filter=d HEAD~ -- \*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}) + mapfile -t eslint_diffed_files_to_lint < <(git diff --name-only --diff-filter=d HEAD~ -- \*.js}) + mapfile -t codeAnalyzer_diffed_sf_files < <(git diff --name-only --diff-filter=d HEAD~ -- src\**\*.{cls,cmp,component,css,html,js,json,page,trigger,xml}) + codeAnalyzer_json=$(jq -c -n '$ARGS.positional' --args "${codeAnalyzer_diffed_sf_files[@]}") + + prettierPathsToValidate ="${prettier_diffed_files_to_lint[@]}" + eslintPathsToValidate="${eslint_diffed_files_to_lint[@]}" + sfCodeAnalyzerPathToValidate=fromJson($codeAnalyzer_json) fi + echo "prettierPathsToValidate=$prettierPathsToValidate" >> $GITHUB_OUTPUT + echo "eslintPathsToValidate=$eslintPathsToValidate" >> $GITHUB_OUTPUT + echo "sfCodeAnalyzerPathToValidate=$sfCodeAnalyzerPathToValidate" >> $GITHUB_OUTPUT + + - uses: navikt/sf-platform/.github/actions/prettierCheck@main + with: + pathToValidate: ${{ steps.paths.outputs.prettierPathsToValidate }} + + # - name: "Verify prettier" + # run: | + # if [ ${{ inputs.validateEntireRepo }} ]; then + # npx prettier . --check + # else + # #Find diff + # mapfile -t diffed_files_to_lint < <(git diff --name-only --diff-filter=d HEAD~ -- \*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}) + # npx prettier "${diffed_files_to_lint[@]}" --check + # fi + # - name: "Verify prettier" + # uses: navikt/sf-platform/.github/actions/prettierCheck + # with: + # pathToValidate: . + - name: "Run eslint" run: | if [ ${{ inputs.validateEntireRepo }} ]; then