Skip to content

Commit

Permalink
🔄 synced file(s) with dealroom/core-mothership (#233)
Browse files Browse the repository at this point in the history
Co-authored-by: dealroomba-app[bot] <189869926+dealroomba-app[bot]@users.noreply.github.com>
  • Loading branch information
dealroomba-app[bot] authored Dec 17, 2024
1 parent 838731d commit 04a82df
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 186 deletions.
125 changes: 125 additions & 0 deletions .github/actions/setup-linter/action.yml
Original file line number Diff line number Diff line change
@@ -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 "/<!-- ${marker} -->/!b;/<!-- ${comment} -->/!i <!-- ${comment} -->"
else
find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \
xargs -0 sed -i "/<!-- ${marker} -->/!b;/<!-- ${comment} -->/!a <!-- ${comment} -->"
fi
}
ensure_no_duplicates() {
find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \
xargs -0 sed -i '/<!-- prettier-ignore-start -->/d; /<!-- prettier-ignore-end -->/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
2 changes: 1 addition & 1 deletion .github/linters/.tflint.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
107 changes: 8 additions & 99 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,20 @@ 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`
env:
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:
Expand Down Expand Up @@ -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 "/<!-- ${marker} -->/!b;/<!-- ${comment} -->/!i <!-- ${comment} -->"
else
find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \
xargs -0 sed -i "/<!-- ${marker} -->/!b;/<!-- ${comment} -->/!a <!-- ${comment} -->"
fi
}
ensure_no_duplicates() {
find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \
xargs -0 sed -i '/<!-- prettier-ignore-start -->/d; /<!-- prettier-ignore-end -->/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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
91 changes: 5 additions & 86 deletions .github/workflows/migrate_20241213.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "/<!-- ${marker} -->/!b;/<!-- ${comment} -->/!i <!-- ${comment} -->"
else
find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \
xargs -0 sed -i "/<!-- ${marker} -->/!b;/<!-- ${comment} -->/!a <!-- ${comment} -->"
fi
}
ensure_no_duplicates() {
find . -type d -name ".terraform" -prune -o -type f -name "README.md" -print0 | \
xargs -0 sed -i '/<!-- prettier-ignore-start -->/d; /<!-- prettier-ignore-end -->/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:
Expand Down

0 comments on commit 04a82df

Please sign in to comment.