-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from cytopia/release-0.1
Initial release
- Loading branch information
Showing
5 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
|
||
### | ||
### Enable sudo (required for docker service) | ||
### | ||
sudo: required | ||
|
||
|
||
### | ||
### Language | ||
### | ||
language: python | ||
|
||
|
||
### | ||
### Add services | ||
### | ||
services: | ||
- docker | ||
|
||
|
||
### | ||
### Build Matrix | ||
### | ||
env: | ||
matrix: | ||
- VERSION=latest | ||
|
||
|
||
### | ||
### Install requirements | ||
### | ||
install: | ||
# Get newer docker version | ||
- while ! sudo apt-get update; do sleep 1; done | ||
- while ! sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce; do sleep 1; done | ||
- docker version | ||
|
||
|
||
### | ||
### Check generation changes, build and test | ||
### | ||
before_script: | ||
- make lint | ||
- while ! make build TAG=${VERSION}; do sleep 1; done | ||
- while ! make test TAG=${VERSION}; do sleep 1; done | ||
|
||
|
||
### | ||
### Push to Dockerhub | ||
### | ||
script: | ||
# Push to docker hub on success | ||
- if [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then | ||
while ! make login USER="${DOCKER_USERNAME}" PASS="${DOCKER_PASSWORD}"; do sleep 1; done; | ||
if [ -n "${TRAVIS_TAG}" ]; then | ||
while ! make push TAG="${VERSION}-${TRAVIS_TAG}"; do sleep 1; done; | ||
elif [ "${TRAVIS_BRANCH}" == "master" ]; then | ||
while ! make push TAG=${VERSION}; do sleep 1; done; | ||
elif [[ ${TRAVIS_BRANCH} =~ ^(release-[.0-9]+)$ ]]; then | ||
while ! make push TAG="${VERSION}-${TRAVIS_BRANCH}"; do sleep 1; done; | ||
else | ||
echo "Skipping branch ${TRAVIS_BRANCH}"; | ||
fi | ||
else | ||
echo "Skipping push on PR"; | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
FROM alpine:3.9 as builder | ||
|
||
RUN set -x \ | ||
&& apk add --no-cache \ | ||
bc \ | ||
gcc \ | ||
libffi-dev \ | ||
make \ | ||
musl-dev \ | ||
openssl-dev \ | ||
python3 \ | ||
python3-dev | ||
|
||
ARG VERSION=latest | ||
RUN set -x \ | ||
&& if [ "${VERSION}" = "latest" ]; then \ | ||
pip3 install --no-cache-dir --no-compile pylint; \ | ||
else \ | ||
pip3 install --no-cache-dir --no-compile "pylint>=${VERSION},<$(echo "${VERSION}+0.1" | bc)"; \ | ||
fi \ | ||
&& find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \ | ||
&& find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf | ||
|
||
|
||
FROM alpine:3.9 as production | ||
LABEL \ | ||
maintainer="cytopia <[email protected]>" \ | ||
repo="https://github.com/cytopia/docker-pylint" | ||
RUN set -x \ | ||
&& apk add --no-cache python3 \ | ||
&& ln -sf /usr/bin/python3 /usr/bin/python \ | ||
&& find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \ | ||
&& find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf | ||
COPY --from=builder /usr/lib/python3.6/site-packages/ /usr/lib/python3.6/site-packages/ | ||
COPY --from=builder /usr/bin/pylint /usr/bin/pylint | ||
WORKDIR /data | ||
ENTRYPOINT ["pylint"] | ||
CMD ["--version"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 cytopia <https://github.com/cytopia> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
ifneq (,) | ||
.error This Makefile requires GNU Make. | ||
endif | ||
|
||
.PHONY: build rebuild lint test _test_version _test_run tag pull login push enter | ||
|
||
CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
|
||
DIR = . | ||
FILE = Dockerfile | ||
IMAGE = cytopia/pylint | ||
TAG = latest | ||
|
||
build: | ||
docker build --build-arg VERSION=$(TAG) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR) | ||
|
||
rebuild: pull | ||
docker build --no-cache --build-arg VERSION=$(TAG) -t $(IMAGE) -f $(DIR)/$(FILE) $(DIR) | ||
|
||
lint: | ||
@docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint file-cr --text --ignore '.git/,.github/,tests/' --path . | ||
@docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint file-crlf --text --ignore '.git/,.github/,tests/' --path . | ||
@docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint file-trailing-single-newline --text --ignore '.git/,.github/,tests/' --path . | ||
@docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint file-trailing-space --text --ignore '.git/,.github/,tests/' --path . | ||
@docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint file-utf8 --text --ignore '.git/,.github/,tests/' --path . | ||
@docker run --rm -v $(CURRENT_DIR):/data cytopia/file-lint file-utf8-bom --text --ignore '.git/,.github/,tests/' --path . | ||
|
||
test: | ||
@$(MAKE) --no-print-directory _test_version | ||
@$(MAKE) --no-print-directory _test_run | ||
|
||
_test_version: | ||
@echo "------------------------------------------------------------" | ||
@echo "- Testing correct version" | ||
@echo "------------------------------------------------------------" | ||
@if [ "$(TAG)" = "latest" ]; then \ | ||
echo "Fetching latest version from GitHub"; \ | ||
LATEST="$$( \ | ||
curl -L -sS https://github.com/PyCQA/pylint/releases/ \ | ||
| tac | tac \ | ||
| grep -Eo "PyCQA/pylint/releases/tag/(pylint-)?[.0-9]+" \ | ||
| head -1 \ | ||
| sed 's/.*tag\///g' \ | ||
| grep -Eo '[.0-9]+' \ | ||
)"; \ | ||
echo "Testing for latest: $${LATEST}"; \ | ||
if ! docker run --rm $(IMAGE) --version | grep -E "$${LATEST}$$"; then \ | ||
echo "Failed"; \ | ||
exit 1; \ | ||
fi; \ | ||
else \ | ||
echo "Testing for tag: $(TAG)"; \ | ||
if ! docker run --rm $(IMAGE) --version | grep -E "^$(TAG)"; then \ | ||
echo "Failed"; \ | ||
exit 1; \ | ||
fi; \ | ||
fi; \ | ||
echo "Success"; \ | ||
|
||
_test_run: | ||
@echo "------------------------------------------------------------" | ||
@echo "- Testing pep8 standard" | ||
@echo "------------------------------------------------------------" | ||
@if ! docker run --rm -v $(CURRENT_DIR)/tests:/data $(IMAGE) test.py ; then \ | ||
echo "Failed"; \ | ||
exit 1; \ | ||
fi; \ | ||
echo "Success"; | ||
|
||
tag: | ||
docker tag $(IMAGE) $(IMAGE):$(TAG) | ||
|
||
pull: | ||
@grep -E '^\s*FROM' Dockerfile \ | ||
| sed -e 's/^FROM//g' -e 's/[[:space:]]*as[[:space:]]*.*$$//g' \ | ||
| xargs -n1 docker pull; | ||
|
||
login: | ||
yes | docker login --username $(USER) --password $(PASS) | ||
|
||
push: | ||
@$(MAKE) tag TAG=$(TAG) | ||
docker push $(IMAGE):$(TAG) | ||
|
||
enter: | ||
docker run --rm --name $(subst /,-,$(IMAGE)) -it --entrypoint=/bin/sh $(ARG) $(IMAGE):$(TAG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
''' | ||
module docstring | ||
''' | ||
|
||
def main(): | ||
'''function docstring''' | ||
print("Hello, World!") | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |