diff --git a/.github/actions/setup-linter/action.yml b/.github/actions/setup-linter/action.yml new file mode 100644 index 0000000..0b4d896 --- /dev/null +++ b/.github/actions/setup-linter/action.yml @@ -0,0 +1,125 @@ +# Auto-synced file, managed by [dealroom/core-mothership](https://github.com/dealroom/core-mothership) +# The changes to this file will be automatically overwritten on the next sync. Do not edit by hand! + +name: Setup Linting Process +description: Setup linting process for the repository +inputs: + config-file: + description: Configuration file to use for linting + required: false + default: .github/super-linter.env + external-setup: + description: Run the external setup action (eg. setup-php, setup-node etc.) + required: false + default: false + configure-ignores: + description: Configure ignores specific to linting process + required: false + default: false + extensions: + description: Extra extensions to install + required: false + default: none + github-token: + description: GitHub token to use for pulling private packages + required: false + docs-generate: + description: Generate documentation for TF modules + required: false + default: false +runs: + using: composite + steps: + - if: inputs.external-setup == 'true' + id: check_files + uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 + with: + files: ./.github/actions/setup/action.yml + - if: inputs.external-setup == 'true' + run: grep -o '^[^#]*' ${{ inputs.config-file }} >> "$GITHUB_ENV" + shell: bash + - uses: ./.github/actions/setup + if: steps.check_files.outputs.files_exists == 'true' + with: + github-token: ${{ inputs.github-token }} + extensions: ${{ inputs.extensions }} + docs-generate: ${{ inputs.docs-generate }} + - if: inputs.configure-ignores == 'true' + shell: bash + run: | + if [ -d ./charts ]; then + if [ -f .prettierignore ]; then + if ! grep -q "charts/" .prettierignore; then + echo "charts/${REPO_NAME}/templates/**/*.yaml" >> .prettierignore + echo "charts/${REPO_NAME}/values/**/*.yaml" >> .prettierignore + fi + else + echo "charts/" > .prettierignore + fi + fi + if [ -f helmfile.yaml ]; then + if [ -f .prettierignore ]; then + if ! grep -q "helmfile.yaml" .prettierignore; then + echo "helmfile.yaml" >> .prettierignore + fi + else + echo "helmfile.yaml" > .prettierignore + fi + fi + env: + REPO_NAME: ${{ github.event.repository.name }} + - if: inputs.configure-ignores == 'true' + shell: bash + run: | + add_prettier_ignore() { + local marker="$1" + local comment="$2" + if [ "$comment" == "prettier-ignore-start" ]; then + find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \ + xargs -0 sed -i "//!b;//!i " + else + find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \ + xargs -0 sed -i "//!b;//!a " + fi + } + ensure_no_duplicates() { + find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \ + xargs -0 sed -i '//d; //d' + } + ensure_no_duplicates + add_prettier_ignore "BEGIN_TF_DOCS" "prettier-ignore-start" + add_prettier_ignore "END_TF_DOCS" "prettier-ignore-end" + - if: inputs.configure-ignores == 'true' + shell: bash + run: | + if [ -f .gitignore ]; then + if ! grep -q "super-linter-output" .gitignore; then + echo "super-linter-output" >> .gitignore + fi + if ! grep -q "super-linter.log" .gitignore; then + echo "super-linter.log" >> .gitignore + fi + if ! grep -q "github_conf" .gitignore; then + echo "github_conf" >> .gitignore + fi + else + echo "super-linter-output" > .gitignore + echo "super-linter.log" >> .gitignore + echo "github_conf" >> .gitignore + fi + - if: inputs.configure-ignores == 'true' + shell: bash + run: | + if [ -d terraform ]; then + if [ -f .gitignore ]; then + if ! grep -qF ".external_modules" .gitignore; then + echo ".external_modules" >> .gitignore + fi + if ! grep -qF "**/.external_modules" .gitignore; then + echo "**/.external_modules" >> .gitignore + fi + else + echo ".external_modules" > .gitignore + echo "**/.external_modules" >> .gitignore + fi + fi diff --git a/.github/linters/.tflint.hcl b/.github/linters/.tflint.hcl index 9ca790c..16e5d6e 100644 --- a/.github/linters/.tflint.hcl +++ b/.github/linters/.tflint.hcl @@ -3,7 +3,7 @@ // https://github.com/terraform-linters/tflint/blob/master/docs/user-guide/config.md config { - module = false + call_module_type = "none" force = false } diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 573bc52..65c47c4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -84,20 +84,13 @@ jobs: run: | echo 'The "do not merge" label is present. Please remove it before merging.' exit 1 - shell: bash - - name: Check if a setup action exists - id: check_files - uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 - with: - files: ./.github/actions/setup/action.yml - - name: Load super-linter configuration - run: grep -o '^[^#]*' .github/super-linter.env >> "$GITHUB_ENV" - - name: Setup application - uses: ./.github/actions/setup - if: steps.check_files.outputs.files_exists == 'true' + - name: Setup linting process + uses: ./.github/actions/setup-linter with: github-token: ${{ steps.get_workflow_token.outputs.token }} extensions: ${{ vars.EXTENSIONS || 'none' }} + external-setup: true + docs-generate: true - name: Lint Codebase uses: super-linter/super-linter/slim@85f7611e0f7b53c8573cca84aa0ed4344f6f6a4d # v7.2.1 # For a full list of environment variables see `.github/super-linter.env` @@ -105,7 +98,6 @@ jobs: GITHUB_TOKEN: ${{ github.token }} # Required for checkov pulling external modules from private repositories GITHUB_PAT: ${{ steps.get_workflow_token.outputs.token }} - VALIDATE_ALL_CODEBASE: ${{ vars.LINT_VALIDATE_ALL_CODEBASE || 'true' }} VALIDATE_PHP_PHPSTAN: ${{ vars.LINT_VALIDATE_PHPSTAN || null }} fix-lint-issues: @@ -134,63 +126,13 @@ jobs: with: fetch-depth: 0 token: ${{ steps.get_workflow_token.outputs.token }} - - name: Check if a setup action exists - id: check_files - uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0 - with: - files: ./.github/actions/setup/action.yml - - name: Load super-linter configuration - run: grep -o '^[^#]*' .github/super-linter.env >> "$GITHUB_ENV" - - name: Setup application - uses: ./.github/actions/setup - if: steps.check_files.outputs.files_exists == 'true' + - name: Setup linting process + uses: ./.github/actions/setup-linter with: github-token: ${{ steps.get_workflow_token.outputs.token }} extensions: ${{ vars.EXTENSIONS || 'none' }} - docs-generate: false - - name: Add ignores to .prettierignore file - run: | - if [ -d ./charts ]; then - if [ -f .prettierignore ]; then - if ! grep -q "charts/" .prettierignore; then - echo "charts/${REPO_NAME}/templates/**/*.yaml" >> .prettierignore - echo "charts/${REPO_NAME}/values/**/*.yaml" >> .prettierignore - fi - else - echo "charts/" > .prettierignore - fi - fi - if [ -f helmfile.yaml ]; then - if [ -f .prettierignore ]; then - if ! grep -q "helmfile.yaml" .prettierignore; then - echo "helmfile.yaml" >> .prettierignore - fi - else - echo "helmfile.yaml" > .prettierignore - fi - fi - env: - REPO_NAME: ${{ github.event.repository.name }} - - name: Add Prettier Ignore Comments - run: | - add_prettier_ignore() { - local marker="$1" - local comment="$2" - if [ "$comment" == "prettier-ignore-start" ]; then - find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \ - xargs -0 sed -i "//!b;//!i " - else - find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \ - xargs -0 sed -i "//!b;//!a " - fi - } - ensure_no_duplicates() { - find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \ - xargs -0 sed -i '//d; //d' - } - ensure_no_duplicates - add_prettier_ignore "BEGIN_TF_DOCS" "prettier-ignore-start" - add_prettier_ignore "END_TF_DOCS" "prettier-ignore-end" + external-setup: true + configure-ignores: true - name: Fix linting issues continue-on-error: true uses: super-linter/super-linter/slim@85f7611e0f7b53c8573cca84aa0ed4344f6f6a4d # v7.2.1 @@ -199,7 +141,6 @@ jobs: GITHUB_TOKEN: ${{ github.token }} # Required for checkov pulling external modules from private repositories GITHUB_PAT: ${{ steps.get_workflow_token.outputs.token }} - VALIDATE_ALL_CODEBASE: ${{ vars.LINT_VALIDATE_ALL_CODEBASE || 'true' }} VALIDATE_PHP_PHPSTAN: ${{ vars.LINT_VALIDATE_PHPSTAN || null }} # Do not write summary as we do not need it here ENABLE_GITHUB_ACTIONS_STEP_SUMMARY: false @@ -228,38 +169,6 @@ jobs: FIX_PROTOBUF: true FIX_GO_MODULES: true FIX_ENV: true - - name: Add super-linter ignores to .gitignore file - run: | - if [ -f .gitignore ]; then - if ! grep -q "super-linter-output" .gitignore; then - echo "super-linter-output" >> .gitignore - fi - if ! grep -q "super-linter.log" .gitignore; then - echo "super-linter.log" >> .gitignore - fi - if ! grep -q "github_conf" .gitignore; then - echo "github_conf" >> .gitignore - fi - else - echo "super-linter-output" > .gitignore - echo "super-linter.log" >> .gitignore - echo "github_conf" >> .gitignore - fi - - name: Add checkov ignores to .gitignore file - run: | - if [ -d terraform ]; then - if [ -f .gitignore ]; then - if ! grep -qF ".external_modules" .gitignore; then - echo ".external_modules" >> .gitignore - fi - if ! grep -qF "**/.external_modules" .gitignore; then - echo "**/.external_modules" >> .gitignore - fi - else - echo ".external_modules" > .gitignore - echo "**/.external_modules" >> .gitignore - fi - fi - name: Commit and push linting fixes uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1 with: diff --git a/.github/workflows/migrate_20241213.yml b/.github/workflows/migrate_20241213.yml index 808c85a..f800f6f 100644 --- a/.github/workflows/migrate_20241213.yml +++ b/.github/workflows/migrate_20241213.yml @@ -61,92 +61,11 @@ jobs: env: GH_TOKEN: ${{ secrets.GH_TOKEN_DEALROOMBA }} REPO_NAME: ${{ github.repository }} - - name: Add ignores to .gitignore file - run: | - if [ -f .gitignore ]; then - if ! grep -q "super-linter-output" .gitignore; then - echo "super-linter-output" >> .gitignore - fi - if ! grep -q "super-linter.log" .gitignore; then - echo "super-linter.log" >> .gitignore - fi - if ! grep -q "github_conf" .gitignore; then - echo "github_conf" >> .gitignore - fi - if ! grep -q "gha-creds-*.json" .gitignore; then - echo "gha-creds-*.json" >> .gitignore - fi - if ! grep -q "key.json" .gitignore; then - echo "*key.json" >> .gitignore - fi - else - { - echo "super-linter-output" - echo "super-linter.log" - echo "github_conf" - echo "gha-creds-*.json" - echo "*key.json" - } >> .gitignore - fi - - name: Add checkov ignores to .gitignore file - run: | - if [ -d terraform ]; then - if [ -f .gitignore ]; then - if ! grep -qF ".external_modules" .gitignore; then - echo ".external_modules" >> .gitignore - fi - if ! grep -qF "**/.external_modules" .gitignore; then - echo "**/.external_modules" >> .gitignore - fi - else - echo ".external_modules" > .gitignore - echo "**/.external_modules" >> .gitignore - fi - fi - - name: Add ignores to .prettierignore file - run: | - if [ -d ./charts ]; then - if [ -f .prettierignore ]; then - if ! grep -q "charts/" .prettierignore; then - echo "charts/${REPO_NAME}/templates/**/*.yaml" >> .prettierignore - echo "charts/${REPO_NAME}/values/**/*.yaml" >> .prettierignore - fi - else - echo "charts/${REPO_NAME}/templates/**/*.yaml" > .prettierignore - echo "charts/${REPO_NAME}/values/**/*.yaml" >> .prettierignore - fi - fi - if [ -f helmfile.yaml ]; then - if [ -f .prettierignore ]; then - if ! grep -q "helmfile.yaml" .prettierignore; then - echo "helmfile.yaml" >> .prettierignore - fi - else - echo "helmfile.yaml" > .prettierignore - fi - fi - env: - REPO_NAME: ${{ github.event.repository.name }} - - name: Add Prettier Ignore Comments - run: | - add_prettier_ignore() { - local marker="$1" - local comment="$2" - if [ "$comment" == "prettier-ignore-start" ]; then - find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \ - xargs -0 sed -i "//!b;//!i " - else - find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \ - xargs -0 sed -i "//!b;//!a " - fi - } - ensure_no_duplicates() { - find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \ - xargs -0 sed -i '//d; //d' - } - ensure_no_duplicates - add_prettier_ignore "BEGIN_TF_DOCS" "prettier-ignore-start" - add_prettier_ignore "END_TF_DOCS" "prettier-ignore-end" + - name: Setup linting ignore files + uses: ./.github/actions/setup-linter + with: + external-setup: false + configure-ignores: true - name: Create Migration PR uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5 with: