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
Empty file added .github/WORDLIST.txt
Empty file.
41 changes: 21 additions & 20 deletions .github/workflows/auto-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,45 @@ name: auto-format
on:
workflow_dispatch:
pull_request:
branches: [dev, main]

env:
GH_TOKEN: ${{ github.token }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
auto-format:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
if: github.event_name == 'pull_request'
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v2
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- uses: actions/checkout@v4
if: github.event_name != 'pull_request'
app-id: ${{ vars.CCBR_BOT_APP_ID }}
private-key: ${{ secrets.CCBR_BOT_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}

- uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ github.ref_name }}
token: ${{ steps.generate-token.outputs.token }}
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}

- name: git config
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

- name: Format R code with air
uses: rstudio/shiny-workflows/format-r-code@v1
git config --global user.name "CCBR-bot"
git config --global user.email "258092125+ccbr-bot@users.noreply.github.com"

- name: format
uses: pre-commit/action@v3.0.1
continue-on-error: true
- name: commit & push
if: ${{ github.event_name == 'pull_request' }}
run: |
git add .
git commit -m "ci: 🤖 auto-format" || echo "nothing to commit"
git commit -m "ci: 🤖 auto-format with pre-commit" || echo "nothing to commit"
git push || echo "nothing to push"
10 changes: 7 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ name: tests

on:
push:
branches: [ main, dev ]
branches: [main, dev]
pull_request:
branches: [ main, dev ]
branches: [main, dev]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v7

- name: Parse environment.json and set Docker image
id: docker_image
Expand Down
52 changes: 52 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
default_install_hook_types: [pre-commit, commit-msg]
default_stages: [pre-commit]
exclude: |
(?x)(
^.codeocean/|
^environment/|
^metadata/|
^code/MOSuite|
^code/SCWorkflow|
^code/OMIX*
)

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-added-large-files
args: ["--maxkb=10240"]
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-json
# spell check
- repo: https://github.com/codespell-project/codespell
rev: v2.4.2
hooks:
- id: codespell
args:
[ -I, .github/WORDLIST.txt ]
# R formatting
- repo: https://github.com/posit-dev/air-pre-commit
rev: 0.10.0
hooks:
- id: air-format
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.3.9028
hooks:
- id: parsable-R
# Python formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.16
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format

# enforce conventional commit format
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.4.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: []
Loading