Skip to content

Commit

Permalink
Merge pull request #121 from UoA-CARES/chore/add-auto-formatting
Browse files Browse the repository at this point in the history
Add autoformatting workflow
  • Loading branch information
beardyFace authored Feb 29, 2024
2 parents 4a44f36 + f1635ab commit 2c91b13
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/autoformatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Auto Formatter

on:
pull_request:
branches:
- "*"

permissions:
contents: read

jobs:

format:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
token: ${{ secrets.BOT_ACCESS_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.11"

- name: Install Black
run: pip install black

- name: Run Black Formatter
run: black .

- name: Check for changes
id: check_changes
run: |
if [ -n "$(git diff)" ]; then
echo "::set-output name=changed::true"
else
echo "::set-output name=changed::false"
fi
continue-on-error: true

# Optionally, customize the user name and commit message, and can add an email as well such as Github Actions' email
- name: Set up Git and Commit Changes
run: |
if [ "${{ steps.check_changes.outputs.changed }}" == "true" ]; then
git config --local user.name "Formatter [BOT]"
git add .
git commit -m "Auto-format code 🧹🌟🤖"
git push
fi
1 change: 1 addition & 0 deletions cares_reinforcement_learning/util/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
def set_seed(seed):
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)

np.random.seed(seed)
random.seed(seed)

Expand Down

0 comments on commit 2c91b13

Please sign in to comment.