Skip to content

Commit

Permalink
Update CI to limit runs to modified files (#51)
Browse files Browse the repository at this point in the history
* Add hard version limits to track in CI

* Rename format.yml to style.yml

* Use changes only build docs when they're changed

* Add style checks to changes system

* Fix typo with style checks

* Add permissions scope to changes

* Add debug job

* Add debug to changes job

* Check debug in change job

* Remove debug statements
  • Loading branch information
alecbcs authored Nov 8, 2023
1 parent adac499 commit 4d8267a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 40 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: ci
on:
push:
branches:
- develop
pull_request:
branches:
- develop

concurrency:
group: ci-${{github.ref}}-${{github.event.pull_request.number || github.run_number}}
cancel-in-progress: true

jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
docs: ${{ steps.filter.outputs.docs }}
style: ${{ steps.filter.outputs.style }}

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # @v2
if: ${{ github.event_name == 'push' }}
with:
fetch-depth: 0

# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50
id: filter
with:
filters: |
docs:
- '.github/**'
- 'docs/**'
style:
- '.github/**'
- 'bin/**'
- 'configs/**'
- 'docs/conf.py'
- 'experiments/**'
- 'repo/**'
docs:
if: ${{ needs.changes.outputs.docs == 'true' }}
needs: changes
uses: ./.github/workflows/docs.yml

style:
if: ${{ needs.changes.outputs.style == 'true' }}
needs: changes
uses: ./.github/workflows/style.yml
13 changes: 3 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
name: Build & Deploy docs site to GitHub Pages
on:
push:
branches:
- develop
pull_request:
branches:
- develop

concurrency:
group: "pages"
cancel-in-progress: true
# This Workflow can be triggered manually
workflow_dispatch:
workflow_call:

jobs:
build:
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/format.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/requirements/style.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
black==23.10.1
flake8==6.1.0
27 changes: 27 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Linting & Style Checks
on:
# This Workflow can be triggered manually
workflow_dispatch:
workflow_call:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Set up Python 3.11
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236
with:
python-version: '3.11'
cache: 'pip'
cache-dependency-path: '.github/workflows/requirements/style.txt'

- name: Install Python dependencies
run: |
pip install -r .github/workflows/requirements/style.txt
- name: Lint and Format Check with Flake8 and Black
run: |
black --diff --check .
flake8

0 comments on commit 4d8267a

Please sign in to comment.