-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f9514b
commit 941a6a0
Showing
1 changed file
with
61 additions
and
43 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 |
---|---|---|
@@ -1,55 +1,73 @@ | ||
--- | ||
#################### | ||
#################### | ||
## Auto Formatter ## | ||
#################### | ||
#################### | ||
name: Formate Code | ||
|
||
# | ||
# Documentation: | ||
# https://github.com/mezgoodle/auto-formatter | ||
# | ||
|
||
############################# | ||
# Start the job on all push # | ||
############################# | ||
name: formatting check | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- "*/**" | ||
pull_request: | ||
paths: | ||
push: | ||
paths: | ||
- "*/**" | ||
# Remove the line above to run when pull-requesting to master | ||
workflow_run: | ||
workflows: ["Dependabot PR Check"] | ||
types: | ||
- completed | ||
|
||
permissions: | ||
contents: read | ||
|
||
############### | ||
# Set the Job # | ||
############### | ||
jobs: | ||
build: | ||
# Name the Job | ||
name: Formate Code | ||
# Set the agent to run on | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.11"] | ||
poetry-version: ["1.7"] | ||
|
||
defaults: | ||
run: | ||
working-directory: discord_bot | ||
|
||
################## | ||
# Load all steps # | ||
################## | ||
steps: | ||
########################## | ||
# Checkout the code base # | ||
########################## | ||
- name: Checkout Code | ||
- name: 📥 Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
# Full git history is needed to get a proper list of changed files within `auto-formatter` | ||
fetch-depth: 0 | ||
|
||
################################ | ||
# Run Auto-formatter against code base # | ||
################################ | ||
- name: Auto-Formatter | ||
uses: mezgoodle/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.TOKEN }} | ||
sparse-checkout: "discord_bot" | ||
sparse-checkout-cone-mode: false | ||
|
||
- name: 🐍 Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: 📜 Install poetry | ||
uses: abatilo/actions-poetry@v2 | ||
with: | ||
poetry-version: ${{ matrix.poetry-version }} | ||
|
||
- name: 🚀 Cache the venv based on the .lock | ||
uses: actions/cache@v3 | ||
with: | ||
path: discord_bot/.venv | ||
key: venv-${{ hashFiles('discord_bot/poetry.lock') }} | ||
|
||
- name: 🔨 Install dev dependencies | ||
run: poetry install --with dev | ||
|
||
- name: 🧑🔧 Lint with ruff | ||
run: poetry run ruff check . | ||
|
||
- name: 🧹 Format with black | ||
run: poetry run black --check . | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pre-commit | ||
- name: Run pre-commit | ||
run: | | ||
pre-commit run --all-files | ||
- name: 🧪 Run tests | ||
run: poetry run pytest |