Loading .gitignore 0 → 100644 +2 −0 Original line number Diff line number Diff line # Python (for tests) *.py[co] .gitlab-ci.yml +74 −68 Original line number Diff line number Diff line image: docker:stable variables: DOCKER_HOST: "tcp://docker:2375/" DOCKER_DRIVER: "overlay2" DOCKER_TLS_CERTDIR: "" DOCKER_BUILDKIT: "1" services: - docker:dind before_script: - docker info - docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY" WORDPRESS_VERSION: value: 5.8.1 description: WordPress release PHP_VERSION: value: 8.0.0 description: PHP release to build into the backend image NGINX_VERSION: value: 1.21.3 description: Nginx release for the frontend image .build: &build stage: build script: - TARGET=${CI_JOB_NAME##*:} - BUILD_TAG=${CI_REGISTRY_IMAGE}/${TARGET}/build:${CI_PIPELINE_ID} - docker build . --pull=true --tag=${BUILD_TAG} --target=${TARGET} ${NGINX_VERSION:+--build-arg=nginx_version=$NGINX_VERSION} ${PHP_VERSION:+--build-arg=php_version=$PHP_VERSION} ${WORDPRESS_VERSION:+--build-arg=wp_version=$WORDPRESS_VERSION} - docker push ${BUILD_TAG} .changes: &only-changes only: &change-files .changes: &change-files changes: - .gitlab-ci.yml - Dockerfile Loading @@ -37,48 +18,73 @@ before_script: - plugins/* - scripts/* .merge-requests: &only-merge-requests only: << : *change-files refs: - merge_requests build-master:fastcgi: << : [ *build ] only: [ master, schedules ] build-master:nginx: << : [ *build ] only: [ master, schedules ] build-mr:fastcgi: << : [ *build, *only-merge-requests ] build-mr:nginx: << : [ *build, *only-merge-requests ] build:fastcgi: << : [ *build, *only-changes ] except: [ merge_requests, master, schedules ] build:nginx: << : [ *build, *only-changes ] except: [ merge_requests, master, schedules ] .build: stage: build image: docker.kodo.org.uk/ci-images/buildkit/buildctl:latest tags: [buildkit] rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_PIPELINE_SOURCE == "merge_request_event" - << : *change-files script: - BUILD_TAG=${CI_REGISTRY_IMAGE}/${TARGET}:build-${CI_PIPELINE_IID} - buildctl build --frontend=dockerfile.v0 --local context=. --local dockerfile=. --opt target=${TARGET} --opt build-arg:nginx_version=${NGINX_VERSION} --opt build-arg:php_version=${PHP_VERSION} --opt build-arg:wp_version=${WORDPRESS_VERSION} --opt label:nginx.version=${NGINX_VERSION} --opt label:php.version=${PHP_VERSION} --opt label:wordpress.version=${WORDPRESS_VERSION} --output type=image,name=${BUILD_TAG},push=true .push-tags: &push-tags .tag: stage: deploy only: image: docker.kodo.org.uk/ci-images/docker-reg:latest rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "schedule" variables: TAG: latest - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH << : *change-files variables: TAG: latest - if: $CI_COMMIT_BRANCH == "develop" << : *change-files refs: [ master, develop, schedules ] variables: TAG: unstable script: | BUILD_REPO=${CI_REGISTRY_IMAGE}/${CI_JOB_NAME##*:}/build:${CI_PIPELINE_ID} DEPLOY_REPO=${CI_REGISTRY_IMAGE}/${CI_JOB_NAME##*:} VERSION=`eval "docker run --rm ${BUILD_REPO} ${GET_VERSION}"` . scripts/deploy.sh BUILD_TAG=${CI_REGISTRY_IMAGE}/${TARGET}:build-${CI_PIPELINE_IID} docker-reg $BUILD_TAG retag $TAG if [ $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]; then docker-reg $BUILD_TAG retag $VERSION fi push:fastcgi: <<: *push-tags Build Wordpress: extends: [.build] variables: GET_VERSION: wp core version push:nginx: <<: *push-tags TARGET: fastcgi Build Nginx: extends: [.build] variables: TARGET: nginx Tag Wordpress Image: extends: [.tag] variables: TARGET: fastcgi VERSION: $WORDPRESS_VERSION Tag Nginx Image: extends: [.tag] variables: GET_VERSION: nginx -V 2>&1 | sed -n '/nginx version:/s/.*nginx\///p' TARGET: nginx VERSION: $NGINX_VERSION .lint.cfg 0 → 100644 +103 −0 Original line number Diff line number Diff line [isort] force_single_line = true [mypy] strict = true warn_unused_configs = true warn_unreachable = true mypy_path = tests, tests/stubs plugins = trio_typing.plugin [flake8] max-line-length = 92 max-doc-length = 92 use-flake8-tabs = true blank-lines-indent = never indent-tabs-def = 1 format = pylint select = C,D,E,ET,F,SFS,T,W,WT per-file-ignores = **/__init__.py: D104 **/__main__.py: D100, E702 ignore = ;[ '%s' imported but unused ] ; Handled by pylint, which does it better F401 ;[ Missing docstring in public method ] ; Handled by pylint, which does it better D102 ;[ Missing docstring in magic method ] ; Magic/dunder methods are well-known D105 ;[ Misisng docstring in __init__ ] ; Document basic construction in the class docstring D107 ;[ One-line docstring should fit on one line with quotes ] ; Prefer top-and-bottom style always D200 ;[ Docstring should be indented with spaces, not tabs ] ; Tabs, absolutely always D206 ;[ Use r""" if any backslashes in a docstring ] ; If I want to put escape chars in a docstring, I will D301 ;[ Use u""" for Unicode docstrings ] ; This must be for Python 2? D302 ;[ First line should end with a period ] ; First line should *NEVER* end with a period D400 ;[ First line should be in the imperative mood ] ; I like this for functions and methods, not for properties. This stands until ; pydocstyle splits a new code for properties or flake8 adds some way of ; filtering codes with line regexes like golangci-lint. D401 ;[ No blank lines allowed between a section header and its content ] D412 ;[ missing whitespace around bitwise or shift operator ] E227 ;[ Line too long ] ; Prefer B950 implementation E501 ;[ multiple statements on one line (def) ] ; Dosen't work well with short @overload definitions E704 ;[ unexpected number of tabs and spaces at start of statement ] ET128 ;[ Line break before binary operator ] ; Not considered current W503 ;[ Format-method string formatting ] ; Allow this style SFS201 ;[ f-string string formatting ] ; Allow this style SFS301 include = ;[ First word of the docstring should not be This ] D404 ; flake8-bugbear plugin ; B950 is a replacement for E501 B0 B903 B950 .pre-commit-config.yaml +68 −15 Original line number Diff line number Diff line default_stages: [commit] repos: - repo: meta hooks: - id: check-hooks-apply - id: check-useless-excludes - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.4.0 hooks: - id: check-added-large-files stages: [commit] - id: check-case-conflict stages: [commit] - id: check-docstring-first - id: check-merge-conflict stages: [commit] - id: check-yaml args: [--allow-multiple-documents] stages: [commit] - id: debug-statements - id: destroyed-symlinks stages: [commit] - id: end-of-file-fixer stages: [commit] stages: [commit, manual] - id: fix-byte-order-marker stages: [commit] - id: fix-encoding-pragma args: [--remove] - id: mixed-line-ending args: [--fix=lf] stages: [commit] stages: [commit, manual] - id: trailing-whitespace exclude_types: [markdown, plain-text] stages: [commit] stages: [commit, manual] - repo: https://github.com/jorisroovers/gitlint rev: v0.15.0 hooks: - id: gitlint - repo: https://github.com/jumanjihouse/pre-commit-hooks rev: 2.1.5 hooks: - id: protect-first-parent - repo: https://code.kodo.org.uk/dom/pre-commit-hooks rev: v0.5.1 rev: v0.6 hooks: - id: check-executable-modes - id: check-for-squash - id: copyright-notice exclude: ^data/ - id: protect-first-parent - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.8.0 hooks: - id: python-no-eval - id: python-no-log-warn - id: python-use-type-annotations - repo: https://github.com/hakancelik96/unimport rev: 0.9.2 hooks: - id: unimport args: ["--remove", "--include=\\.pyi?$"] types: [] types_or: [python, pyi] stages: [commit, manual] - repo: https://github.com/pycqa/isort rev: 5.9.3 hooks: - id: isort args: ["--settings=.lint.cfg"] stages: [commit, manual] - repo: https://github.com/asottile/add-trailing-comma rev: v2.1.0 hooks: - id: add-trailing-comma args: [--py36-plus] types: [] types_or: [python, pyi] stages: [commit, manual] - repo: https://gitlab.com/pycqa/flake8 rev: 3.8.4 hooks: - id: flake8 args: ["--config=.lint.cfg"] additional_dependencies: - flake8-bugbear - flake8-docstrings - flake8-print - flake8-requirements - flake8-return - flake8-sfs - flake8-tabs - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.910 hooks: - id: mypy args: ["--config-file=.lint.cfg"] additional_dependencies: - trio-typing - types-requests - git+https://code.kodo.org.uk/dom/type-stubs.git#type-stubs[jsonpath,parse] Dockerfile +4 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,10 @@ RUN --mount=type=bind,source=scripts/install-deps.sh,target=/stage /stage FROM deps as compile RUN --mount=type=bind,source=scripts/install-build-deps.sh,target=/stage /stage RUN --mount=type=bind,source=scripts/compile-dist-ext.sh,target=/stage /stage RUN --mount=type=bind,source=scripts/compile-imagick.sh,target=/stage /stage ARG imagick_version RUN --mount=type=bind,source=scripts/compile-imagick.sh,target=/stage \ /stage ${imagick_version} FROM deps as fastcgi Loading Loading
.gitignore 0 → 100644 +2 −0 Original line number Diff line number Diff line # Python (for tests) *.py[co]
.gitlab-ci.yml +74 −68 Original line number Diff line number Diff line image: docker:stable variables: DOCKER_HOST: "tcp://docker:2375/" DOCKER_DRIVER: "overlay2" DOCKER_TLS_CERTDIR: "" DOCKER_BUILDKIT: "1" services: - docker:dind before_script: - docker info - docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY" WORDPRESS_VERSION: value: 5.8.1 description: WordPress release PHP_VERSION: value: 8.0.0 description: PHP release to build into the backend image NGINX_VERSION: value: 1.21.3 description: Nginx release for the frontend image .build: &build stage: build script: - TARGET=${CI_JOB_NAME##*:} - BUILD_TAG=${CI_REGISTRY_IMAGE}/${TARGET}/build:${CI_PIPELINE_ID} - docker build . --pull=true --tag=${BUILD_TAG} --target=${TARGET} ${NGINX_VERSION:+--build-arg=nginx_version=$NGINX_VERSION} ${PHP_VERSION:+--build-arg=php_version=$PHP_VERSION} ${WORDPRESS_VERSION:+--build-arg=wp_version=$WORDPRESS_VERSION} - docker push ${BUILD_TAG} .changes: &only-changes only: &change-files .changes: &change-files changes: - .gitlab-ci.yml - Dockerfile Loading @@ -37,48 +18,73 @@ before_script: - plugins/* - scripts/* .merge-requests: &only-merge-requests only: << : *change-files refs: - merge_requests build-master:fastcgi: << : [ *build ] only: [ master, schedules ] build-master:nginx: << : [ *build ] only: [ master, schedules ] build-mr:fastcgi: << : [ *build, *only-merge-requests ] build-mr:nginx: << : [ *build, *only-merge-requests ] build:fastcgi: << : [ *build, *only-changes ] except: [ merge_requests, master, schedules ] build:nginx: << : [ *build, *only-changes ] except: [ merge_requests, master, schedules ] .build: stage: build image: docker.kodo.org.uk/ci-images/buildkit/buildctl:latest tags: [buildkit] rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_PIPELINE_SOURCE == "schedule" - if: $CI_PIPELINE_SOURCE == "merge_request_event" - << : *change-files script: - BUILD_TAG=${CI_REGISTRY_IMAGE}/${TARGET}:build-${CI_PIPELINE_IID} - buildctl build --frontend=dockerfile.v0 --local context=. --local dockerfile=. --opt target=${TARGET} --opt build-arg:nginx_version=${NGINX_VERSION} --opt build-arg:php_version=${PHP_VERSION} --opt build-arg:wp_version=${WORDPRESS_VERSION} --opt label:nginx.version=${NGINX_VERSION} --opt label:php.version=${PHP_VERSION} --opt label:wordpress.version=${WORDPRESS_VERSION} --output type=image,name=${BUILD_TAG},push=true .push-tags: &push-tags .tag: stage: deploy only: image: docker.kodo.org.uk/ci-images/docker-reg:latest rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "schedule" variables: TAG: latest - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH << : *change-files variables: TAG: latest - if: $CI_COMMIT_BRANCH == "develop" << : *change-files refs: [ master, develop, schedules ] variables: TAG: unstable script: | BUILD_REPO=${CI_REGISTRY_IMAGE}/${CI_JOB_NAME##*:}/build:${CI_PIPELINE_ID} DEPLOY_REPO=${CI_REGISTRY_IMAGE}/${CI_JOB_NAME##*:} VERSION=`eval "docker run --rm ${BUILD_REPO} ${GET_VERSION}"` . scripts/deploy.sh BUILD_TAG=${CI_REGISTRY_IMAGE}/${TARGET}:build-${CI_PIPELINE_IID} docker-reg $BUILD_TAG retag $TAG if [ $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]; then docker-reg $BUILD_TAG retag $VERSION fi push:fastcgi: <<: *push-tags Build Wordpress: extends: [.build] variables: GET_VERSION: wp core version push:nginx: <<: *push-tags TARGET: fastcgi Build Nginx: extends: [.build] variables: TARGET: nginx Tag Wordpress Image: extends: [.tag] variables: TARGET: fastcgi VERSION: $WORDPRESS_VERSION Tag Nginx Image: extends: [.tag] variables: GET_VERSION: nginx -V 2>&1 | sed -n '/nginx version:/s/.*nginx\///p' TARGET: nginx VERSION: $NGINX_VERSION
.lint.cfg 0 → 100644 +103 −0 Original line number Diff line number Diff line [isort] force_single_line = true [mypy] strict = true warn_unused_configs = true warn_unreachable = true mypy_path = tests, tests/stubs plugins = trio_typing.plugin [flake8] max-line-length = 92 max-doc-length = 92 use-flake8-tabs = true blank-lines-indent = never indent-tabs-def = 1 format = pylint select = C,D,E,ET,F,SFS,T,W,WT per-file-ignores = **/__init__.py: D104 **/__main__.py: D100, E702 ignore = ;[ '%s' imported but unused ] ; Handled by pylint, which does it better F401 ;[ Missing docstring in public method ] ; Handled by pylint, which does it better D102 ;[ Missing docstring in magic method ] ; Magic/dunder methods are well-known D105 ;[ Misisng docstring in __init__ ] ; Document basic construction in the class docstring D107 ;[ One-line docstring should fit on one line with quotes ] ; Prefer top-and-bottom style always D200 ;[ Docstring should be indented with spaces, not tabs ] ; Tabs, absolutely always D206 ;[ Use r""" if any backslashes in a docstring ] ; If I want to put escape chars in a docstring, I will D301 ;[ Use u""" for Unicode docstrings ] ; This must be for Python 2? D302 ;[ First line should end with a period ] ; First line should *NEVER* end with a period D400 ;[ First line should be in the imperative mood ] ; I like this for functions and methods, not for properties. This stands until ; pydocstyle splits a new code for properties or flake8 adds some way of ; filtering codes with line regexes like golangci-lint. D401 ;[ No blank lines allowed between a section header and its content ] D412 ;[ missing whitespace around bitwise or shift operator ] E227 ;[ Line too long ] ; Prefer B950 implementation E501 ;[ multiple statements on one line (def) ] ; Dosen't work well with short @overload definitions E704 ;[ unexpected number of tabs and spaces at start of statement ] ET128 ;[ Line break before binary operator ] ; Not considered current W503 ;[ Format-method string formatting ] ; Allow this style SFS201 ;[ f-string string formatting ] ; Allow this style SFS301 include = ;[ First word of the docstring should not be This ] D404 ; flake8-bugbear plugin ; B950 is a replacement for E501 B0 B903 B950
.pre-commit-config.yaml +68 −15 Original line number Diff line number Diff line default_stages: [commit] repos: - repo: meta hooks: - id: check-hooks-apply - id: check-useless-excludes - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.4.0 hooks: - id: check-added-large-files stages: [commit] - id: check-case-conflict stages: [commit] - id: check-docstring-first - id: check-merge-conflict stages: [commit] - id: check-yaml args: [--allow-multiple-documents] stages: [commit] - id: debug-statements - id: destroyed-symlinks stages: [commit] - id: end-of-file-fixer stages: [commit] stages: [commit, manual] - id: fix-byte-order-marker stages: [commit] - id: fix-encoding-pragma args: [--remove] - id: mixed-line-ending args: [--fix=lf] stages: [commit] stages: [commit, manual] - id: trailing-whitespace exclude_types: [markdown, plain-text] stages: [commit] stages: [commit, manual] - repo: https://github.com/jorisroovers/gitlint rev: v0.15.0 hooks: - id: gitlint - repo: https://github.com/jumanjihouse/pre-commit-hooks rev: 2.1.5 hooks: - id: protect-first-parent - repo: https://code.kodo.org.uk/dom/pre-commit-hooks rev: v0.5.1 rev: v0.6 hooks: - id: check-executable-modes - id: check-for-squash - id: copyright-notice exclude: ^data/ - id: protect-first-parent - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.8.0 hooks: - id: python-no-eval - id: python-no-log-warn - id: python-use-type-annotations - repo: https://github.com/hakancelik96/unimport rev: 0.9.2 hooks: - id: unimport args: ["--remove", "--include=\\.pyi?$"] types: [] types_or: [python, pyi] stages: [commit, manual] - repo: https://github.com/pycqa/isort rev: 5.9.3 hooks: - id: isort args: ["--settings=.lint.cfg"] stages: [commit, manual] - repo: https://github.com/asottile/add-trailing-comma rev: v2.1.0 hooks: - id: add-trailing-comma args: [--py36-plus] types: [] types_or: [python, pyi] stages: [commit, manual] - repo: https://gitlab.com/pycqa/flake8 rev: 3.8.4 hooks: - id: flake8 args: ["--config=.lint.cfg"] additional_dependencies: - flake8-bugbear - flake8-docstrings - flake8-print - flake8-requirements - flake8-return - flake8-sfs - flake8-tabs - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.910 hooks: - id: mypy args: ["--config-file=.lint.cfg"] additional_dependencies: - trio-typing - types-requests - git+https://code.kodo.org.uk/dom/type-stubs.git#type-stubs[jsonpath,parse]
Dockerfile +4 −1 Original line number Diff line number Diff line Loading @@ -14,7 +14,10 @@ RUN --mount=type=bind,source=scripts/install-deps.sh,target=/stage /stage FROM deps as compile RUN --mount=type=bind,source=scripts/install-build-deps.sh,target=/stage /stage RUN --mount=type=bind,source=scripts/compile-dist-ext.sh,target=/stage /stage RUN --mount=type=bind,source=scripts/compile-imagick.sh,target=/stage /stage ARG imagick_version RUN --mount=type=bind,source=scripts/compile-imagick.sh,target=/stage \ /stage ${imagick_version} FROM deps as fastcgi Loading