-
Notifications
You must be signed in to change notification settings - Fork 1
42 lines (36 loc) · 1.02 KB
/
Copy pathpre-commit.yaml
File metadata and controls
42 lines (36 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Lint and format
on:
pull_request:
branches:
- main
jobs:
check_if_branch_is_ahead_of_main:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check if branch is ahead of main
run: |
if ! git merge-base --is-ancestor origin/main ${{ github.event.pull_request.head.sha }};
then echo "This branch is not up to date with main";
exit 1; fi
test:
needs: check_if_branch_is_ahead_of_main
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Changed files
id: changed_files
uses: tj-actions/changed-files@v44
- uses: pre-commit/action@v3.0.1
with:
extra_args: --files ${{ steps.changed_files.outputs.all_changed_files }}