Skip to content
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
41 changes: 41 additions & 0 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Common setup"
description: "Shared setup steps for the workflows"

runs:
using: "composite"
steps:
- name: Export env
shell: bash
run: |
ARCH=$(echo $(uname -m) | sed -e 's:i686:i386:g')
OS_CODE_NAME="$(lsb_release -sc)"
echo "ARCH=${ARCH}" >> $GITHUB_ENV
echo "OS_CODE_NAME=${OS_CODE_NAME}" >> $GITHUB_ENV

- name: Set up Python
uses: actions/setup-python@v5
id: setup-python
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: etc/pip/dev-requirements.txt

- name: Install Python deps
shell: bash
run: |
python3 -m pip install -r etc/pip/dev-requirements.txt

- name: Toolchain cache
uses: actions/cache@v4
id: toolchain
with:
path: /opt/mongodbtoolchain
key: toolchain-${{ env.OS_CODE_NAME }}-${{ env.ARCH }}

- name: Install toolchain
shell: bash
if: steps.toolchain.outputs.cache-hit != 'true'
run: |
curl -O https://downloads.percona.com/downloads/packaging/toolchain_installer.tar.gz
tar -zxvf toolchain_installer.tar.gz
bash -x ./installer.sh -k --download-url "https://downloads.percona.com/downloads/packaging/${OS_CODE_NAME}_mongodbtoolchain_${ARCH}.tar.gz"
54 changes: 54 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: format

on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]

permissions:
contents: read

jobs:
analyze:
name: Check code formatting
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'ci-skip-format') }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/actions/setup-env

- name: Run linters
run: |
echo "Running clang-format"
buildscripts/clang_format.py format
echo "Running python formatters"
buildscripts/pylinters.py fix
echo "Running python scons formatter"
buildscripts/pylinters.py fix-scons
echo "Running javascript formatters"
buildscripts/eslint.py fix

- name: Verify formatting
run: |
if ! git diff --quiet; then
echo "::error::Formatting issues detected."
echo ""
echo "Your PR is not properly formatted."
echo ""
echo "To fix the problem locally, run:"
echo ""
echo " buildscripts/clang_format.py format"
echo " buildscripts/pylinters.py fix"
echo " buildscripts/pylinters.py fix-scons"
echo " buildscripts/eslint.py fix"
echo ""
echo "and commit the resulting changes."
echo ""
echo "Affected files:"
git diff --stat
echo "Diff:"
git diff | head -n 1000
exit 1
fi