From df65d12561a5b38b226259de79023674550be291 Mon Sep 17 00:00:00 2001 From: Marius Ghita Date: Mon, 28 Oct 2024 17:59:08 +0200 Subject: [PATCH] chore: repo-ansible run --- .devcontainer/devcontainer.json | 39 +++++++------- .devcontainer/git/hooks/pre-push | 6 ++- .devcontainer/postCreate.sh | 2 - .devcontainer/postStart.sh | 7 +++ .github/settings.yml | 2 +- .github/workflows/10-review.yaml | 53 ++++++++++++++++++++ .github/workflows/dependabot-auto-merge.yaml | 6 +-- .github/workflows/repo-ansible.yaml | 32 +++--------- composer-unused.php | 15 ------ 9 files changed, 93 insertions(+), 69 deletions(-) create mode 100644 .github/workflows/10-review.yaml delete mode 100644 composer-unused.php diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0d14213..eb42f96 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -15,27 +15,26 @@ "ghcr.io/devcontainers/features/docker-in-docker:1": {} }, - // Configure tool-specific properties. "customizations": { - // Configure properties specific to VS Code. - "vscode": { - // Set *default* container specific settings.json values on container create. - "settings": { - "php.validate.executablePath": "/usr/local/bin/php", - "yaml.schemas": { - "https://raw.githubusercontent.com/linkorb/repo-ansible/main/repo.schema.yaml": ["repo.yaml"] - }, - // YAML extension by RedHat that prompts on each new devcontainer to enable telemetry - "redhat.telemetry.enabled": false - }, - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "xdebug.php-debug", - "bmewburn.vscode-intelephense-client", - "mrmlnc.vscode-apache", - "74th.json-yaml-schema-selector" - ] - } + // auto-generated based on repo-ansible defaults + repo.yaml (devcontainer.customizations_vscode) definition + "vscode": +{ + "extensions": [ + "xdebug.php-debug", + "bmewburn.vscode-intelephense-client", + "mrmlnc.vscode-apache", + "74th.json-yaml-schema-selector" + ], + "settings": { + "php.validate.executablePath": "/usr/local/bin/php", + "yaml.schemas": { + "https://raw.githubusercontent.com/linkorb/repo-ansible/main/repo.schema.yaml": [ + "repo.yaml" + ] + }, + "redhat.telemetry.enabled": false + } +} }, "forwardPorts": [ 80, 8000 ], "remoteUser": "vscode", diff --git a/.devcontainer/git/hooks/pre-push b/.devcontainer/git/hooks/pre-push index 92b7a7f..2e973ee 100644 --- a/.devcontainer/git/hooks/pre-push +++ b/.devcontainer/git/hooks/pre-push @@ -1,8 +1,10 @@ #!/usr/bin/bash temporary_file=$(mktemp) -composer-unused --no-progress --output-format=github > $temporary_file +# Temporary workaround on issue reported in #8432 +# shellcheck disable=2024 +sudo composer-unused --no-progress --output-format=github > "$temporary_file" exit_code=$? -cat $temporary_file | grep -v 'ignored' +grep -v 'ignored' "$temporary_file" exit $exit_code diff --git a/.devcontainer/postCreate.sh b/.devcontainer/postCreate.sh index 689bcba..8c8ee46 100755 --- a/.devcontainer/postCreate.sh +++ b/.devcontainer/postCreate.sh @@ -7,8 +7,6 @@ sudo rm /usr/lib/python3.*/EXTERNALLY-MANAGED || true git config commit.template .devcontainer/git/linkorb_commit.template -cp .devcontainer/git/hooks/pre-push .git/hooks/pre-push -chmod +x .git/hooks/pre-push composer config --global --auth http-basic.repo.packagist.com "$GITHUB_USER" "$PACKAGIST_TOKEN" diff --git a/.devcontainer/postStart.sh b/.devcontainer/postStart.sh index 8fa1418..0afd521 100755 --- a/.devcontainer/postStart.sh +++ b/.devcontainer/postStart.sh @@ -1,3 +1,10 @@ #!/usr/bin/env bash # Managed by https://github.com/linkorb/repo-ansible. Manual changes will be overwritten. +# pre-push composer-unused hook disabled. See Card #8980 +if [ -f .git/hooks/pre-push ]; then + diff .devcontainer/git/hooks/pre-push .git/hooks/pre-push + if [ $? -eq 0 ]; then + rm .git/hooks/pre-push + fi +fi diff --git a/.github/settings.yml b/.github/settings.yml index 9148711..0e8f16d 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -10,6 +10,7 @@ repository: # A short description of the repository that will show up on GitHub description: "Connector: Database connection resolver" + # A URL with more information about the repository homepage: https://engineering.linkorb.com @@ -71,4 +72,3 @@ labels: # Milestones: define milestones for Issues and Pull Requests - diff --git a/.github/workflows/10-review.yaml b/.github/workflows/10-review.yaml new file mode 100644 index 0000000..5167f6a --- /dev/null +++ b/.github/workflows/10-review.yaml @@ -0,0 +1,53 @@ +# Managed by https://github.com/linkorb/repo-ansible. Manual changes will be overwritten. +name: Review + +on: + pull_request_target: + types: [opened, edited, reopened, synchronize] + workflow_call: + +jobs: + commit-conventions: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + # interesting alternative: https://github.com/cocogitto/cocogitto + - name: Conventional commit checker + uses: webiny/action-conventional-commits@v1.3.0 + # XXX: normal action versioning syntax (`@v1`) doesn't work with this action, + # possibly because not published on the GitHub marketplace + + - name: Check Card# reference + uses: gsactions/commit-message-checker@v2 + with: + # Matches lines that end in a card number: #1234 + # Matches lines that end in a card number and PR reference: #1234 (#20) + pattern: '#\d{4}(\s+\(#\d+\))?' + flags: 'gm' + error: 'Your commit message has to end with a card number like "#1234".' + excludeDescription: 'true' # optional: this excludes the description body of a pull request + excludeTitle: 'true' # optional: this excludes the title of a pull request + checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request + accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true + + - name: Check Line Length + uses: gsactions/commit-message-checker@v2 + with: + pattern: '^.{0,50}$' + error: 'The maximum line length of 50 characters is exceeded.' + excludeDescription: 'true' # optional: this excludes the description body of a pull request + excludeTitle: 'true' # optional: this excludes the title of a pull request + checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request + accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true + + - name: Check Body Length + uses: gsactions/commit-message-checker@v2 + with: + pattern: '^.{0,72}$' + error: 'The maximum line length of 72 characters is exceeded in the body.' + excludeDescription: 'false' # optional: this excludes the description body of a pull request + excludeTitle: 'true' # optional: this excludes the title of a pull request + checkAllCommitMessages: 'true' # optional: this checks all commits associated with a pull request + accessToken: ${{ secrets.GITHUB_TOKEN }} # github access token is only required if checkAllCommitMessages is true diff --git a/.github/workflows/dependabot-auto-merge.yaml b/.github/workflows/dependabot-auto-merge.yaml index f24a91c..ce97a2a 100644 --- a/.github/workflows/dependabot-auto-merge.yaml +++ b/.github/workflows/dependabot-auto-merge.yaml @@ -1,4 +1,4 @@ -name: Dependabot auto-merge +name: Auto-merge Dependabot PRs on: pull_request_target permissions: @@ -6,13 +6,13 @@ permissions: contents: write # required for the gh client to read/merge commits jobs: - dependabot: + run: runs-on: ubuntu-latest if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }} steps: - name: Dependabot metadata id: metadata - uses: dependabot/fetch-metadata@v1 + uses: dependabot/fetch-metadata@v2 - name: Enable auto-merge for Dependabot PRs if: steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch' diff --git a/.github/workflows/repo-ansible.yaml b/.github/workflows/repo-ansible.yaml index d17ee74..9c524d5 100644 --- a/.github/workflows/repo-ansible.yaml +++ b/.github/workflows/repo-ansible.yaml @@ -1,4 +1,4 @@ -name: repo-ansible +name: Auto-run repo-ansible on: workflow_dispatch: @@ -27,35 +27,16 @@ jobs: steps: - if: ${{ env.IS_PULL_REQUEST == '0' }} uses: actions/checkout@v4 - with: - path: current - if: ${{ env.IS_PULL_REQUEST == '1' }} uses: actions/checkout@v4 with: - path: current ref: refs/pull/${{ github.event.pull_request.number }}/merge - - uses: actions/checkout@v4 - with: - repository: linkorb/repo-ansible - path: repo-ansible - - - # XXX ansible installed within GitHub Runner via pipx, which doesn't support direct installation from a file - # like pip does. See https://github.com/pypa/pipx/issues/934 - - name: install repo-ansible dependencies - working-directory: repo-ansible - run: cat requirements.txt | xargs pipx inject ansible-core - - - - name: run ansible playbook - working-directory: current - env: - ANSIBLE_DISPLAY_OK_HOSTS: 0 - ANSIBLE_DISPLAY_SKIPPED_HOSTS: 0 + - name: repo-ansible run: | - ansible-playbook ../repo-ansible/playbook-cwd.yaml | tee /tmp/repo_ansible_output + docker pull ghcr.io/linkorb/repo-ansible:latest >/dev/null + docker run --rm -v "$PWD":/app ghcr.io/linkorb/repo-ansible:latest | tee /tmp/repo_ansible_output export OUTPUT=$(cat /tmp/repo_ansible_output) { echo 'REPO_ANSIBLE_OUTPUT<addPatternFilter(PatternFilter::fromString('/^ext-.*/')) - ; -};