Skip to content

Commit

Permalink
Split autofixes into its own workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel-Therrien-Beslogic committed Nov 19, 2024
1 parent 2dd0756 commit d463d1c
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/canopeum_backend_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ on:

jobs:
Build:
runs-on: "ubuntu-latest"
runs-on: ubuntu-latest
defaults:
run:
working-directory: canopeum_backend
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: 'login'
- name: login
uses: docker/login-action@v1
with:
registry: ghcr.io
Expand Down
24 changes: 2 additions & 22 deletions .github/workflows/canopeum_backend_pr_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,34 +64,14 @@ jobs:
python-version: "3.12"
working-directory: canopeum_backend

Ruff-Autofixes:
Ruff:
runs-on: unbuntu-latest
defaults:
run:
working-directory: canopeum_backend
# Only run autofixes on PRs
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
# Token with Contents permissions to allow retriggering workflow
token: ${{ secrets.PR_AUTOFIX_PAT }}
- run: echo "${{github.event.head_commit.author.name}}"
- uses: astral-sh/ruff-action@v1
with:
args: check --fix
- uses: astral-sh/ruff-action@v1
# Format even on lint failure
if: ${{ !cancelled() }}
with:
args: format
- name: Commit autofixes
uses: EndBug/add-and-commit@v9
# TODO: Prevent infinite loops, github.event.head_commit.author.name is not accessible in this context
# if: ${{ github.event.head_commit.author.name != 'github-actions' }}
# Push autofixes even on failure
if: ${{ !cancelled() }}
with:
default_author: github_actions
args: format --check
2 changes: 1 addition & 1 deletion .github/workflows/canopeum_frontend_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: npm ci
- name: Build project
run: npm run build
- name: 'login'
- name: login
uses: docker/login-action@v1
with:
registry: ghcr.io
Expand Down
19 changes: 2 additions & 17 deletions .github/workflows/canopeum_frontend_pr_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,16 @@ on:
- ".github/workflows/canopeum_frontend_pr_validation.yml"

jobs:
Lint-Autofixes:
Lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: canopeum_frontend
# Only run autofixes on PRs
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
# Token with Contents permissions to allow retriggering workflow
token: ${{ secrets.PR_AUTOFIX_PAT }}
- uses: actions/setup-node@v4
- run: npm ci
- run: npm run lint:fix
- name: Commit autofixes
uses: EndBug/add-and-commit@v9
# TODO: Prevent infinite loops, github.event.head_commit.author.name is not accessible in this context
# if: ${{ github.event.head_commit.author.name != 'github-actions' }}
# Push autofixes even on failure
if: ${{ !cancelled() }}
with:
default_author: github_actions
- run: npm run lint

Build:
runs-on: ubuntu-latest
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/pr_autofixes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: PR Autofixes

on:
pull_request:
branches:
- main

jobs:
Autofixes:
runs-on: unbuntu-latest
# Only run autofixes on PRs
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
# Token with Contents permissions to allow retriggering workflow
token: ${{ secrets.PR_AUTOFIX_PAT }}

# Ruff autofixes
- run: cd canopeum_backend
- uses: astral-sh/ruff-action@v1
# Fix even on other steps failure
if: ${{ !cancelled() }}
with:
args: check --fix
- uses: astral-sh/ruff-action@v1
# Format even on lint failure
if: ${{ !cancelled() }}
with:
args: format

# ESLint & Dprint autofixes
- run: cd ../canopeum_frontend
- run: npm run lint:fix
# Fix even on other steps failure
if: ${{ !cancelled() }}

- name: Commit autofixes
uses: EndBug/add-and-commit@v9
# TODO: Prevent infinite loops, github.event.head_commit.author.name is not accessible in this context
# if: ${{ github.event.head_commit.author.name != 'github-actions' }}
# Push autofixes even on failure
if: ${{ !cancelled() }}
with:
default_author: github_actions

0 comments on commit d463d1c

Please sign in to comment.