Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: repo-ansible run #10

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions .devcontainer/git/hooks/pre-push
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
7 changes: 7 additions & 0 deletions .devcontainer/postStart.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -71,4 +72,3 @@ labels:


# Milestones: define milestones for Issues and Pull Requests

53 changes: 53 additions & 0 deletions .github/workflows/10-review.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
# 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
6 changes: 3 additions & 3 deletions .github/workflows/dependabot-auto-merge.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: Dependabot auto-merge
name: Auto-merge Dependabot PRs
on: pull_request_target

permissions:
pull-requests: write # required for the action to read metadata
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'
Expand Down
32 changes: 6 additions & 26 deletions .github/workflows/repo-ansible.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: repo-ansible
name: Auto-run repo-ansible

on:
workflow_dispatch:
Expand Down Expand Up @@ -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<<EOF'
Expand All @@ -70,10 +51,9 @@ jobs:

- if: ${{ env.IS_PULL_REQUEST == '0' }}
name: commit changes
working-directory: current
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
if git commit -m "chore: repo-ansible run"; then
git push
Expand Down
15 changes: 0 additions & 15 deletions composer-unused.php

This file was deleted.