Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update Makefile, transition from Travis CI #1911

Merged
merged 5 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
44 changes: 44 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI/CD
ITProKyle marked this conversation as resolved.
Show resolved Hide resolved


on:
pull_request:
push:
branches:
- master
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also include branch main

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? This repo does not have a main branch and the default branch is master.



defaults:
run:
shell: bash


jobs:
test-python:
name: Python Linting & Tests
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Pip Cache (Linux)
uses: actions/cache@v1
if: runner.os == 'Linux'
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}
- name: Install Python Dependencies
run: |
pip install --upgrade pip setuptools wheel
pip install --upgrade flake8 cfn_flip>=1.0.2
ITProKyle marked this conversation as resolved.
Show resolved Hide resolved
- name: Run Lints
run: make lint
- name: Run Tests
run: make test
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

69 changes: 53 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,48 @@

PYDIRS=setup.py examples scripts tests troposphere

test:
flake8 ${PYDIRS}
python setup.py test
black --check ${PYDIRS}
isort --check ${PYDIRS}
help: ## show this message
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
printf "%-30s %s\n" "target" "help" ; \
printf "%-30s %s\n" "------" "----" ; \
for help_line in $${help_lines[@]}; do \
IFS=$$':' ; \
help_split=($$help_line) ; \
help_command=`echo $${help_split[0]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
help_info=`echo $${help_split[2]} | sed -e 's/^ *//' -e 's/ *$$//'` ; \
printf '\033[36m'; \
printf "%-30s %s" $$help_command ; \
printf '\033[0m'; \
printf "%s\n" $$help_info; \
done

spec:
curl -O https://d1uauaxba7bl26.cloudfront.net/latest/CloudFormationResourceSpecification.zip
rm -rf spec
mkdir spec
unzip -d spec CloudFormationResourceSpecification.zip
rm CloudFormationResourceSpecification.zip
fix-black: ## automatically fix all black errors
@black ${PYDIRS}

spec2:
curl -O --compressed https://d1uauaxba7bl26.cloudfront.net/latest/gzip/CloudFormationResourceSpecification.json
/bin/echo -n "Downloaded version: " && jq .ResourceSpecificationVersion CloudFormationResourceSpecification.json
fix-isort: ## automatically fix all isort errors
@isort ${PYDIRS}

clean:
rm -rf ${p39dir} troposphere.egg-info

lint: lint-flake8 ## run all linters
Copy link
Contributor

@michael-k michael-k Jun 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this also run lint-black and lint-isort? Or the comment should be adjusted.

right now, only configured to forward to the lint-flake8 target as it is the only thing being run as a check currently

I don't think this restriction is necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this restriction is necessary

If I were to add the other targets here before the codebase is updated to pass both black and isort checks, the action I added will always fail. This target is being used as the main linting entry point for the workflow and to provide an entry point for local linting.

I plan to have a few follow-up PRs to this one that will address this concern by pairing it with updates to the code to pass these checks. I this them out, for now, to cut reduce the diffs for an easier review.


lint-black: ## run black
@echo "Running black... If this fails, run 'make fix-black' to resolve."
@black ${PYDIRS} --check --color --diff
@echo ""

lint-flake8: ## run flake8
@echo "Running flake8..."
@flake8 --version
@flake8 --config=setup.cfg --show-source
@echo ""

lint-isort: ## run isort
@echo "Running isort... If this fails, run 'make fix-isort' to resolve."
@isort ${PYDIRS} --check-only
@echo ""

release-test:
python setup.py sdist
Expand All @@ -34,5 +60,16 @@ release-test-39:
deactivate && \
rm -rf ${p39dir}

clean:
rm -rf ${p39dir} troposphere.egg-info
spec:
curl -O https://d1uauaxba7bl26.cloudfront.net/latest/CloudFormationResourceSpecification.zip
rm -rf spec
mkdir spec
unzip -d spec CloudFormationResourceSpecification.zip
rm CloudFormationResourceSpecification.zip

spec2:
curl -O --compressed https://d1uauaxba7bl26.cloudfront.net/latest/gzip/CloudFormationResourceSpecification.json
/bin/echo -n "Downloaded version: " && jq .ResourceSpecificationVersion CloudFormationResourceSpecification.json

test: ## run tests
@python setup.py test