├── .gitignore ├── Dockerfiles ├── Dockerfile.latest ├── Dockerfile.python3.6 ├── Dockerfile.python3.7 ├── Dockerfile.python3.8 ├── Dockerfile.python3.9 └── Dockerfile.python3.10 ├── .github ├── dependabot.yml ├── labels.yml ├── workflows │ ├── release-drafter.yml │ ├── repository.yml │ ├── lint.yml │ ├── github-docker-action.yml │ ├── action_pull_request.yml │ ├── action_schedule.yml │ ├── action_branch.yml │ └── params.yml └── release-drafter.yml ├── .yamllint ├── tests ├── failure.py └── success.py ├── action.yml ├── LICENSE ├── Makefile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile.docker 2 | Makefile.lint 3 | -------------------------------------------------------------------------------- /Dockerfiles/Dockerfile.latest: -------------------------------------------------------------------------------- 1 | Dockerfile.python3.10 -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2 3 | updates: 4 | # Maintain dependencies for GitHub Actions 5 | - package-ecosystem: "github-actions" 6 | directory: "/" 7 | schedule: 8 | interval: "daily" 9 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | 4 | ignore: | 5 | .yamllint 6 | 7 | 8 | rules: 9 | truthy: 10 | allowed-values: ['true', 'false'] 11 | check-keys: False 12 | level: error 13 | line-length: disable 14 | -------------------------------------------------------------------------------- /tests/failure.py: -------------------------------------------------------------------------------- 1 | def very_important_function(template: str, *variables, file: os.PathLike, engine: str, header: bool = True, debug: bool = False): 2 | """Applies `variables` to the `template` and writes to `file`.""" 3 | with open(file, 'w') as f: 4 | pass 5 | -------------------------------------------------------------------------------- /tests/success.py: -------------------------------------------------------------------------------- 1 | def very_important_function( 2 | template: str, 3 | *variables, 4 | file: os.PathLike, 5 | engine: str, 6 | header: bool = True, 7 | debug: bool = False 8 | ): 9 | """Applies `variables` to the `template` and writes to `file`.""" 10 | with open(file, "w") as f: 11 | pass 12 | -------------------------------------------------------------------------------- /.github/labels.yml: -------------------------------------------------------------------------------- 1 | # The labels in this file are automatically synced with the repository 2 | # using the micnncim/action-label-syncer action. 3 | --- 4 | - name: C-dependency 5 | color: 1abc9c 6 | description: "Category: Dependency" 7 | - name: PR-block 8 | color: 3498db 9 | description: "Pull Request: Do not merge" 10 | - name: PR-merge 11 | color: 3498db 12 | description: "Pull Request: Merge when ready" 13 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | # https://help.github.com/en/articles/metadata-syntax-for-github-actions 2 | 3 | name: 'Python Black' 4 | description: 'Runs Python Black' 5 | author: 'cytopia' 6 | branding: 7 | icon: 'code' 8 | color: 'black' 9 | 10 | inputs: 11 | path: 12 | description: 'Path to check (defaults to current directory)' 13 | required: false 14 | default: './' 15 | runs: 16 | using: 'docker' 17 | image: 'docker://cytopia/black' 18 | args: 19 | - '--check' 20 | - ${{ inputs.path }} 21 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Release Drafter 3 | 4 | on: 5 | push: 6 | # branches to consider in the event; optional, defaults to all 7 | branches: 8 | - master 9 | 10 | jobs: 11 | update_release_draft: 12 | runs-on: ubuntu-latest 13 | steps: 14 | # Drafts your next Release notes as Pull Requests are merged into "master" 15 | - uses: release-drafter/release-drafter@v5 16 | with: 17 | publish: true 18 | env: 19 | GITHUB_TOKEN: ${{ secrets.RELEASE_DRAFTER_TOKEN }} 20 | -------------------------------------------------------------------------------- /.github/workflows/repository.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Repository 3 | 4 | on: 5 | push: 6 | branches: 7 | - master 8 | paths: 9 | - .github/labels.yml 10 | 11 | jobs: 12 | labels: 13 | name: Labels 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checkout code 18 | uses: actions/checkout@v3 19 | 20 | - name: Sync labels 21 | uses: micnncim/action-label-syncer@v1 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | with: 25 | manifest: .github/labels.yml 26 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name-template: '$RESOLVED_VERSION 🌈' 3 | tag-template: '$RESOLVED_VERSION' 4 | version-template: '$MAJOR.$MINOR' 5 | categories: 6 | - title: '🚀 Features' 7 | labels: 8 | - 'feature' 9 | - 'enhancement' 10 | - title: '🐛 Bug Fixes' 11 | labels: 12 | - 'fix' 13 | - 'bugfix' 14 | - 'bug' 15 | - title: '🧰 Maintenance' 16 | label: 'chore' 17 | change-template: '- $TITLE @$AUTHOR (#$NUMBER)' 18 | change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. 19 | version-resolver: 20 | major: 21 | labels: 22 | - 'major' 23 | minor: 24 | labels: 25 | - 'minor' 26 | patch: 27 | labels: 28 | - 'patch' 29 | default: minor 30 | template: | 31 | ## Changes 32 | 33 | $CHANGES 34 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # ------------------------------------------------------------------------------------------------- 4 | # Job Name 5 | # ------------------------------------------------------------------------------------------------- 6 | name: lint 7 | 8 | 9 | # ------------------------------------------------------------------------------------------------- 10 | # When to run 11 | # ------------------------------------------------------------------------------------------------- 12 | on: 13 | # Runs on Pull Requests 14 | pull_request: 15 | 16 | 17 | # ------------------------------------------------------------------------------------------------- 18 | # What to run 19 | # ------------------------------------------------------------------------------------------------- 20 | jobs: 21 | lint: 22 | uses: devilbox/github-actions/.github/workflows/lint-generic.yml@master 23 | -------------------------------------------------------------------------------- /.github/workflows/github-docker-action.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # ------------------------------------------------------------------------------------------------- 3 | # Job Name 4 | # ------------------------------------------------------------------------------------------------- 5 | name: GitHub Docker Action 6 | 7 | 8 | # ------------------------------------------------------------------------------------------------- 9 | # When to run 10 | # ------------------------------------------------------------------------------------------------- 11 | on: 12 | push: 13 | 14 | jobs: 15 | github_docker_action: 16 | name: test 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@v3 21 | 22 | - name: test file (success) 23 | uses: ./ 24 | with: 25 | path: 'tests/success.py' 26 | 27 | - name: test file (failure) 28 | uses: ./ 29 | with: 30 | path: 'tests/failure.py' 31 | continue-on-error: true 32 | 33 | 34 | - name: test directory (failure) 35 | uses: ./ 36 | with: 37 | path: 'tests/' 38 | continue-on-error: true 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 cytopia 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/action_pull_request.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # ------------------------------------------------------------------------------------------------- 4 | # Job Name 5 | # ------------------------------------------------------------------------------------------------- 6 | name: build 7 | 8 | 9 | # ------------------------------------------------------------------------------------------------- 10 | # When to run 11 | # ------------------------------------------------------------------------------------------------- 12 | on: 13 | pull_request: 14 | 15 | 16 | jobs: 17 | 18 | # (1/2) Determine repository params 19 | params: 20 | uses: ./.github/workflows/params.yml 21 | # Only run for forks (contributor) 22 | if: github.event.pull_request.head.repo.fork 23 | 24 | # (2/2) Build 25 | docker: 26 | needs: [params] 27 | uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master 28 | with: 29 | enabled: true 30 | can_deploy: false 31 | matrix: ${{ needs.params.outputs.matrix }} 32 | refs: ${{ needs.params.outputs.refs }} 33 | secrets: 34 | dockerhub_username: "" 35 | dockerhub_password: "" 36 | -------------------------------------------------------------------------------- /.github/workflows/action_schedule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # ------------------------------------------------------------------------------------------------- 4 | # Job Name 5 | # ------------------------------------------------------------------------------------------------- 6 | name: nightly 7 | 8 | 9 | # ------------------------------------------------------------------------------------------------- 10 | # When to run 11 | # ------------------------------------------------------------------------------------------------- 12 | on: 13 | # Runs daily 14 | schedule: 15 | - cron: '0 0 * * *' 16 | 17 | 18 | jobs: 19 | 20 | # (1/2) Determine repository params 21 | params: 22 | uses: ./.github/workflows/params.yml 23 | 24 | # (2/2) Build 25 | docker: 26 | needs: [params] 27 | uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master 28 | with: 29 | enabled: true 30 | can_deploy: true 31 | matrix: ${{ needs.params.outputs.matrix }} 32 | refs: ${{ needs.params.outputs.refs }} 33 | secrets: 34 | dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} 35 | dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} 36 | -------------------------------------------------------------------------------- /.github/workflows/action_branch.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # ------------------------------------------------------------------------------------------------- 4 | # Job Name 5 | # ------------------------------------------------------------------------------------------------- 6 | name: build 7 | 8 | 9 | # ------------------------------------------------------------------------------------------------- 10 | # When to run 11 | # ------------------------------------------------------------------------------------------------- 12 | on: 13 | push: 14 | paths: 15 | - 'Makefile' 16 | - 'Dockerfiles/**' 17 | - 'tests/**' 18 | - '.github/workflows/action*.yml' 19 | - '.github/workflows/params.yml' 20 | 21 | jobs: 22 | 23 | # (1/2) Determine repository params 24 | params: 25 | uses: ./.github/workflows/params.yml 26 | 27 | # (2/2) Build 28 | docker: 29 | needs: [params] 30 | uses: devilbox/github-actions/.github/workflows/docker-name-version-flavour-arch.yml@master 31 | with: 32 | enabled: true 33 | can_deploy: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/release-') }} 34 | matrix: ${{ needs.params.outputs.matrix }} 35 | refs: ${{ needs.params.outputs.refs }} 36 | secrets: 37 | dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }} 38 | dockerhub_password: ${{ secrets.DOCKERHUB_PASSWORD }} 39 | -------------------------------------------------------------------------------- /Dockerfiles/Dockerfile.python3.6: -------------------------------------------------------------------------------- 1 | FROM alpine:3.9 as builder 2 | 3 | RUN set -eux \ 4 | && apk add --no-cache \ 5 | bc \ 6 | gcc \ 7 | musl-dev \ 8 | py3-pip \ 9 | python3 \ 10 | python3-dev 11 | 12 | ARG BLACK_VERSION 13 | RUN set -eux \ 14 | && if [ "${BLACK_VERSION}" = "latest" ]; then \ 15 | pip3 install --no-cache-dir --no-compile black[jupyter]; \ 16 | elif [ "${BLACK_VERSION}" -lt "22" ]; then \ 17 | pip3 install --no-cache-dir --no-compile "black[jupyter]~=${BLACK_VERSION}.0b"; \ 18 | else \ 19 | pip3 install --no-cache-dir --no-compile "black[jupyter]~=${BLACK_VERSION}.0"; \ 20 | fi 21 | 22 | RUN set -eux \ 23 | && python3 --version \ 24 | && black --version \ 25 | && black --version | grep -E '^black.+?(version\s)?[0-9]+\.[\.0-9]+' \ 26 | \ 27 | && find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \ 28 | && find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf 29 | 30 | 31 | FROM alpine:3.9 as production 32 | ARG BLACK_VERSION 33 | # https://github.com/opencontainers/image-spec/blob/master/annotations.md 34 | #LABEL "org.opencontainers.image.created"="" 35 | #LABEL "org.opencontainers.image.version"="" 36 | #LABEL "org.opencontainers.image.revision"="" 37 | LABEL "maintainer"="cytopia " 38 | LABEL "org.opencontainers.image.authors"="cytopia " 39 | LABEL "org.opencontainers.image.vendor"="cytopia" 40 | LABEL "org.opencontainers.image.licenses"="MIT" 41 | LABEL "org.opencontainers.image.url"="https://github.com/cytopia/docker-black" 42 | LABEL "org.opencontainers.image.documentation"="https://github.com/cytopia/docker-black" 43 | LABEL "org.opencontainers.image.source"="https://github.com/cytopia/docker-black" 44 | LABEL "org.opencontainers.image.ref.name"="black ${BLACK_VERSION}" 45 | LABEL "org.opencontainers.image.title"="black ${BLACK_VERSION}" 46 | LABEL "org.opencontainers.image.description"="black ${BLACK_VERSION}" 47 | 48 | RUN set -eux \ 49 | && apk add --no-cache \ 50 | python3 \ 51 | && ln -sf /usr/bin/python3 /usr/bin/python \ 52 | && find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \ 53 | && find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf 54 | 55 | COPY --from=builder /usr/lib/python3.6/site-packages/ /usr/lib/python3.6/site-packages/ 56 | COPY --from=builder /usr/bin/black /usr/bin/black 57 | WORKDIR /data 58 | ENTRYPOINT ["black"] 59 | -------------------------------------------------------------------------------- /Dockerfiles/Dockerfile.python3.7: -------------------------------------------------------------------------------- 1 | FROM alpine:3.10 as builder 2 | 3 | RUN set -eux \ 4 | && apk add --no-cache \ 5 | bc \ 6 | gcc \ 7 | musl-dev \ 8 | py3-pip \ 9 | python3 \ 10 | python3-dev 11 | 12 | ARG BLACK_VERSION 13 | RUN set -eux \ 14 | && if [ "${BLACK_VERSION}" = "latest" ]; then \ 15 | pip3 install --no-cache-dir --no-compile black[jupyter]; \ 16 | elif [ "${BLACK_VERSION}" -lt "22" ]; then \ 17 | pip3 install --no-cache-dir --no-compile "black[jupyter]~=${BLACK_VERSION}.0b"; \ 18 | else \ 19 | pip3 install --no-cache-dir --no-compile "black[jupyter]~=${BLACK_VERSION}.0"; \ 20 | fi 21 | 22 | RUN set -eux \ 23 | && python3 --version \ 24 | && black --version \ 25 | && black --version | grep -E '^black.+?(version\s)?[0-9]+\.[\.0-9]+' \ 26 | \ 27 | && find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \ 28 | && find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf 29 | 30 | 31 | FROM alpine:3.10 as production 32 | ARG BLACK_VERSION 33 | # https://github.com/opencontainers/image-spec/blob/master/annotations.md 34 | #LABEL "org.opencontainers.image.created"="" 35 | #LABEL "org.opencontainers.image.version"="" 36 | #LABEL "org.opencontainers.image.revision"="" 37 | LABEL "maintainer"="cytopia " 38 | LABEL "org.opencontainers.image.authors"="cytopia " 39 | LABEL "org.opencontainers.image.vendor"="cytopia" 40 | LABEL "org.opencontainers.image.licenses"="MIT" 41 | LABEL "org.opencontainers.image.url"="https://github.com/cytopia/docker-black" 42 | LABEL "org.opencontainers.image.documentation"="https://github.com/cytopia/docker-black" 43 | LABEL "org.opencontainers.image.source"="https://github.com/cytopia/docker-black" 44 | LABEL "org.opencontainers.image.ref.name"="black ${BLACK_VERSION}" 45 | LABEL "org.opencontainers.image.title"="black ${BLACK_VERSION}" 46 | LABEL "org.opencontainers.image.description"="black ${BLACK_VERSION}" 47 | 48 | RUN set -eux \ 49 | && apk add --no-cache \ 50 | python3 \ 51 | && ln -sf /usr/bin/python3 /usr/bin/python \ 52 | && find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \ 53 | && find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf 54 | 55 | COPY --from=builder /usr/lib/python3.7/site-packages/ /usr/lib/python3.7/site-packages/ 56 | COPY --from=builder /usr/bin/black /usr/bin/black 57 | WORKDIR /data 58 | ENTRYPOINT ["black"] 59 | -------------------------------------------------------------------------------- /Dockerfiles/Dockerfile.python3.8: -------------------------------------------------------------------------------- 1 | FROM alpine:3.13 as builder 2 | 3 | RUN set -eux \ 4 | && apk add --no-cache \ 5 | bc \ 6 | gcc \ 7 | musl-dev \ 8 | py3-pip \ 9 | python3 \ 10 | python3-dev 11 | 12 | ARG BLACK_VERSION 13 | RUN set -eux \ 14 | && if [ "${BLACK_VERSION}" = "latest" ]; then \ 15 | pip3 install --no-cache-dir --no-compile black[jupyter]; \ 16 | elif [ "${BLACK_VERSION}" -lt "22" ]; then \ 17 | pip3 install --no-cache-dir --no-compile "black[jupyter]~=${BLACK_VERSION}.0b"; \ 18 | else \ 19 | pip3 install --no-cache-dir --no-compile "black[jupyter]~=${BLACK_VERSION}.0"; \ 20 | fi 21 | 22 | RUN set -eux \ 23 | && python3 --version \ 24 | && black --version \ 25 | && black --version | grep -E '^black.+?(version\s)?[0-9]+\.[\.0-9]+' \ 26 | \ 27 | && find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \ 28 | && find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf 29 | 30 | 31 | FROM alpine:3.13 as production 32 | ARG BLACK_VERSION 33 | # https://github.com/opencontainers/image-spec/blob/master/annotations.md 34 | #LABEL "org.opencontainers.image.created"="" 35 | #LABEL "org.opencontainers.image.version"="" 36 | #LABEL "org.opencontainers.image.revision"="" 37 | LABEL "maintainer"="cytopia " 38 | LABEL "org.opencontainers.image.authors"="cytopia " 39 | LABEL "org.opencontainers.image.vendor"="cytopia" 40 | LABEL "org.opencontainers.image.licenses"="MIT" 41 | LABEL "org.opencontainers.image.url"="https://github.com/cytopia/docker-black" 42 | LABEL "org.opencontainers.image.documentation"="https://github.com/cytopia/docker-black" 43 | LABEL "org.opencontainers.image.source"="https://github.com/cytopia/docker-black" 44 | LABEL "org.opencontainers.image.ref.name"="black ${BLACK_VERSION}" 45 | LABEL "org.opencontainers.image.title"="black ${BLACK_VERSION}" 46 | LABEL "org.opencontainers.image.description"="black ${BLACK_VERSION}" 47 | 48 | RUN set -eux \ 49 | && apk add --no-cache \ 50 | python3 \ 51 | && ln -sf /usr/bin/python3 /usr/bin/python \ 52 | && find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \ 53 | && find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf 54 | 55 | COPY --from=builder /usr/lib/python3.8/site-packages/ /usr/lib/python3.8/site-packages/ 56 | COPY --from=builder /usr/bin/black /usr/bin/black 57 | WORKDIR /data 58 | ENTRYPOINT ["black"] 59 | -------------------------------------------------------------------------------- /Dockerfiles/Dockerfile.python3.9: -------------------------------------------------------------------------------- 1 | FROM alpine:3.15 as builder 2 | 3 | RUN set -eux \ 4 | && apk add --no-cache \ 5 | bc \ 6 | gcc \ 7 | musl-dev \ 8 | py3-pip \ 9 | python3 \ 10 | python3-dev 11 | 12 | ARG BLACK_VERSION 13 | RUN set -eux \ 14 | && if [ "${BLACK_VERSION}" = "latest" ]; then \ 15 | pip3 install --no-cache-dir --no-compile black[jupyter]; \ 16 | elif [ "${BLACK_VERSION}" -lt "22" ]; then \ 17 | pip3 install --no-cache-dir --no-compile "black[jupyter]~=${BLACK_VERSION}.0b"; \ 18 | else \ 19 | pip3 install --no-cache-dir --no-compile "black[jupyter]~=${BLACK_VERSION}.0"; \ 20 | fi 21 | 22 | RUN set -eux \ 23 | && python3 --version \ 24 | && black --version \ 25 | && black --version | grep -E '^black.+?(version\s)?[0-9]+\.[\.0-9]+' \ 26 | \ 27 | && find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \ 28 | && find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf 29 | 30 | 31 | FROM alpine:3.15 as production 32 | ARG BLACK_VERSION 33 | # https://github.com/opencontainers/image-spec/blob/master/annotations.md 34 | #LABEL "org.opencontainers.image.created"="" 35 | #LABEL "org.opencontainers.image.version"="" 36 | #LABEL "org.opencontainers.image.revision"="" 37 | LABEL "maintainer"="cytopia " 38 | LABEL "org.opencontainers.image.authors"="cytopia " 39 | LABEL "org.opencontainers.image.vendor"="cytopia" 40 | LABEL "org.opencontainers.image.licenses"="MIT" 41 | LABEL "org.opencontainers.image.url"="https://github.com/cytopia/docker-black" 42 | LABEL "org.opencontainers.image.documentation"="https://github.com/cytopia/docker-black" 43 | LABEL "org.opencontainers.image.source"="https://github.com/cytopia/docker-black" 44 | LABEL "org.opencontainers.image.ref.name"="black ${BLACK_VERSION}" 45 | LABEL "org.opencontainers.image.title"="black ${BLACK_VERSION}" 46 | LABEL "org.opencontainers.image.description"="black ${BLACK_VERSION}" 47 | 48 | RUN set -eux \ 49 | && apk add --no-cache \ 50 | python3 \ 51 | && ln -sf /usr/bin/python3 /usr/bin/python \ 52 | && find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \ 53 | && find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf 54 | 55 | COPY --from=builder /usr/lib/python3.9/site-packages/ /usr/lib/python3.9/site-packages/ 56 | COPY --from=builder /usr/bin/black /usr/bin/black 57 | WORKDIR /data 58 | ENTRYPOINT ["black"] 59 | -------------------------------------------------------------------------------- /Dockerfiles/Dockerfile.python3.10: -------------------------------------------------------------------------------- 1 | FROM alpine:3.16 as builder 2 | 3 | RUN set -eux \ 4 | && apk add --no-cache \ 5 | bc \ 6 | gcc \ 7 | musl-dev \ 8 | py3-pip \ 9 | python3 \ 10 | python3-dev 11 | 12 | ARG BLACK_VERSION 13 | RUN set -eux \ 14 | && if [ "${BLACK_VERSION}" = "latest" ]; then \ 15 | pip3 install --no-cache-dir --no-compile black[jupyter]; \ 16 | elif [ "${BLACK_VERSION}" -lt "22" ]; then \ 17 | pip3 install --no-cache-dir --no-compile "black[jupyter]~=${BLACK_VERSION}.0b"; \ 18 | else \ 19 | pip3 install --no-cache-dir --no-compile "black[jupyter]~=${BLACK_VERSION}.0"; \ 20 | fi 21 | 22 | RUN set -eux \ 23 | && python3 --version \ 24 | && black --version \ 25 | && black --version | grep -E '^black.+?(version\s)?[0-9]+\.[\.0-9]+' \ 26 | \ 27 | && find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \ 28 | && find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf 29 | 30 | 31 | FROM alpine:3.16 as production 32 | ARG BLACK_VERSION 33 | # https://github.com/opencontainers/image-spec/blob/master/annotations.md 34 | #LABEL "org.opencontainers.image.created"="" 35 | #LABEL "org.opencontainers.image.version"="" 36 | #LABEL "org.opencontainers.image.revision"="" 37 | LABEL "maintainer"="cytopia " 38 | LABEL "org.opencontainers.image.authors"="cytopia " 39 | LABEL "org.opencontainers.image.vendor"="cytopia" 40 | LABEL "org.opencontainers.image.licenses"="MIT" 41 | LABEL "org.opencontainers.image.url"="https://github.com/cytopia/docker-black" 42 | LABEL "org.opencontainers.image.documentation"="https://github.com/cytopia/docker-black" 43 | LABEL "org.opencontainers.image.source"="https://github.com/cytopia/docker-black" 44 | LABEL "org.opencontainers.image.ref.name"="black ${BLACK_VERSION}" 45 | LABEL "org.opencontainers.image.title"="black ${BLACK_VERSION}" 46 | LABEL "org.opencontainers.image.description"="black ${BLACK_VERSION}" 47 | 48 | RUN set -eux \ 49 | && apk add --no-cache \ 50 | python3 \ 51 | && ln -sf /usr/bin/python3 /usr/bin/python \ 52 | && find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \ 53 | && find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf 54 | 55 | COPY --from=builder /usr/lib/python3.10/site-packages/ /usr/lib/python3.10/site-packages/ 56 | COPY --from=builder /usr/bin/black /usr/bin/black 57 | WORKDIR /data 58 | ENTRYPOINT ["black"] 59 | -------------------------------------------------------------------------------- /.github/workflows/params.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # ------------------------------------------------------------------------------------------------- 4 | # Job Name 5 | # ------------------------------------------------------------------------------------------------- 6 | name: params 7 | 8 | 9 | # ------------------------------------------------------------------------------------------------- 10 | # Custom Variables 11 | # ------------------------------------------------------------------------------------------------- 12 | env: 13 | MATRIX: >- 14 | [ 15 | { 16 | "NAME": "black", 17 | "VERSION": [ 18 | "latest", 19 | 20 | "BLACK-latest PYTHON-latest", 21 | "BLACK-latest PYTHON-3.10", 22 | "BLACK-latest PYTHON-3.9", 23 | "BLACK-latest PYTHON-3.8", 24 | "BLACK-latest PYTHON-3.7", 25 | "BLACK-latest PYTHON-3.6", 26 | 27 | "BLACK-22 PYTHON-latest", 28 | "BLACK-22 PYTHON-3.10", 29 | "BLACK-22 PYTHON-3.9", 30 | "BLACK-22 PYTHON-3.8", 31 | "BLACK-22 PYTHON-3.7", 32 | "BLACK-22 PYTHON-3.6" 33 | ], 34 | "FLAVOUR": ["latest"], 35 | "ARCH": ["linux/amd64", "linux/386", "linux/arm64", "linux/arm/v7", "linux/arm/v6", "linux/ppc64le", "linux/s390x"] 36 | } 37 | ] 38 | 39 | 40 | # ------------------------------------------------------------------------------------------------- 41 | # When to run 42 | # ------------------------------------------------------------------------------------------------- 43 | on: 44 | workflow_call: 45 | outputs: 46 | matrix: 47 | description: "The determined version matrix" 48 | value: ${{ jobs.params.outputs.matrix }} 49 | refs: 50 | description: "The determined git ref matrix (only during scheduled run)" 51 | value: ${{ jobs.params.outputs.refs }} 52 | 53 | jobs: 54 | params: 55 | runs-on: ubuntu-latest 56 | 57 | outputs: 58 | matrix: ${{ steps.set-matrix.outputs.matrix }} 59 | refs: ${{ steps.set-refs.outputs.matrix }} 60 | 61 | steps: 62 | - name: "[Set-Output] Matrix" 63 | id: set-matrix 64 | run: | 65 | echo "matrix=$( echo '${{ env.MATRIX }}' | jq -M -c )" >> $GITHUB_OUTPUT 66 | 67 | - name: "[Set-Output] Matrix 'Refs' (master branch and latest tag)" 68 | id: set-refs 69 | uses: cytopia/git-ref-matrix-action@v0.1.13 70 | with: 71 | repository_default_branch: master 72 | branches: master 73 | num_latest_tags: 0 74 | if: github.event_name == 'schedule' 75 | 76 | - name: "[DEBUG] Show settings'" 77 | run: | 78 | echo 'Matrix' 79 | echo '--------------------' 80 | echo '${{ steps.set-matrix.outputs.matrix }}' 81 | echo 82 | 83 | echo 'Matrix: Refs' 84 | echo '--------------------' 85 | echo '${{ steps.set-matrix-refs.outputs.matrix }}' 86 | echo 87 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ifneq (,) 2 | .error This Makefile requires GNU Make. 3 | endif 4 | 5 | # Ensure additional Makefiles are present 6 | MAKEFILES = Makefile.docker Makefile.lint 7 | $(MAKEFILES): URL=https://raw.githubusercontent.com/devilbox/makefiles/master/$(@) 8 | $(MAKEFILES): 9 | @if ! (curl --fail -sS -o $(@) $(URL) || wget -O $(@) $(URL)); then \ 10 | echo "Error, curl or wget required."; \ 11 | echo "Exiting."; \ 12 | false; \ 13 | fi 14 | include $(MAKEFILES) 15 | 16 | # Set default Target 17 | .DEFAULT_GOAL := help 18 | 19 | 20 | # ------------------------------------------------------------------------------------------------- 21 | # Default configuration 22 | # ------------------------------------------------------------------------------------------------- 23 | # Own vars 24 | TAG = latest 25 | 26 | # Makefile.docker overwrites 27 | NAME = black 28 | VERSION = latest 29 | IMAGE = cytopia/black 30 | FLAVOUR = latest 31 | DIR = Dockerfiles 32 | 33 | # Extract PHP- and PCS- version from VERSION string 34 | ifeq ($(strip $(VERSION)),latest) 35 | PYTHON_VERSION = latest 36 | BLACK_VERSION = latest 37 | else 38 | PYTHON_VERSION = $(subst PYTHON-,,$(shell echo "$(VERSION)" | grep -Eo 'PYTHON-([.0-9]+|latest)')) 39 | BLACK_VERSION = $(subst BLACK-,,$(shell echo "$(VERSION)" | grep -Eo 'BLACK-([.0-9]+|latest)')) 40 | endif 41 | 42 | FILE = Dockerfile.${PYTHON_VERSION} 43 | ifneq ($(strip $(PYTHON_VERSION)),latest) 44 | FILE = Dockerfile.python${PYTHON_VERSION} 45 | endif 46 | 47 | 48 | # Building from master branch: Tag == 'latest' 49 | ifeq ($(strip $(TAG)),latest) 50 | ifeq ($(strip $(VERSION)),latest) 51 | DOCKER_TAG = $(FLAVOUR) 52 | else 53 | ifeq ($(strip $(FLAVOUR)),latest) 54 | ifeq ($(strip $(PYTHON_VERSION)),latest) 55 | DOCKER_TAG = $(BLACK_VERSION) 56 | else 57 | DOCKER_TAG = $(BLACK_VERSION)-py$(PYTHON_VERSION) 58 | endif 59 | else 60 | ifeq ($(strip $(PYTHON_VERSION)),latest) 61 | DOCKER_TAG = $(FLAVOUR)-$(BLACK_VERSION) 62 | else 63 | DOCKER_TAG = $(FLAVOUR)-$(BLACK_VERSION)-py$(PYTHON_VERSION) 64 | endif 65 | endif 66 | endif 67 | # Building from any other branch or tag: Tag == '' 68 | else 69 | ifeq ($(strip $(VERSION)),latest) 70 | ifeq ($(strip $(FLAVOUR)),latest) 71 | DOCKER_TAG = latest-$(TAG) 72 | else 73 | DOCKER_TAG = $(FLAVOUR)-latest-$(TAG) 74 | endif 75 | else 76 | ifeq ($(strip $(FLAVOUR)),latest) 77 | ifeq ($(strip $(PYTHON_VERSION)),latest) 78 | DOCKER_TAG = $(BLACK_VERSION)-$(TAG) 79 | else 80 | DOCKER_TAG = $(BLACK_VERSION)-py$(PYTHON_VERSION)-$(TAG) 81 | endif 82 | else 83 | ifeq ($(strip $(PYTHON_VERSION)),latest) 84 | DOCKER_TAG = $(FLAVOUR)-$(BLACK_VERSION)-$(TAG) 85 | else 86 | DOCKER_TAG = $(FLAVOUR)-$(BLACK_VERSION)-py$(PYTHON_VERSION)-$(TAG) 87 | endif 88 | endif 89 | endif 90 | endif 91 | 92 | # Makefile.lint overwrites 93 | FL_IGNORES = .git/,.github/ 94 | SC_IGNORES = .git/,.github/ 95 | JL_IGNORES = .git/,.github/ 96 | 97 | 98 | # ------------------------------------------------------------------------------------------------- 99 | # Default Target 100 | # ------------------------------------------------------------------------------------------------- 101 | .PHONY: help 102 | help: 103 | @echo "lint Lint project files and repository" 104 | @echo 105 | @echo "build [ARCH=...] [TAG=...] Build Docker image" 106 | @echo "rebuild [ARCH=...] [TAG=...] Build Docker image without cache" 107 | @echo "push [ARCH=...] [TAG=...] Push Docker image to Docker hub" 108 | @echo 109 | @echo "manifest-create [ARCHES=...] [TAG=...] Create multi-arch manifest" 110 | @echo "manifest-push [TAG=...] Push multi-arch manifest" 111 | @echo 112 | @echo "test [ARCH=...] Test built Docker image" 113 | @echo 114 | 115 | 116 | # ------------------------------------------------------------------------------------------------- 117 | # Docker Targets 118 | # ------------------------------------------------------------------------------------------------- 119 | .PHONY: build 120 | build: ARGS+=--build-arg BLACK_VERSION=$(BLACK_VERSION) 121 | build: docker-arch-build 122 | 123 | .PHONY: rebuild 124 | rebuild: ARGS+=--build-arg BLACK_VERSION=$(BLACK_VERSION) 125 | rebuild: docker-arch-rebuild 126 | 127 | .PHONY: push 128 | push: docker-arch-push 129 | 130 | 131 | # ------------------------------------------------------------------------------------------------- 132 | # Manifest Targets 133 | # ------------------------------------------------------------------------------------------------- 134 | .PHONY: manifest-create 135 | manifest-create: docker-manifest-create 136 | 137 | .PHONY: manifest-push 138 | manifest-push: docker-manifest-push 139 | 140 | 141 | # ------------------------------------------------------------------------------------------------- 142 | # Test Targets 143 | # ------------------------------------------------------------------------------------------------- 144 | .PHONY: test 145 | test: _test-black-version 146 | test: _test-python-version 147 | test: _test-run 148 | 149 | .PHONY: _test-black-version 150 | _test-black-version: 151 | @echo "------------------------------------------------------------" 152 | @echo "- Testing correct Black version" 153 | @echo "------------------------------------------------------------" 154 | @if [ "$(BLACK_VERSION)" = "latest" ]; then \ 155 | echo "Fetching latest version from GitHub"; \ 156 | LATEST="$$( \ 157 | curl -L -sS https://github.com/python/black/releases/ \ 158 | | tac | tac \ 159 | | grep -Eo '/black/releases/tag/v?[.0-9]+"' \ 160 | | grep -Eo 'v?[.0-9]+' \ 161 | | head -1 \ 162 | | sed 's/.*v//g' \ 163 | | sed 's/.*\///g' \ 164 | )"; \ 165 | if [ "$(PYTHON_VERSION)" = "3.6" ]; then \ 166 | LATEST="22.8.0"; \ 167 | fi; \ 168 | echo "Testing for latest: $${LATEST}"; \ 169 | if ! docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) --version | grep -E "^black.+?(version\s)?$${LATEST}"; then \ 170 | docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) --version; \ 171 | echo "Failed"; \ 172 | exit 1; \ 173 | fi; \ 174 | else \ 175 | echo "Testing for tag: $(BLACK_VERSION)"; \ 176 | if ! docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) --version | grep -E "^black.+?(version\s)?$(BLACK_VERSION)"; then \ 177 | docker run --rm --platform $(ARCH) $(IMAGE):$(DOCKER_TAG) --version; \ 178 | echo "Failed"; \ 179 | exit 1; \ 180 | fi; \ 181 | fi; \ 182 | echo "Success"; \ 183 | 184 | .PHONY: _test-python-version 185 | _test-python-version: 186 | @echo "------------------------------------------------------------" 187 | @echo "- Testing correct Python version" 188 | @echo "------------------------------------------------------------" 189 | @if [ "$(PYTHON_VERSION)" = "latest" ]; then \ 190 | if ! docker run --rm --platform $(ARCH) --entrypoint=python $(IMAGE):$(DOCKER_TAG) --version | grep -E '^Python [.0-9]+'; then \ 191 | echo "Failed"; \ 192 | exit 1; \ 193 | fi; \ 194 | else \ 195 | echo "Testing for tag: $(PYTHON_VERSION)"; \ 196 | if ! docker run --rm --platform $(ARCH) --entrypoint=python $(IMAGE):$(DOCKER_TAG) --version | grep -E "^Python $(PYTHON_VERSION)"; then \ 197 | echo "Failed"; \ 198 | exit 1; \ 199 | fi; \ 200 | fi; \ 201 | echo "Success"; \ 202 | 203 | _test-run: 204 | @echo "------------------------------------------------------------" 205 | @echo "- Testing python black (Failure)" 206 | @echo "------------------------------------------------------------" 207 | @if docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests:/data $(IMAGE):$(DOCKER_TAG) --check --diff failure.py ; then \ 208 | echo "Failed"; \ 209 | exit 1; \ 210 | else \ 211 | echo "OK"; \ 212 | fi; 213 | @echo "------------------------------------------------------------" 214 | @echo "- Testing python black (Success)" 215 | @echo "------------------------------------------------------------" 216 | @if ! docker run --rm --platform $(ARCH) -v $(CURRENT_DIR)/tests:/data $(IMAGE):$(DOCKER_TAG) --check --diff success.py ; then \ 217 | echo "Failed"; \ 218 | exit 1; \ 219 | else \ 220 | echo "OK"; \ 221 | fi; 222 | @echo "Success"; 223 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker image for `black` 2 | 3 | [![Tag](https://img.shields.io/github/tag/cytopia/docker-black.svg)](https://github.com/cytopia/docker-black/releases) 4 | [![](https://img.shields.io/badge/github-cytopia%2Fdocker--black-red.svg)](https://github.com/cytopia/docker-black "github.com/cytopia/docker-black") 5 | [![](https://img.shields.io/docker/pulls/cytopia/black.svg)](https://hub.docker.com/r/cytopia/black) 6 | [![Docker](https://badgen.net/badge/icon/:latest?icon=docker&label=cytopia/black)](https://hub.docker.com/r/cytopia/black) 7 | [![License](https://img.shields.io/badge/license-MIT-%233DA639.svg)](https://opensource.org/licenses/MIT) 8 | 9 | [![lint](https://github.com/cytopia/docker-black/workflows/lint/badge.svg)](https://github.com/cytopia/docker-black/actions?query=workflow%3Alint) 10 | [![build](https://github.com/cytopia/docker-black/workflows/build/badge.svg)](https://github.com/cytopia/docker-black/actions?query=workflow%3Abuild) 11 | [![nightly](https://github.com/cytopia/docker-black/workflows/nightly/badge.svg)](https://github.com/cytopia/docker-black/actions?query=workflow%3Anightly) 12 | 13 | 14 | > #### All [#awesome-ci](https://github.com/topics/awesome-ci) Docker images 15 | > 16 | > [ansible-lint][alint-git-lnk] **•** 17 | > [ansible][ansible-git-lnk] **•** 18 | > [awesome-ci][aci-git-lnk] **•** 19 | > [bandit][bandit-git-lnk] **•** 20 | > [black][black-git-lnk] **•** 21 | > [checkmake][cm-git-lnk] **•** 22 | > [eslint][elint-git-lnk] **•** 23 | > [file-lint][flint-git-lnk] **•** 24 | > [gofmt][gfmt-git-lnk] **•** 25 | > [goimports][gimp-git-lnk] **•** 26 | > [golint][glint-git-lnk] **•** 27 | > [jsonlint][jlint-git-lnk] **•** 28 | > [kubeval][kubeval-git-lnk] **•** 29 | > [linkcheck][linkcheck-git-lnk] **•** 30 | > [mypy][mypy-git-lnk] **•** 31 | > [php-cs-fixer][pcsf-git-lnk] **•** 32 | > [phpcbf][pcbf-git-lnk] **•** 33 | > [phpcs][pcs-git-lnk] **•** 34 | > [phplint][plint-git-lnk] **•** 35 | > [pycodestyle][pycs-git-lnk] **•** 36 | > [pydocstyle][pyds-git-lnk] **•** 37 | > [pylint][pylint-git-lnk] **•** 38 | > [terraform-docs][tfdocs-git-lnk] **•** 39 | > [terragrunt-fmt][tgfmt-git-lnk] **•** 40 | > [terragrunt][tg-git-lnk] **•** 41 | > [yamlfmt][yfmt-git-lnk] **•** 42 | > [yamllint][ylint-git-lnk] 43 | 44 | View **[Dockerfiles](https://github.com/cytopia/docker-black/blob/master/Dockerfiles/)** on GitHub. 45 | 46 | 47 | **Available Architectures:** `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6`, `ppc64le`, `s390x` 48 | 49 | Tiny Alpine-based multistage-build dockerized version of [Black](https://github.com/python/black)[1]. 50 | The image is built nightly against multiple stable versions and pushed to Dockerhub. 51 | 52 | [1] Official project: https://github.com/python/black 53 | 54 | ## :octocat: GitHub Action 55 | 56 | **Runs on:** 57 | 58 | To add this to GitHub Actions, add the following snippet into your `.github/workflows/` directory: 59 | 60 | `.github/workflows/lint.yml` 61 | ```yml 62 | on: [push, pull_request] 63 | 64 | jobs: 65 | python-black: 66 | name: Python Black 67 | runs-on: ubuntu-latest 68 | steps: 69 | - uses: actions/checkout@v3 70 | - name: Python Black 71 | uses: cytopia/docker-black@0.8 72 | with: 73 | path: 'src/' 74 | ``` 75 | 76 | 77 | ## :whale: Available Docker image versions 78 | 79 | [![](https://img.shields.io/docker/pulls/cytopia/black.svg)](https://hub.docker.com/r/cytopia/black) 80 | [![Docker](https://badgen.net/badge/icon/:latest?icon=docker&label=cytopia/black)](https://hub.docker.com/r/cytopia/black) 81 | 82 | #### Rolling releaess 83 | 84 | The following Docker image tags are rolling releases and are built and updated every night. 85 | 86 | [![nightly](https://github.com/cytopia/docker-black/workflows/nightly/badge.svg)](https://github.com/cytopia/docker-black/actions?query=workflow%3Anightly) 87 | 88 | 89 | | Docker Tag | Git Ref | Black | Python | Available Architectures | 90 | |-----------------------|--------------|--------------|-------------|----------------------------------------------| 91 | | **`latest`** | master | latest | latest | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 92 | | `latest-py3.10` | master | latest | **`3.10`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 93 | | `latest-py3.9` | master | latest | **`3.9`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 94 | | `latest-py3.8` | master | latest | **`3.8`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 95 | | `latest-py3.7` | master | latest | **`3.7`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 96 | | `latest-py3.6` | master | latest | **`3.6`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 97 | | | | | | | 98 | | **`22`** | master | **`22.x.x`** | latest | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 99 | | `22-py3.10` | master | **`22.x.x`** | **`3.10`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 100 | | `22-py3.9` | master | **`22.x.x`** | **`3.9`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 101 | | `22-py3.8` | master | **`22.x.x`** | **`3.8`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 102 | | `22-py3.7` | master | **`22.x.x`** | **`3.7`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 103 | | `22-py3.6` | master | **`22.x.x`** | **`3.6`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 104 | 105 | 106 | #### Point in time releases 107 | 108 | The following Docker image tags are built once and can be used for reproducible builds. Its version never changes so you will have to update tags in your pipelines from time to time in order to stay up-to-date. 109 | 110 | [![build](https://github.com/cytopia/docker-black/workflows/build/badge.svg)](https://github.com/cytopia/docker-black/actions?query=workflow%3Abuild) 111 | 112 | | Docker Tag | Git Ref | Black | Python | Available Architectures | 113 | |-----------------------|--------------|--------------|-------------|----------------------------------------------| 114 | | **`latest-`** | git: `` | latest | latest | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 115 | | `latest-py3.10-` | git: `` | latest | **`3.10`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 116 | | `latest-py3.9-` | git: `` | latest | **`3.9`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 117 | | `latest-py3.8-` | git: `` | latest | **`3.8`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 118 | | `latest-py3.7-` | git: `` | latest | **`3.7`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 119 | | `latest-py3.6-` | git: `` | latest | **`3.6`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 120 | | | | | | | 121 | | **`22-`** | git: `` | **`22.x.x`** | latest | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 122 | | `22-py3.10-` | git: `` | **`22.x.x`** | **`3.10`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 123 | | `22-py3.9-` | git: `` | **`22.x.x`** | **`3.9`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 124 | | `22-py3.8-` | git: `` | **`22.x.x`** | **`3.8`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 125 | | `22-py3.7-` | git: `` | **`22.x.x`** | **`3.7`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 126 | | `22-py3.6-` | git: `` | **`22.x.x`** | **`3.6`** | `amd64`, `i386`, `arm64`, `arm/v7`, `arm/v6` | 127 | 128 | > Where `` refers to the chosen git tag from this repository. 129 | 130 | 131 | ## :open_file_folder: Docker mounts 132 | 133 | The working directory inside the Docker container is **`/data/`** and should be mounted locally. 134 | 135 | 136 | ## :computer: Usage 137 | 138 | ### Command line 139 | 140 | ```bash 141 | # Linux, Mac, Windows (Powershell) 142 | docker run --rm -v $(pwd):/data cytopia/black main.py 143 | 144 | # Windows (cmd) 145 | docker run --rm -v %cd%:/data cytopia/black main.py 146 | ``` 147 | 148 | ### GitLab CI 149 | 150 | ```yaml 151 | stages: 152 | - format 153 | 154 | format-black: 155 | stage: format 156 | image: 157 | name: cytopia/black 158 | entrypoint: ["/bin/ash", "-c"] 159 | script: 160 | - python3 -m black --check --diff my_source_files/ 161 | ``` 162 | 163 | 164 | ## :arrows_counterclockwise: Related [#awesome-ci](https://github.com/topics/awesome-ci) projects 165 | 166 | ### Docker images 167 | 168 | Save yourself from installing lot's of dependencies and pick a dockerized version of your favourite 169 | linter below for reproducible local or remote CI tests: 170 | 171 | | GitHub | DockerHub | Type | Description | 172 | |--------|-----------|------|-------------| 173 | | [awesome-ci][aci-git-lnk] | [![aci-hub-img]][aci-hub-lnk] | Basic | Tools for git, file and static source code analysis | 174 | | [file-lint][flint-git-lnk] | [![flint-hub-img]][flint-hub-lnk] | Basic | Baisc source code analysis | 175 | | [linkcheck][linkcheck-git-lnk] | [![linkcheck-hub-img]][flint-hub-lnk] | Basic | Search for URLs in files and validate their HTTP status code | 176 | | [ansible][ansible-git-lnk] | [![ansible-hub-img]][ansible-hub-lnk] | Ansible | Multiple versions and flavours of Ansible | 177 | | [ansible-lint][alint-git-lnk] | [![alint-hub-img]][alint-hub-lnk] | Ansible | Lint Ansible | 178 | | [gofmt][gfmt-git-lnk] | [![gfmt-hub-img]][gfmt-hub-lnk] | Go | Format Go source code **[1]** | 179 | | [goimports][gimp-git-lnk] | [![gimp-hub-img]][gimp-hub-lnk] | Go | Format Go source code **[1]** | 180 | | [golint][glint-git-lnk] | [![glint-hub-img]][glint-hub-lnk] | Go | Lint Go code | 181 | | [eslint][elint-git-lnk] | [![elint-hub-img]][elint-hub-lnk] | Javascript | Lint Javascript code | 182 | | [jsonlint][jlint-git-lnk] | [![jlint-hub-img]][jlint-hub-lnk] | JSON | Lint JSON files **[1]** | 183 | | [kubeval][kubeval-git-lnk] | [![kubeval-hub-img]][kubeval-hub-lnk] | K8s | Lint Kubernetes files | 184 | | [checkmake][cm-git-lnk] | [![cm-hub-img]][cm-hub-lnk] | Make | Lint Makefiles | 185 | | [phpcbf][pcbf-git-lnk] | [![pcbf-hub-img]][pcbf-hub-lnk] | PHP | PHP Code Beautifier and Fixer | 186 | | [phpcs][pcs-git-lnk] | [![pcs-hub-img]][pcs-hub-lnk] | PHP | PHP Code Sniffer | 187 | | [phplint][plint-git-lnk] | [![plint-hub-img]][plint-hub-lnk] | PHP | PHP Code Linter **[1]** | 188 | | [php-cs-fixer][pcsf-git-lnk] | [![pcsf-hub-img]][pcsf-hub-lnk] | PHP | PHP Coding Standards Fixer | 189 | | [bandit][bandit-git-lnk] | [![bandit-hub-img]][bandit-hub-lnk] | Python | A security linter from PyCQA 190 | | [black][black-git-lnk] | [![black-hub-img]][black-hub-lnk] | Python | The uncompromising Python code formatter | 191 | | [mypy][mypy-git-lnk] | [![mypy-hub-img]][mypy-hub-lnk] | Python | Static source code analysis | 192 | | [pycodestyle][pycs-git-lnk] | [![pycs-hub-img]][pycs-hub-lnk] | Python | Python style guide checker | 193 | | [pydocstyle][pyds-git-lnk] | [![pyds-hub-img]][pyds-hub-lnk] | Python | Python docstyle checker | 194 | | [pylint][pylint-git-lnk] | [![pylint-hub-img]][pylint-hub-lnk] | Python | Python source code, bug and quality checker | 195 | | [terraform-docs][tfdocs-git-lnk] | [![tfdocs-hub-img]][tfdocs-hub-lnk] | Terraform | Terraform doc generator (TF 0.12 ready) **[1]** | 196 | | [terragrunt][tg-git-lnk] | [![tg-hub-img]][tg-hub-lnk] | Terraform | Terragrunt and Terraform | 197 | | [terragrunt-fmt][tgfmt-git-lnk] | [![tgfmt-hub-img]][tgfmt-hub-lnk] | Terraform | `terraform fmt` for Terragrunt files **[1]** | 198 | | [yamlfmt][yfmt-git-lnk] | [![yfmt-hub-img]][yfmt-hub-lnk] | Yaml | Format Yaml files **[1]** | 199 | | [yamllint][ylint-git-lnk] | [![ylint-hub-img]][ylint-hub-lnk] | Yaml | Lint Yaml files | 200 | 201 | > **[1]** Uses a shell wrapper to add **enhanced functionality** not available by original project. 202 | 203 | [aci-git-lnk]: https://github.com/cytopia/awesome-ci 204 | [aci-hub-img]: https://img.shields.io/docker/pulls/cytopia/awesome-ci.svg 205 | [aci-hub-lnk]: https://hub.docker.com/r/cytopia/awesome-ci 206 | 207 | [flint-git-lnk]: https://github.com/cytopia/docker-file-lint 208 | [flint-hub-img]: https://img.shields.io/docker/pulls/cytopia/file-lint.svg 209 | [flint-hub-lnk]: https://hub.docker.com/r/cytopia/file-lint 210 | 211 | [linkcheck-git-lnk]: https://github.com/cytopia/docker-linkcheck 212 | [linkcheck-hub-img]: https://img.shields.io/docker/pulls/cytopia/linkcheck.svg 213 | [linkcheck-hub-lnk]: https://hub.docker.com/r/cytopia/linkcheck 214 | 215 | [jlint-git-lnk]: https://github.com/cytopia/docker-jsonlint 216 | [jlint-hub-img]: https://img.shields.io/docker/pulls/cytopia/jsonlint.svg 217 | [jlint-hub-lnk]: https://hub.docker.com/r/cytopia/jsonlint 218 | 219 | [ansible-git-lnk]: https://github.com/cytopia/docker-ansible 220 | [ansible-hub-img]: https://img.shields.io/docker/pulls/cytopia/ansible.svg 221 | [ansible-hub-lnk]: https://hub.docker.com/r/cytopia/ansible 222 | 223 | [alint-git-lnk]: https://github.com/cytopia/docker-ansible-lint 224 | [alint-hub-img]: https://img.shields.io/docker/pulls/cytopia/ansible-lint.svg 225 | [alint-hub-lnk]: https://hub.docker.com/r/cytopia/ansible-lint 226 | 227 | [kubeval-git-lnk]: https://github.com/cytopia/docker-kubeval 228 | [kubeval-hub-img]: https://img.shields.io/docker/pulls/cytopia/kubeval.svg 229 | [kubeval-hub-lnk]: https://hub.docker.com/r/cytopia/kubeval 230 | 231 | [gfmt-git-lnk]: https://github.com/cytopia/docker-gofmt 232 | [gfmt-hub-img]: https://img.shields.io/docker/pulls/cytopia/gofmt.svg 233 | [gfmt-hub-lnk]: https://hub.docker.com/r/cytopia/gofmt 234 | 235 | [gimp-git-lnk]: https://github.com/cytopia/docker-goimports 236 | [gimp-hub-img]: https://img.shields.io/docker/pulls/cytopia/goimports.svg 237 | [gimp-hub-lnk]: https://hub.docker.com/r/cytopia/goimports 238 | 239 | [glint-git-lnk]: https://github.com/cytopia/docker-golint 240 | [glint-hub-img]: https://img.shields.io/docker/pulls/cytopia/golint.svg 241 | [glint-hub-lnk]: https://hub.docker.com/r/cytopia/golint 242 | 243 | [elint-git-lnk]: https://github.com/cytopia/docker-eslint 244 | [elint-hub-img]: https://img.shields.io/docker/pulls/cytopia/eslint.svg 245 | [elint-hub-lnk]: https://hub.docker.com/r/cytopia/eslint 246 | 247 | [cm-git-lnk]: https://github.com/cytopia/docker-checkmake 248 | [cm-hub-img]: https://img.shields.io/docker/pulls/cytopia/checkmake.svg 249 | [cm-hub-lnk]: https://hub.docker.com/r/cytopia/checkmake 250 | 251 | [pcbf-git-lnk]: https://github.com/cytopia/docker-phpcbf 252 | [pcbf-hub-img]: https://img.shields.io/docker/pulls/cytopia/phpcbf.svg 253 | [pcbf-hub-lnk]: https://hub.docker.com/r/cytopia/phpcbf 254 | 255 | [pcs-git-lnk]: https://github.com/cytopia/docker-phpcs 256 | [pcs-hub-img]: https://img.shields.io/docker/pulls/cytopia/phpcs.svg 257 | [pcs-hub-lnk]: https://hub.docker.com/r/cytopia/phpcs 258 | 259 | [plint-git-lnk]: https://github.com/cytopia/docker-phplint 260 | [plint-hub-img]: https://img.shields.io/docker/pulls/cytopia/phplint.svg 261 | [plint-hub-lnk]: https://hub.docker.com/r/cytopia/phplint 262 | 263 | [pcsf-git-lnk]: https://github.com/cytopia/docker-php-cs-fixer 264 | [pcsf-hub-img]: https://img.shields.io/docker/pulls/cytopia/php-cs-fixer.svg 265 | [pcsf-hub-lnk]: https://hub.docker.com/r/cytopia/php-cs-fixer 266 | 267 | [bandit-git-lnk]: https://github.com/cytopia/docker-bandit 268 | [bandit-hub-img]: https://img.shields.io/docker/pulls/cytopia/bandit.svg 269 | [bandit-hub-lnk]: https://hub.docker.com/r/cytopia/bandit 270 | 271 | [black-git-lnk]: https://github.com/cytopia/docker-black 272 | [black-hub-img]: https://img.shields.io/docker/pulls/cytopia/black.svg 273 | [black-hub-lnk]: https://hub.docker.com/r/cytopia/black 274 | 275 | [mypy-git-lnk]: https://github.com/cytopia/docker-mypy 276 | [mypy-hub-img]: https://img.shields.io/docker/pulls/cytopia/mypy.svg 277 | [mypy-hub-lnk]: https://hub.docker.com/r/cytopia/mypy 278 | 279 | [pycs-git-lnk]: https://github.com/cytopia/docker-pycodestyle 280 | [pycs-hub-img]: https://img.shields.io/docker/pulls/cytopia/pycodestyle.svg 281 | [pycs-hub-lnk]: https://hub.docker.com/r/cytopia/pycodestyle 282 | 283 | [pyds-git-lnk]: https://github.com/cytopia/docker-pydocstyle 284 | [pyds-hub-img]: https://img.shields.io/docker/pulls/cytopia/pydocstyle.svg 285 | [pyds-hub-lnk]: https://hub.docker.com/r/cytopia/pydocstyle 286 | 287 | [pylint-git-lnk]: https://github.com/cytopia/docker-pylint 288 | [pylint-hub-img]: https://img.shields.io/docker/pulls/cytopia/pylint.svg 289 | [pylint-hub-lnk]: https://hub.docker.com/r/cytopia/pylint 290 | 291 | [tfdocs-git-lnk]: https://github.com/cytopia/docker-terraform-docs 292 | [tfdocs-hub-img]: https://img.shields.io/docker/pulls/cytopia/terraform-docs.svg 293 | [tfdocs-hub-lnk]: https://hub.docker.com/r/cytopia/terraform-docs 294 | 295 | [tg-git-lnk]: https://github.com/cytopia/docker-terragrunt 296 | [tg-hub-img]: https://img.shields.io/docker/pulls/cytopia/terragrunt.svg 297 | [tg-hub-lnk]: https://hub.docker.com/r/cytopia/terragrunt 298 | 299 | [tgfmt-git-lnk]: https://github.com/cytopia/docker-terragrunt-fmt 300 | [tgfmt-hub-img]: https://img.shields.io/docker/pulls/cytopia/terragrunt-fmt.svg 301 | [tgfmt-hub-lnk]: https://hub.docker.com/r/cytopia/terragrunt-fmt 302 | 303 | [yfmt-git-lnk]: https://github.com/cytopia/docker-yamlfmt 304 | [yfmt-hub-img]: https://img.shields.io/docker/pulls/cytopia/yamlfmt.svg 305 | [yfmt-hub-lnk]: https://hub.docker.com/r/cytopia/yamlfmt 306 | 307 | [ylint-git-lnk]: https://github.com/cytopia/docker-yamllint 308 | [ylint-hub-img]: https://img.shields.io/docker/pulls/cytopia/yamllint.svg 309 | [ylint-hub-lnk]: https://hub.docker.com/r/cytopia/yamllint 310 | 311 | 312 | ### Makefiles 313 | 314 | Visit **[cytopia/makefiles](https://github.com/cytopia/makefiles)** for dependency-less, seamless project integration and minimum required best-practice code linting for CI. 315 | The provided Makefiles will only require GNU Make and Docker itself removing the need to install anything else. 316 | 317 | 318 | ## :page_facing_up: License 319 | 320 | 321 | **[MIT License](LICENSE)** 322 | 323 | Copyright (c) 2019 [cytopia](https://github.com/cytopia) 324 | --------------------------------------------------------------------------------