Skip to content

Instantly share code, notes, and snippets.

@girisagar46
Last active February 15, 2020 16:26
Show Gist options
  • Select an option

  • Save girisagar46/a2c7afc040b43b5fe1af0334ce0d5a4e to your computer and use it in GitHub Desktop.

Select an option

Save girisagar46/a2c7afc040b43b5fe1af0334ce0d5a4e to your computer and use it in GitHub Desktop.
CircleCI check only changed files
version: 2.1
executors:
default:
working_directory: ~/workspace
docker:
- image: circleci/python:3.5
jobs:
lint:
executor:
name: default
steps:
- checkout
- run: sudo pip install flake8
- run:
name: Lint files
command: |
make check-syntax-errors check-style
.circleci/flake8-lint.sh
workflows:
ci:
jobs:
- lint
version: 2.1
executors:
default:
working_directory: ~/workspace
docker:
- image: circleci/python:3.5
jobs:
lint:
executor:
name: default
steps:
- checkout
- run: sudo pip install flake8
- run:
name: Lint files
command: |
CHANGED_FILES=$(git diff --name-only << pipeline.git.base_revision >> <<pipeline.git.revision>> -- "*.py") # CircleCI pipeline should be enabled
echo ${CHANGED_FILES}
echo ${CHANGED_FILES} | xargs --no-run-if-empty flake8
workflows:
ci:
jobs:
- lint
#! /usr/bin/env bash
last_tagged_commit=`git describe --tags --abbrev=0 --first-parent` # --first-parent ensures we don't follow tags not published in master through an unlikely intermediary merge commit
echo $last_tagged_commit
if ! changes=$(git diff-index --name-only --diff-filter=ACMR --exit-code $last_tagged_commit -- "*.py")
then
echo "Running flake8 on these changed files:"
echo $changes
flake8 $changes
else echo "Changes not detected."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment