-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷🏻 ci: implement code formatting pipeline
Refs: DEVTOOL-22
- Loading branch information
1 parent
7a578c6
commit 45ca1f0
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Format Pipeline | ||
|
||
permissions: | ||
contents: write | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
python-version: [3.11] | ||
timeout-minutes: 15 | ||
steps: | ||
- name: 📥 Checkout the repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 # Only last commit | ||
|
||
- name: 🐍 Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- id: cache | ||
name: 📦 Create cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ runner.os }}-python-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml', 'requirements.txt', 'requirements_dev.txt') }} | ||
|
||
- name: 📦 Install dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: | | ||
pip install -r requirements_dev.txt --no-warn-script-location --no-python-version-warning --no-warn-conflicts | ||
- name: 🏃 Run Formatter | ||
run: bash scripts/format.sh | ||
|
||
- name: 📤 Commit & Push Changes | ||
run: | | ||
if ! git diff-index --quiet HEAD --; then | ||
git config --global user.name "Formatter Action" | ||
git config --global user.email "formatter@github.com" | ||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | ||
git add . | ||
git commit -m "🔨 refactor: run automatic formatter" | ||
git push origin HEAD:${{ github.ref }} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh -e | ||
set -x | ||
|
||
wget https://raw.githubusercontent.com/adriamontoto/dotfiles/master/python/ruff.toml --output-document /tmp/ruff.toml | ||
|
||
ruff check developing_tools tests --fix-only --config /tmp/ruff.toml | ||
ruff format developing_tools tests --config /tmp/ruff.toml |