From 73c437dcdf3a230d80578fdbe1782ddc70cd9360 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Wed, 2 Oct 2024 18:14:20 +0700 Subject: [PATCH 01/12] feat: add main builder Signed-off-by: bkioshn --- earthly/container/Earthfile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 earthly/container/Earthfile diff --git a/earthly/container/Earthfile b/earthly/container/Earthfile new file mode 100644 index 000000000..899fc7cc2 --- /dev/null +++ b/earthly/container/Earthfile @@ -0,0 +1,26 @@ +VERSION 0.8 + +IMPORT ../python AS python +IMPORT ../../utilities/scripts AS scripts + +main-builder: + FROM debian:stable-slim + + ARG --required tool + + WORKDIR /root + + RUN apt-get update && \ + apt-get install -y \ + openssl \ + wget \ + curl \ + graphviz \ + bash \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + + IF [ "$tool" = "python" ] + COPY python+script/scripts scripts + DO python+ADD_PYTHON_TOOLS + END From 6c8f053087895694c24e288f811cfbf770bc3850 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Wed, 2 Oct 2024 18:14:51 +0700 Subject: [PATCH 02/12] feat: add python tool installation Signed-off-by: bkioshn --- earthly/python/Earthfile | 45 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/earthly/python/Earthfile b/earthly/python/Earthfile index 562e2c038..f308f7a1a 100644 --- a/earthly/python/Earthfile +++ b/earthly/python/Earthfile @@ -1,10 +1,51 @@ -# Common Python UDCs and Builders. VERSION 0.8 IMPORT ../../utilities/scripts AS scripts # cspell: words libgcc ruff +# script: Copy the python scripts directory +script: + FROM scratch + COPY --dir scripts scripts + SAVE ARTIFACT /scripts scripts + +ADD_PYTHON_TOOLS: + FUNCTION + + # Install additional Python tools + RUN apt-get update && \ + apt-get install -y \ + python3.10 \ + python3-pip \ + python3-venv \ + && rm -rf /var/lib/apt/lists/* + + RUN python3 --version + RUN pip3 --version + + RUN python3 -m venv /opt/venv + ENV PATH="/opt/venv/bin:$PATH" + ENV PYTHONDONTWRITEBYTECODE=1 # Prevents .pyc file creation + + # Install Poetry + ENV POETRY_HOME="/opt/poetry" + RUN mkdir -p $POETRY_HOME && \ + curl -sSL https://install.python-poetry.org | python3 - && \ + ln -s "$POETRY_HOME/bin/poetry" /usr/local/bin/poetry + + # Adjust Poetry's configuration to optimize performance + RUN poetry config installer.max-workers 10 + + RUN pip3 install ruff==0.6.8 + RUN pip install rich==13.9.1 + + # Add common scripts for use within the container + DO scripts+ADD_BASH_SCRIPTS + DO scripts+ADD_PYTHON_SCRIPTS + +# ------- delete below this line ------- + python-base: FROM python:3.12-alpine3.20 @@ -60,7 +101,7 @@ CHECK: FUNCTION # Execute the check script - RUN /scripts/std_checks.py + RUN scripts/std_checks.py LINT_PYTHON: # Linting all Python code is done with ruff From f621f5c594e86449350eeab00f3b5c3c45adbf7e Mon Sep 17 00:00:00 2001 From: bkioshn Date: Wed, 2 Oct 2024 18:15:29 +0700 Subject: [PATCH 03/12] fix: python example Signed-off-by: bkioshn --- examples/python/Earthfile | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/examples/python/Earthfile b/examples/python/Earthfile index 755bfde7a..5bcb07335 100644 --- a/examples/python/Earthfile +++ b/examples/python/Earthfile @@ -1,20 +1,14 @@ VERSION 0.8 IMPORT ../../earthly/python AS python-ci - -# Assuming the detailed setup from the second snippet is defined in relevant Earthly targets. +IMPORT ../../earthly/container AS container builder: - FROM python-ci+python-base - + FROM container+main-builder --tool=python + COPY --dir poetry.lock pyproject.toml Readme.md src . check: FROM +builder DO python-ci+CHECK - -python-linter: - FROM +builder - - DO python-ci+LINT_PYTHON \ No newline at end of file From e0f4369c21e6b5a41b4171bc9c612cb3e97b25c0 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Fri, 4 Oct 2024 16:43:12 +0700 Subject: [PATCH 04/12] feat(wip): add rust tools (only work for amd64) Signed-off-by: bkioshn --- earthly/container/Earthfile | 2 + earthly/rust/Earthfile | 199 ++++++++++++++++++++++++++++++++++++ examples/rust/Earthfile | 3 +- 3 files changed, 203 insertions(+), 1 deletion(-) diff --git a/earthly/container/Earthfile b/earthly/container/Earthfile index 899fc7cc2..6c9f3f97d 100644 --- a/earthly/container/Earthfile +++ b/earthly/container/Earthfile @@ -1,6 +1,7 @@ VERSION 0.8 IMPORT ../python AS python +IMPORT ../rust AS rust IMPORT ../../utilities/scripts AS scripts main-builder: @@ -24,3 +25,4 @@ main-builder: COPY python+script/scripts scripts DO python+ADD_PYTHON_TOOLS END + DO rust+ADD_RUST_TOOLS diff --git a/earthly/rust/Earthfile b/earthly/rust/Earthfile index 25e4b398e..9a5c3820b 100644 --- a/earthly/rust/Earthfile +++ b/earthly/rust/Earthfile @@ -15,6 +15,205 @@ IMPORT ../../utilities/scripts AS scripts # cspell: words miri ripgrep toolset lcov psycopg # cspell: words TARGETPLATFORM TARGETOS TARGETARCH TARGETVARIANT USERPLATFORM USEROS USERARCH USERVARIANT # cspell: words findutils fileset pkgconfig wasip +script: + FROM scratch + COPY --dir scripts /scripts + COPY --dir stdcfgs /stdcfgs + + SAVE ARTIFACT /scripts scripts + SAVE ARTIFACT /stdcfgs stdcfgs + +ADD_RUST_TOOLS: + FUNCTION + + ARG TARGETPLATFORM + ARG TARGETOS + ARG TARGETARCH + ARG TARGETVARIANT + ARG USERPLATFORM + ARG USEROS + ARG USERARCH + ARG USERVARIANT + + ARG keep_fingerprints=false + ARG sweep_days=4 + + # $EARTHLY_CACHE_PREFIX - MUST BE DONE IN A FUNCTION, OR IT PRODUCES THE WRONG VALUE + ARG EARTHLY_TARGET_PROJECT_NO_TAG #https://docs.earthly.dev/docs/earthfile/builtin-args + ARG CACHE_VERSION="00001" # Bumping this causes the old cache to be dropped. + ARG cache_prefix="${EARTHLY_TARGET_PROJECT_NO_TAG}#${TARGETOS}#${TARGETARCH}${TARGETVARIANT}#earthly-cargo-cache#${CACHE_VERSION}" + + # Enables rust backtrace when something panics + ENV RUST_BACKTRACE=full + + # Install necessary packages + # Expand this list as needed, rather than adding more tools in later containers. + # + # Note: openssl-dev and openssl-libs-static are added to support the cargo-component crate. + # if that crate is removed, these dependencies can also be removed. + RUN apt-get update && apt-get install -y \ + build-essential \ + clang \ + cmake \ + colordiff \ + findutils \ + fontconfig \ + fonts-liberation2 \ + libssl-dev \ + mold \ + openssl \ + pkgconf \ + python3-pip \ + python3-rich \ + python3-psycopg \ + ripgrep \ + ca-certificates \ + gcc \ + libc6-dev \ + && rm -rf /var/lib/apt/lists/* + + + DO +RUST_INSTALL + + # Fix up font cache. + RUN fc-cache -f + + # Make sure we have cargo. + RUN rustup component add cargo + + # Make sure we have the clippy linter. + RUN rustup component add clippy + + # Needed to generate code coverage. + RUN rustup component add llvm-tools-preview + + # Install a nightly toolchain which matches. + RUN rustup toolchain install nightly --component miri --component rust-src --component rustfmt --component clippy --component cargo + + # Ensure we have all the necessary targets + RUN rustup target add wasm32-unknown-unknown + RUN rustup target add wasm32-wasip1 + # RUN rustup target add wasm32-wasip2 # wasm32-wasip2 not yet available in stable - Try again in 1.82 + RUN rustup target add x86_64-unknown-linux-gnu + RUN rustup target add x86_64-apple-darwin + RUN rustup target add x86_64-pc-windows-gnu + RUN rustup target add aarch64-unknown-linux-gnu + RUN rustup target add aarch64-apple-darwin + + RUN rustup target add wasm32-unknown-unknown --toolchain nightly + RUN rustup target add wasm32-wasip1 --toolchain nightly + RUN rustup target add wasm32-wasip2 --toolchain nightly + RUN rustup target add x86_64-unknown-linux-gnu --toolchain nightly + RUN rustup target add x86_64-apple-darwin --toolchain nightly + RUN rustup target add x86_64-pc-windows-gnu --toolchain nightly + RUN rustup target add aarch64-unknown-linux-gnu --toolchain nightly + RUN rustup target add aarch64-apple-darwin --toolchain nightly + + RUN echo $PATH + RUN echo $CARGO_HOME + + + + # CARGO_HOME, PATH and RUSTUP_HOME is already set by the base container. + # Do not change them. + + DO +INSTALL_TOOLS + + DO rust+INIT --keep_fingerprints=$keep_fingerprints --sweep_days=$sweep_days --cache_prefix=$cache_prefix + + # # Set the mount cache env vars + DO rust+SET_CACHE_MOUNTS_ENV + # COPY +script/scripts scripts + + # # Universal build scripts we will always need and are not target dependent. + # COPY --dir scripts /scripts + COPY +script/scripts /scripts + # # Copy our common scripts so we can use them inside the container. + DO scripts+ADD_BASH_SCRIPTS + DO scripts+ADD_PYTHON_SCRIPTS + + COPY +script/stdcfgs /stdcfgs + + # RUN false + + # Standardized Rust configs. + # Build will refuse to proceed if the projects rust configs do not match these. + # This is to enforce consistent compiler and tool configuration on local setup and CI builds. + # COPY --dir stdcfgs /stdcfgs + +RUST_INSTALL: + FUNCTION + + ARG TARGETARCH + + LABEL org.opencontainers.image.source=https://github.com/rust-lang/docker-rust + + ENV RUSTUP_HOME=/usr/local/rustup + ENV CARGO_HOME=/usr/local/cargo + ENV PATH=/usr/local/cargo/bin:$PATH + ENV RUST_VERSION=1.81.0 + + IF [ "$TARGETARCH" = "amd64" ] + LET PLATFORM = "x86_64-unknown-linux-gnu" + LET RUSTUP_SHA = "6aeece6993e902708983b209d04c0d1dbb14ebb405ddb87def578d41f920f56d" + ELSE IF [ "$TARGETARCH" = "arm64" ] + LET PLATFORM = "aarch64-unknown-linux-gnu" + LET RUSTUP_SHA = "1cffbf51e63e634c746f741de50649bbbcbd9dbe1de363c9ecef64e278dba2b2" + ELSE + RUN echo >&2 "unsupported architecture: ${TARGETARCH}"; exit 1 + END + + LET URL = "https://static.rust-lang.org/rustup/archive/1.27.1/${PLATFORM}/rustup-init" + RUN wget $URL && echo "${RUSTUP_SHA} *rustup-init" | sha256sum -c - \ + && chmod +x rustup-init \ + && ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host $PLATFORM \ + && rm rustup-init \ + && chmod -R a+w $RUSTUP_HOME $CARGO_HOME \ + && rustup --version && cargo --version && rustc --version \ + && rm -rf /var/lib/apt/lists/* + + # RUN set -eux; \ + # dpkgArch="$(dpkg--print-architecture)"; \ + # case "${dpkgArch##*-}" in \ + # amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='6aeece6993e902708983b209d04c0d1dbb14ebb405ddb87def578d41f920f56d' ;; \ + # armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='3c4114923305f1cd3b96ce3454e9e549ad4aa7c07c03aec73d1a785e98388bed' ;; \ + # arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='1cffbf51e63e634c746f741de50649bbbcbd9dbe1de363c9ecef64e278dba2b2' ;; \ + # i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='0a6bed6e9f21192a51f83977716466895706059afb880500ff1d0e751ada5237' ;; \ + # ppc64el) rustArch='powerpc64le-unknown-linux-gnu'; rustupSha256='079430f58ad4da1d1f4f5f2f0bd321422373213246a93b3ddb53dad627f5aa38' ;; \ + # s390x) rustArch='s390x-unknown-linux-gnu'; rustupSha256='e7f89da453c8ce5771c28279d1a01d5e83541d420695c74ec81a7ec5d287c51c' ;; \ + # *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ + # esac; \ + # url="https://static.rust-lang.org/rustup/archive/1.27.1/${rustArch}/rustup-init"; \ + # wget "$url"; \ + # echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ + # chmod +x rustup-init; \ + # ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ + # rm rustup-init; \ + # chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ + # rustup --version; \ + # cargo --version; \ + # rustc --version; \ + # rm -rf /var/lib/apt/lists/*; + # RUN false + # RUN echo $url +INSTALL_TOOLS: + FUNCTION + # Install cargo-binstall so we can speed up tool installation. + DO rust-tools+CARGO_BINSTALL_INSTALL + + DO +COPY_TOOL --tool="cargo-nextest" + DO +COPY_TOOL --tool="cargo-machete" + DO +COPY_TOOL --tool="refinery" + DO +COPY_TOOL --tool="cargo-deny" + DO +COPY_TOOL --tool="cargo-modules" + DO +COPY_TOOL --tool="cargo-depgraph" + DO +COPY_TOOL --tool="cargo-llvm-cov" + DO +COPY_TOOL --tool="wasm-tools" + DO +COPY_TOOL --tool="cargo-expand" + DO +COPY_TOOL --tool="wit-bindgen" + DO +COPY_TOOL --tool="cargo-sweep" + DO +COPY_TOOL --tool="cargo-component" + DO +COPY_TOOL --tool="wasm-pack" # rust-base : Base Rustup build container. # Not called directly, used by other targets. diff --git a/examples/rust/Earthfile b/examples/rust/Earthfile index 5c3379fb0..a8ce1cbba 100644 --- a/examples/rust/Earthfile +++ b/examples/rust/Earthfile @@ -1,12 +1,13 @@ VERSION 0.8 IMPORT ./../../earthly/rust AS rust-ci +IMPORT ./../../earthly/container AS container # cspell: words USERARCH toolsets # builder : Set up our target toolchains, and copy our files. builder: - DO rust-ci+SETUP + FROM container+main-builder --tool=rust COPY --keep-ts --dir \ .cargo .config Cargo.toml clippy.toml deny.toml rustfmt.toml \ From d7bb9c5ec7b2558387305473b8593e065403191c Mon Sep 17 00:00:00 2001 From: bkioshn Date: Thu, 17 Oct 2024 18:26:34 +0700 Subject: [PATCH 05/12] fix: add flutter tools Signed-off-by: bkioshn --- earthly/container/Earthfile | 4 +- earthly/flutter/Earthfile | 98 ++++++++++++++++++++++++++----------- 2 files changed, 72 insertions(+), 30 deletions(-) diff --git a/earthly/container/Earthfile b/earthly/container/Earthfile index 6c9f3f97d..6605b62d3 100644 --- a/earthly/container/Earthfile +++ b/earthly/container/Earthfile @@ -2,6 +2,7 @@ VERSION 0.8 IMPORT ../python AS python IMPORT ../rust AS rust +IMPORT ../flutter AS flutter IMPORT ../../utilities/scripts AS scripts main-builder: @@ -25,4 +26,5 @@ main-builder: COPY python+script/scripts scripts DO python+ADD_PYTHON_TOOLS END - DO rust+ADD_RUST_TOOLS + # DO rust+ADD_RUST_TOOLS + DO flutter+ADD_FLUTTER_TOOLS diff --git a/earthly/flutter/Earthfile b/earthly/flutter/Earthfile index 325ef5922..0de654de6 100644 --- a/earthly/flutter/Earthfile +++ b/earthly/flutter/Earthfile @@ -4,25 +4,11 @@ VERSION 0.8 IMPORT ./installer AS installer -# flutter-src save Flutter source code as artifact. -flutter-src: - FROM busybox +ADD_FLUTTER_TOOLS: + FUNCTION ARG version=3.24.1 ARG TARGETARCH - RUN mkdir -p /flutter - IF [ "$TARGETARCH" = "amd64" ] - RUN wget -qO - https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_$version-stable.tar.xz \ - | tar -xJ -C /flutter - ELSE - GIT CLONE --branch $version https://github.com/flutter/flutter.git /flutter - END - SAVE ARTIFACT /flutter flutter - -# flutter-base installs required tools and packages. -flutter-base: - FROM debian:bookworm-20240513-slim - ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update --fix-missing @@ -37,7 +23,13 @@ flutter-base: ARG edge_package_release = 1 DO installer+INSTALL_EDGE_LINUX64 --edge_version=$edge_version --edge_package_release=$edge_package_release - COPY +flutter-src/flutter /usr/local + IF [ "$TARGETARCH" = "amd64" ] + RUN wget -qO - https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_$version-stable.tar.xz \ + | tar -xJ -C /usr/local + ELSE IF [ "$TARGETARCH" = "arm64" ] + GIT CLONE --branch $version https://github.com/flutter/flutter.git /usr/local + END + ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:$HOME/.pub-cache/bin:${PATH}" RUN flutter config --no-analytics RUN flutter --version @@ -49,18 +41,6 @@ flutter-base: RUN dart pub global activate combine_coverage RUN dart pub global activate license_checker -# test-flutter-base-amd64 : installs required tools and packages for amd64. -test-flutter-base-amd64: - BUILD --platform=linux/amd64 +flutter-base - -# test-flutter-base-arm64 : installs required tools and packages for arm64. -test-flutter-base-arm64: - BUILD --platform=linux/arm64 +flutter-base - -SETUP: - FUNCTION - FROM +flutter-base - # Runs melos bootstrap if melos.yaml file is present. BOOTSTRAP: FUNCTION @@ -178,3 +158,63 @@ BUILD_WEB: ELSE SAVE ARTIFACT web /web END + + +# -------------delete below this line---------------- +# flutter-src save Flutter source code as artifact. +flutter-src: + FROM busybox + ARG version=3.24.1 + ARG TARGETARCH + + RUN mkdir -p /flutter + IF [ "$TARGETARCH" = "amd64" ] + RUN wget -qO - https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_$version-stable.tar.xz \ + | tar -xJ -C /flutter + ELSE + GIT CLONE --branch $version https://github.com/flutter/flutter.git /flutter + END + SAVE ARTIFACT /flutter flutter + +# flutter-base installs required tools and packages. +flutter-base: + FROM debian:bookworm-20240513-slim + + ENV DEBIAN_FRONTEND=noninteractive + + RUN apt-get update --fix-missing + RUN apt-get install -y apt-utils git curl gzip unzip bzip2 bash jq gpg lcov + + WORKDIR frontend + + DO installer+INSTALL_CHROME_LINUX64 + DO installer+INSTALL_FIREFOX_LINUX64 + + ARG edge_version = 125.0.2535.51 + ARG edge_package_release = 1 + DO installer+INSTALL_EDGE_LINUX64 --edge_version=$edge_version --edge_package_release=$edge_package_release + + COPY +flutter-src/flutter /usr/local + ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:$HOME/.pub-cache/bin:${PATH}" + RUN flutter config --no-analytics + RUN flutter --version + RUN flutter doctor -v + RUN flutter config --enable-web + RUN dart pub global activate melos + RUN dart pub global activate junitreport + RUN dart pub global activate coverage + RUN dart pub global activate combine_coverage + RUN dart pub global activate license_checker + +# test-flutter-base-amd64 : installs required tools and packages for amd64. +test-flutter-base-amd64: + BUILD --platform=linux/amd64 +flutter-base + +# test-flutter-base-arm64 : installs required tools and packages for arm64. +test-flutter-base-arm64: + BUILD --platform=linux/arm64 +flutter-base + +SETUP: + FUNCTION + FROM +flutter-base + From ce6b368362ca957f325130b35f31c16d305fb5ed Mon Sep 17 00:00:00 2001 From: bkioshn Date: Thu, 17 Oct 2024 20:27:36 +0700 Subject: [PATCH 06/12] fix: flutter tools Signed-off-by: bkioshn --- earthly/container/Earthfile | 3 ++- earthly/flutter/Earthfile | 28 +++++++++++++++++----------- earthly/flutter/installer/Earthfile | 5 ++--- examples/flutter/example/Earthfile | 8 ++++---- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/earthly/container/Earthfile b/earthly/container/Earthfile index 6605b62d3..a58daffed 100644 --- a/earthly/container/Earthfile +++ b/earthly/container/Earthfile @@ -20,11 +20,12 @@ main-builder: graphviz \ bash \ build-essential \ + git \ && rm -rf /var/lib/apt/lists/* IF [ "$tool" = "python" ] COPY python+script/scripts scripts DO python+ADD_PYTHON_TOOLS END - # DO rust+ADD_RUST_TOOLS + DO rust+ADD_RUST_TOOLS DO flutter+ADD_FLUTTER_TOOLS diff --git a/earthly/flutter/Earthfile b/earthly/flutter/Earthfile index f7c2be07a..776ff24a5 100644 --- a/earthly/flutter/Earthfile +++ b/earthly/flutter/Earthfile @@ -10,19 +10,18 @@ ADD_FLUTTER_TOOLS: ARG TARGETARCH ENV DEBIAN_FRONTEND=noninteractive - - RUN apt-get update --fix-missing - RUN apt-get install -y apt-utils git curl gzip unzip bzip2 bash jq gpg lcov - WORKDIR frontend - DO installer+INSTALL_CHROME_LINUX64 - DO installer+INSTALL_FIREFOX_LINUX64 - - ARG edge_version = 125.0.2535.51 - ARG edge_package_release = 1 - DO installer+INSTALL_EDGE_LINUX64 --edge_version=$edge_version --edge_package_release=$edge_package_release + RUN apt-get update --fix-missing && apt-get install -y \ + apt-utils \ + gzip \ + unzip \ + bzip2 \ + jq \ + gpg \ + lcov + # Install Flutter IF [ "$TARGETARCH" = "amd64" ] RUN wget -qO - https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_$version-stable.tar.xz \ | tar -xJ -C /usr/local @@ -30,7 +29,9 @@ ADD_FLUTTER_TOOLS: GIT CLONE --branch $version https://github.com/flutter/flutter.git /usr/local END + RUN git config --global --add safe.directory /usr/local/flutter ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:$HOME/.pub-cache/bin:${PATH}" + RUN flutter config --no-analytics RUN flutter --version RUN flutter doctor -v @@ -41,6 +42,11 @@ ADD_FLUTTER_TOOLS: RUN dart pub global activate combine_coverage RUN dart pub global activate license_checker + # Install browsers + DO installer+INSTALL_CHROME_LINUX64 + DO installer+INSTALL_FIREFOX_LINUX64 + DO installer+INSTALL_EDGE_LINUX64 + # Runs melos bootstrap if melos.yaml file is present. BOOTSTRAP: FUNCTION @@ -101,7 +107,7 @@ FORMAT: RUN melos run format-check ELSE RUN echo "Running flutter format" - RUN flutter format --set-exit-if-changed . + RUN dart format --set-exit-if-changed . END # Dry-runs the publish script for publishable packages. diff --git a/earthly/flutter/installer/Earthfile b/earthly/flutter/installer/Earthfile index f37f14799..2f94eeaa5 100644 --- a/earthly/flutter/installer/Earthfile +++ b/earthly/flutter/installer/Earthfile @@ -99,9 +99,8 @@ INSTALL_EDGE_LINUX64: LET BLUE ='\033[0;34m' IF [ "$TARGETARCH" = "amd64" ] - ARG --required edge_version - ARG --required edge_package_release - + ARG edge_version = 125.0.2535.51 + ARG edge_package_release = 1 RUN printf "${BLUE} Installing Edge..." RUN curl -LO https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_${edge_version}-${edge_package_release}_amd64.deb RUN apt-get update && apt-get install -y ./microsoft-edge-stable_${edge_version}-${edge_package_release}_amd64.deb diff --git a/examples/flutter/example/Earthfile b/examples/flutter/example/Earthfile index 2b791cd6a..db9a8674f 100644 --- a/examples/flutter/example/Earthfile +++ b/examples/flutter/example/Earthfile @@ -1,12 +1,12 @@ VERSION 0.8 IMPORT ../../../earthly/flutter AS flutter-ci - +IMPORT ../../../earthly/container AS container # To see more available functions, navigate to earthly/flutter/Earthfile. # Set up the CI environment for Flutter app. builder: - DO flutter-ci+SETUP + FROM container+main-builder --tool=flutter COPY --dir . . @@ -26,11 +26,11 @@ format: unit-tests: FROM +builder - DO flutter-ci+UNIT_TEST + DO flutter-ci+UNIT_TESTS # Build the Flutter app for the web. # Assuming that we have a main.dart file in lib folder and we run `build-web` in folder -# with pubspec.yaml file: earthly +build-web --TARGET=lib/main.dart +# with pubspec.yaml file: earthly +build-web --TARGET=lib/main.dart --SENTRY_DSN= build-web: FROM +builder From b89d22a47f13b3c601321d582795e812767a7968 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Fri, 18 Oct 2024 14:45:33 +0700 Subject: [PATCH 07/12] fix: remove WORKDIR from flutter Signed-off-by: bkioshn --- earthly/flutter/Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/earthly/flutter/Earthfile b/earthly/flutter/Earthfile index 776ff24a5..cc9fdaaab 100644 --- a/earthly/flutter/Earthfile +++ b/earthly/flutter/Earthfile @@ -10,7 +10,7 @@ ADD_FLUTTER_TOOLS: ARG TARGETARCH ENV DEBIAN_FRONTEND=noninteractive - WORKDIR frontend + # WORKDIR frontend RUN apt-get update --fix-missing && apt-get install -y \ apt-utils \ From 3debf7a12c622cb06e3c56bf8ed7c6bb78198cbc Mon Sep 17 00:00:00 2001 From: bkioshn Date: Fri, 18 Oct 2024 14:45:57 +0700 Subject: [PATCH 08/12] fix: remove ginkgo Signed-off-by: bkioshn --- examples/go/go.mod | 5 ++++- examples/go/go.sum | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/go/go.mod b/examples/go/go.mod index 1f4e663a2..bd0f874f7 100644 --- a/examples/go/go.mod +++ b/examples/go/go.mod @@ -1,11 +1,14 @@ module github.com/input-output-hk/catalyst-ci/examples/go -go 1.20 +go 1.23.2 require github.com/Code-Hex/Neo-cowsay/v2 v2.0.4 require ( github.com/Code-Hex/go-wordwrap v1.0.0 // indirect + github.com/go-task/slim-sprig/v3 v3.0.0 // indirect + github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect github.com/rivo/uniseg v0.2.0 // indirect + golang.org/x/tools v0.24.0 // indirect ) diff --git a/examples/go/go.sum b/examples/go/go.sum index dc66ae8e2..b0aec928c 100644 --- a/examples/go/go.sum +++ b/examples/go/go.sum @@ -2,13 +2,21 @@ github.com/Code-Hex/Neo-cowsay/v2 v2.0.4 h1:y80Hd9hmB+rsEH/p4c5ti5PbO0PhBmxw4Ngb github.com/Code-Hex/Neo-cowsay/v2 v2.0.4/go.mod h1:6k40Pwrc2FazLf1BUbmAC36E9LvT+DErjZr30isbXhg= github.com/Code-Hex/go-wordwrap v1.0.0 h1:yl5fLyZEz3+hPGbpTRlTQ8mQJ1HXWcTq1FCNR1ch6zM= github.com/Code-Hex/go-wordwrap v1.0.0/go.mod h1:/SsbgkY2Q0aPQRyvXcyQwWYTQOIwSORKe6MPjRVGIWU= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA= +github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= +github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From a88c5cfe07b9c9051c1d7e9fe7c853d18e0d8167 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Fri, 18 Oct 2024 14:54:29 +0700 Subject: [PATCH 09/12] feat: add go tools Signed-off-by: bkioshn --- earthly/container/Earthfile | 2 + earthly/go/Earthfile | 105 +++++++++++++++++++++--------------- examples/go/Earthfile | 38 +++---------- 3 files changed, 71 insertions(+), 74 deletions(-) diff --git a/earthly/container/Earthfile b/earthly/container/Earthfile index a58daffed..ee6a41742 100644 --- a/earthly/container/Earthfile +++ b/earthly/container/Earthfile @@ -3,6 +3,7 @@ VERSION 0.8 IMPORT ../python AS python IMPORT ../rust AS rust IMPORT ../flutter AS flutter +IMPORT ../go AS go IMPORT ../../utilities/scripts AS scripts main-builder: @@ -29,3 +30,4 @@ main-builder: END DO rust+ADD_RUST_TOOLS DO flutter+ADD_FLUTTER_TOOLS + DO go+ADD_GO_TOOLS diff --git a/earthly/go/Earthfile b/earthly/go/Earthfile index d4abe5fba..587c12c07 100644 --- a/earthly/go/Earthfile +++ b/earthly/go/Earthfile @@ -1,60 +1,56 @@ VERSION 0.8 -DEPS: - FUNCTION - - # Establish a cache - RUN mkdir -p /go/cache && mkdir -p /go/modcache - ENV GOCACHE=/go/cache - ENV GOMODCACHE=/go/modcache - CACHE --sharing shared /go - - COPY go.mod go.sum ./ - RUN go mod download - - # Install ginkgo for testing - and test it works. - RUN go get github.com/onsi/ginkgo/v2/ginkgo && \ - go install github.com/onsi/ginkgo/v2/ginkgo && \ - ginkgo version - - # Save artifacts that may have been modified - SAVE ARTIFACT go.mod AS LOCAL go.mod - SAVE ARTIFACT go.sum AS LOCAL go.sum - +ADD_GO_TOOLS: + FUNCTION + + ARG TARGETARCH + RUN apt-get update && \ + apt-get install -y \ + gcc \ + musl-dev \ + && rm -rf /var/lib/apt/lists/* + + LET GO_VERSION = "1.23.2" + + # Install go + IF [ "$TARGETARCH" = "amd64" ] + LET URL = "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" + ELSE + LET URL = "https://dl.google.com/go/go${GO_VERSION}.linux-arm64.tar.gz" + END + RUN curl -sSL $URL | tar -xz -C /usr/local + + # Set go path + ENV GOROOT="/usr/local/go" + ENV GOPATH="/go" + ENV GOBIN="$GOPATH/bin" + ENV PATH="$PATH:$GOROOT/bin:$GOPATH/bin" + + # Install golangci-lint + RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \ + | sh -s -- -b $GOBIN v1.61.0 \ + && golangci-lint --version + + # Install ginkgo + RUN go install github.com/onsi/ginkgo/ginkgo@v1.16.5 \ + && ginkgo version + FMT: FUNCTION - # latest linux/amd64 - FROM cytopia/gofmt@sha256:ae76abdbc96780819ce175f7ba4bf1fec98e9f708eb680d0b949d1737a959983 - WORKDIR /work - ARG --required src + RUN gofmt -l . - FOR f IN ${src} - COPY ${f} /work/${f} - END +FIX_FMT: + FUNCTION - RUN gofmt -l . | grep . && exit 1 || exit 0 + ARG --required src + RUN gofmt -w . LINT: FUNCTION - - # v1.54-alpine - FROM golangci/golangci-lint@sha256:a8423cab177c2863b863ee6d9f00c58f101cadd6120e195b2bb59fdfa189c1ae - WORKDIR /work - ARG --required src - FOR f IN ${src} - COPY ${f} /work/${f} - END - - CACHE --sharing shared /cache - ENV GOLANGCI_LINT_CACHE=/cache/golangci-lint - ENV GOCACHE=/cache/go-build - - RUN go get ./... - RUN golangci-lint run \ --timeout 5m \ -E errchkjson \ @@ -65,3 +61,24 @@ LINT: -E nilnil \ -E revive \ -E testpackage + +# -------------delete this line if not needed---------------- +DEPS: + FUNCTION + + # Establish a cache + RUN mkdir -p /go/cache && mkdir -p /go/modcache + ENV GOCACHE=/go/cache + ENV GOMODCACHE=/go/modcache + CACHE --sharing shared /go + + RUN go mod download + + # Install ginkgo for testing - and test it works. + RUN go get github.com/onsi/ginkgo/v2/ginkgo && \ + go install github.com/onsi/ginkgo/v2/ginkgo && \ + ginkgo version + + # Save artifacts that may have been modified + SAVE ARTIFACT go.mod AS LOCAL go.mod + SAVE ARTIFACT go.sum AS LOCAL go.sum \ No newline at end of file diff --git a/examples/go/Earthfile b/examples/go/Earthfile index db7dde10a..570db8b5e 100644 --- a/examples/go/Earthfile +++ b/examples/go/Earthfile @@ -3,45 +3,23 @@ VERSION 0.8 IMPORT ../../earthly/go AS go-ci +IMPORT ../../earthly/container AS container -# The structure of this Earthfile is derived from the style guide: -# https://input-output-hk.github.io/catalyst-ci/style/#adhere-to-a-consistent-structure - -deps: - # This target is used to install external Go dependencies. - FROM golang:1.22.4-alpine3.20 - WORKDIR /work - - # Any build dependencies should also be captured in this target. - RUN apk add --no-cache gcc musl-dev - - # This FUNCTION automatically copies the go.mod and go.sum files and runs - # `go mod download` to install the dependencies. - DO go-ci+DEPS --ginkgo="false" - -src: - # This target copies the source code into the current build context - FROM +deps - +builder: + FROM container+main-builder --tool=go COPY --dir cmd . + COPY go.mod go.sum . + RUN go mod tidy check: - # This target checks the overall health of the source code. - FROM +src - - # This FUNCTION validates the code is formatted according to Go standards. + FROM +builder + DO go-ci+FIX_FMT --src="go.mod go.sum cmd" DO go-ci+FMT --src="go.mod go.sum cmd" - - # This FUNCTION runs golangci-lint to check for common errors. DO go-ci+LINT --src="go.mod go.sum cmd" build: - # This target builds the application. - FROM +src - - # The below just creates a fully static binary with no CGO dependencies. + FROM +builder ENV CGO_ENABLED=0 - RUN go mod tidy RUN go build -ldflags="-extldflags=-static" -o bin/hello cmd/main.go # We save the artifact here so that future targets can use it. From de4f9c86de8156b8a017a8381d942f15d91a73d6 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Fri, 18 Oct 2024 17:51:44 +0700 Subject: [PATCH 10/12] fix: python Signed-off-by: bkioshn --- earthly/container/Earthfile | 7 +--- earthly/python/Earthfile | 67 +++++++++++++++++-------------------- examples/python/Earthfile | 11 ++++-- 3 files changed, 40 insertions(+), 45 deletions(-) diff --git a/earthly/container/Earthfile b/earthly/container/Earthfile index ee6a41742..13bdca0b7 100644 --- a/earthly/container/Earthfile +++ b/earthly/container/Earthfile @@ -9,8 +9,6 @@ IMPORT ../../utilities/scripts AS scripts main-builder: FROM debian:stable-slim - ARG --required tool - WORKDIR /root RUN apt-get update && \ @@ -24,10 +22,7 @@ main-builder: git \ && rm -rf /var/lib/apt/lists/* - IF [ "$tool" = "python" ] - COPY python+script/scripts scripts - DO python+ADD_PYTHON_TOOLS - END + DO python+ADD_PYTHON_TOOLS DO rust+ADD_RUST_TOOLS DO flutter+ADD_FLUTTER_TOOLS DO go+ADD_GO_TOOLS diff --git a/earthly/python/Earthfile b/earthly/python/Earthfile index f308f7a1a..5d50081ce 100644 --- a/earthly/python/Earthfile +++ b/earthly/python/Earthfile @@ -13,37 +13,55 @@ script: ADD_PYTHON_TOOLS: FUNCTION - # Install additional Python tools + # Install Python tools RUN apt-get update && \ apt-get install -y \ - python3.10 \ - python3-pip \ + python3 \ python3-venv \ && rm -rf /var/lib/apt/lists/* RUN python3 --version - RUN pip3 --version + # Create a virtual environment RUN python3 -m venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" + ENV PYTHONDONTWRITEBYTECODE=1 # Prevents .pyc file creation # Install Poetry - ENV POETRY_HOME="/opt/poetry" - RUN mkdir -p $POETRY_HOME && \ - curl -sSL https://install.python-poetry.org | python3 - && \ - ln -s "$POETRY_HOME/bin/poetry" /usr/local/bin/poetry + # ENV POETRY_HOME="/opt/poetry" + # RUN mkdir -p $POETRY_HOME && \ + # curl -sSL https://install.python-poetry.org | python3 - && \ + # ln -s "$POETRY_HOME/bin/poetry" /usr/local/bin/poetry - # Adjust Poetry's configuration to optimize performance - RUN poetry config installer.max-workers 10 - RUN pip3 install ruff==0.6.8 - RUN pip install rich==13.9.1 + # Install Linter and other tools + RUN python3 -m pip install ruff==0.7.0 + RUN python3 -m pip install poetry==1.8.4 + # RUN python3 -m pip install rich==13.9.1 - # Add common scripts for use within the container + # Adjust Poetry's configuration to optimize performance + RUN poetry config installer.max-workers 10 + + # Scripts + COPY +script/scripts scripts DO scripts+ADD_BASH_SCRIPTS DO scripts+ADD_PYTHON_SCRIPTS +CHECK: + FUNCTION + + # Execute the check script + RUN scripts/std_checks.py + +LINT: + FUNCTION + + # Where we want to run the `lint` from. Use `.` to check the whole repo. + ARG src=. + RUN ruff check + + # ------- delete below this line ------- python-base: @@ -97,27 +115,4 @@ BUILDER: # Install it all with poetry RUN poetry install $opts -CHECK: - FUNCTION - - # Execute the check script - RUN scripts/std_checks.py - -LINT_PYTHON: - # Linting all Python code is done with ruff - # See: https://github.com/charliermarsh/ruff - FUNCTION - - # Where we want to run the `lint` from. Use `.` to check the whole repo. - ARG src=. - - FROM python:3.9 - WORKDIR /work - - # Install ruff - RUN pip install ruff - - COPY $src . - - RUN ruff . diff --git a/examples/python/Earthfile b/examples/python/Earthfile index 5bcb07335..89dcf95f7 100644 --- a/examples/python/Earthfile +++ b/examples/python/Earthfile @@ -4,11 +4,16 @@ IMPORT ../../earthly/python AS python-ci IMPORT ../../earthly/container AS container builder: - FROM container+main-builder --tool=python + FROM container+main-builder - COPY --dir poetry.lock pyproject.toml Readme.md src . + COPY --dir pyproject.toml src . + RUN poetry install + RUN poetry build check: FROM +builder - DO python-ci+CHECK + +lint: + FROM +builder + DO python-ci+LINT From b4a72e5e679a823d88f47ced0c5a7d78fe7438fa Mon Sep 17 00:00:00 2001 From: bkioshn Date: Fri, 18 Oct 2024 19:10:37 +0700 Subject: [PATCH 11/12] fix: python update pyproject.toml and poetry lock Signed-off-by: bkioshn --- examples/python/poetry.lock | 101 +++------------------------------ examples/python/pyproject.toml | 3 +- 2 files changed, 9 insertions(+), 95 deletions(-) diff --git a/examples/python/poetry.lock b/examples/python/poetry.lock index bdd9f8e6c..54923e25a 100644 --- a/examples/python/poetry.lock +++ b/examples/python/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. [[package]] name = "colorama" @@ -24,109 +24,24 @@ files = [ [[package]] name = "packaging" -version = "23.2" +version = "24.1" description = "Core utilities for Python packages" optional = false -python-versions = ">=3.7" -files = [ - {file = "packaging-23.2-py3-none-any.whl", hash = "sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7"}, - {file = "packaging-23.2.tar.gz", hash = "sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5"}, -] - -[[package]] -name = "pillow" -version = "10.2.0" -description = "Python Imaging Library (Fork)" -optional = false python-versions = ">=3.8" files = [ - {file = "pillow-10.2.0-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:7823bdd049099efa16e4246bdf15e5a13dbb18a51b68fa06d6c1d4d8b99a796e"}, - {file = "pillow-10.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:83b2021f2ade7d1ed556bc50a399127d7fb245e725aa0113ebd05cfe88aaf588"}, - {file = "pillow-10.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fad5ff2f13d69b7e74ce5b4ecd12cc0ec530fcee76356cac6742785ff71c452"}, - {file = "pillow-10.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:da2b52b37dad6d9ec64e653637a096905b258d2fc2b984c41ae7d08b938a67e4"}, - {file = "pillow-10.2.0-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:47c0995fc4e7f79b5cfcab1fc437ff2890b770440f7696a3ba065ee0fd496563"}, - {file = "pillow-10.2.0-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:322bdf3c9b556e9ffb18f93462e5f749d3444ce081290352c6070d014c93feb2"}, - {file = "pillow-10.2.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:51f1a1bffc50e2e9492e87d8e09a17c5eea8409cda8d3f277eb6edc82813c17c"}, - {file = "pillow-10.2.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:69ffdd6120a4737710a9eee73e1d2e37db89b620f702754b8f6e62594471dee0"}, - {file = "pillow-10.2.0-cp310-cp310-win32.whl", hash = "sha256:c6dafac9e0f2b3c78df97e79af707cdc5ef8e88208d686a4847bab8266870023"}, - {file = "pillow-10.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:aebb6044806f2e16ecc07b2a2637ee1ef67a11840a66752751714a0d924adf72"}, - {file = "pillow-10.2.0-cp310-cp310-win_arm64.whl", hash = "sha256:7049e301399273a0136ff39b84c3678e314f2158f50f517bc50285fb5ec847ad"}, - {file = "pillow-10.2.0-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:35bb52c37f256f662abdfa49d2dfa6ce5d93281d323a9af377a120e89a9eafb5"}, - {file = "pillow-10.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9c23f307202661071d94b5e384e1e1dc7dfb972a28a2310e4ee16103e66ddb67"}, - {file = "pillow-10.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:773efe0603db30c281521a7c0214cad7836c03b8ccff897beae9b47c0b657d61"}, - {file = "pillow-10.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:11fa2e5984b949b0dd6d7a94d967743d87c577ff0b83392f17cb3990d0d2fd6e"}, - {file = "pillow-10.2.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:716d30ed977be8b37d3ef185fecb9e5a1d62d110dfbdcd1e2a122ab46fddb03f"}, - {file = "pillow-10.2.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:a086c2af425c5f62a65e12fbf385f7c9fcb8f107d0849dba5839461a129cf311"}, - {file = "pillow-10.2.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:c8de2789052ed501dd829e9cae8d3dcce7acb4777ea4a479c14521c942d395b1"}, - {file = "pillow-10.2.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:609448742444d9290fd687940ac0b57fb35e6fd92bdb65386e08e99af60bf757"}, - {file = "pillow-10.2.0-cp311-cp311-win32.whl", hash = "sha256:823ef7a27cf86df6597fa0671066c1b596f69eba53efa3d1e1cb8b30f3533068"}, - {file = "pillow-10.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:1da3b2703afd040cf65ec97efea81cfba59cdbed9c11d8efc5ab09df9509fc56"}, - {file = "pillow-10.2.0-cp311-cp311-win_arm64.whl", hash = "sha256:edca80cbfb2b68d7b56930b84a0e45ae1694aeba0541f798e908a49d66b837f1"}, - {file = "pillow-10.2.0-cp312-cp312-macosx_10_10_x86_64.whl", hash = "sha256:1b5e1b74d1bd1b78bc3477528919414874748dd363e6272efd5abf7654e68bef"}, - {file = "pillow-10.2.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0eae2073305f451d8ecacb5474997c08569fb4eb4ac231ffa4ad7d342fdc25ac"}, - {file = "pillow-10.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b7c2286c23cd350b80d2fc9d424fc797575fb16f854b831d16fd47ceec078f2c"}, - {file = "pillow-10.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1e23412b5c41e58cec602f1135c57dfcf15482013ce6e5f093a86db69646a5aa"}, - {file = "pillow-10.2.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:52a50aa3fb3acb9cf7213573ef55d31d6eca37f5709c69e6858fe3bc04a5c2a2"}, - {file = "pillow-10.2.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:127cee571038f252a552760076407f9cff79761c3d436a12af6000cd182a9d04"}, - {file = "pillow-10.2.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:8d12251f02d69d8310b046e82572ed486685c38f02176bd08baf216746eb947f"}, - {file = "pillow-10.2.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:54f1852cd531aa981bc0965b7d609f5f6cc8ce8c41b1139f6ed6b3c54ab82bfb"}, - {file = "pillow-10.2.0-cp312-cp312-win32.whl", hash = "sha256:257d8788df5ca62c980314053197f4d46eefedf4e6175bc9412f14412ec4ea2f"}, - {file = "pillow-10.2.0-cp312-cp312-win_amd64.whl", hash = "sha256:154e939c5f0053a383de4fd3d3da48d9427a7e985f58af8e94d0b3c9fcfcf4f9"}, - {file = "pillow-10.2.0-cp312-cp312-win_arm64.whl", hash = "sha256:f379abd2f1e3dddb2b61bc67977a6b5a0a3f7485538bcc6f39ec76163891ee48"}, - {file = "pillow-10.2.0-cp38-cp38-macosx_10_10_x86_64.whl", hash = "sha256:8373c6c251f7ef8bda6675dd6d2b3a0fcc31edf1201266b5cf608b62a37407f9"}, - {file = "pillow-10.2.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:870ea1ada0899fd0b79643990809323b389d4d1d46c192f97342eeb6ee0b8483"}, - {file = "pillow-10.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b4b6b1e20608493548b1f32bce8cca185bf0480983890403d3b8753e44077129"}, - {file = "pillow-10.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3031709084b6e7852d00479fd1d310b07d0ba82765f973b543c8af5061cf990e"}, - {file = "pillow-10.2.0-cp38-cp38-manylinux_2_28_aarch64.whl", hash = "sha256:3ff074fc97dd4e80543a3e91f69d58889baf2002b6be64347ea8cf5533188213"}, - {file = "pillow-10.2.0-cp38-cp38-manylinux_2_28_x86_64.whl", hash = "sha256:cb4c38abeef13c61d6916f264d4845fab99d7b711be96c326b84df9e3e0ff62d"}, - {file = "pillow-10.2.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b1b3020d90c2d8e1dae29cf3ce54f8094f7938460fb5ce8bc5c01450b01fbaf6"}, - {file = "pillow-10.2.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:170aeb00224ab3dc54230c797f8404507240dd868cf52066f66a41b33169bdbe"}, - {file = "pillow-10.2.0-cp38-cp38-win32.whl", hash = "sha256:c4225f5220f46b2fde568c74fca27ae9771536c2e29d7c04f4fb62c83275ac4e"}, - {file = "pillow-10.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:0689b5a8c5288bc0504d9fcee48f61a6a586b9b98514d7d29b840143d6734f39"}, - {file = "pillow-10.2.0-cp39-cp39-macosx_10_10_x86_64.whl", hash = "sha256:b792a349405fbc0163190fde0dc7b3fef3c9268292586cf5645598b48e63dc67"}, - {file = "pillow-10.2.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c570f24be1e468e3f0ce7ef56a89a60f0e05b30a3669a459e419c6eac2c35364"}, - {file = "pillow-10.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8ecd059fdaf60c1963c58ceb8997b32e9dc1b911f5da5307aab614f1ce5c2fb"}, - {file = "pillow-10.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c365fd1703040de1ec284b176d6af5abe21b427cb3a5ff68e0759e1e313a5e7e"}, - {file = "pillow-10.2.0-cp39-cp39-manylinux_2_28_aarch64.whl", hash = "sha256:70c61d4c475835a19b3a5aa42492409878bbca7438554a1f89d20d58a7c75c01"}, - {file = "pillow-10.2.0-cp39-cp39-manylinux_2_28_x86_64.whl", hash = "sha256:b6f491cdf80ae540738859d9766783e3b3c8e5bd37f5dfa0b76abdecc5081f13"}, - {file = "pillow-10.2.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:9d189550615b4948f45252d7f005e53c2040cea1af5b60d6f79491a6e147eef7"}, - {file = "pillow-10.2.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:49d9ba1ed0ef3e061088cd1e7538a0759aab559e2e0a80a36f9fd9d8c0c21591"}, - {file = "pillow-10.2.0-cp39-cp39-win32.whl", hash = "sha256:babf5acfede515f176833ed6028754cbcd0d206f7f614ea3447d67c33be12516"}, - {file = "pillow-10.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:0304004f8067386b477d20a518b50f3fa658a28d44e4116970abfcd94fac34a8"}, - {file = "pillow-10.2.0-cp39-cp39-win_arm64.whl", hash = "sha256:0fb3e7fc88a14eacd303e90481ad983fd5b69c761e9e6ef94c983f91025da869"}, - {file = "pillow-10.2.0-pp310-pypy310_pp73-macosx_10_10_x86_64.whl", hash = "sha256:322209c642aabdd6207517e9739c704dc9f9db943015535783239022002f054a"}, - {file = "pillow-10.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3eedd52442c0a5ff4f887fab0c1c0bb164d8635b32c894bc1faf4c618dd89df2"}, - {file = "pillow-10.2.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cb28c753fd5eb3dd859b4ee95de66cc62af91bcff5db5f2571d32a520baf1f04"}, - {file = "pillow-10.2.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:33870dc4653c5017bf4c8873e5488d8f8d5f8935e2f1fb9a2208c47cdd66efd2"}, - {file = "pillow-10.2.0-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:3c31822339516fb3c82d03f30e22b1d038da87ef27b6a78c9549888f8ceda39a"}, - {file = "pillow-10.2.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:a2b56ba36e05f973d450582fb015594aaa78834fefe8dfb8fcd79b93e64ba4c6"}, - {file = "pillow-10.2.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:d8e6aeb9201e655354b3ad049cb77d19813ad4ece0df1249d3c793de3774f8c7"}, - {file = "pillow-10.2.0-pp39-pypy39_pp73-macosx_10_10_x86_64.whl", hash = "sha256:2247178effb34a77c11c0e8ac355c7a741ceca0a732b27bf11e747bbc950722f"}, - {file = "pillow-10.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:15587643b9e5eb26c48e49a7b33659790d28f190fc514a322d55da2fb5c2950e"}, - {file = "pillow-10.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:753cd8f2086b2b80180d9b3010dd4ed147efc167c90d3bf593fe2af21265e5a5"}, - {file = "pillow-10.2.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:7c8f97e8e7a9009bcacbe3766a36175056c12f9a44e6e6f2d5caad06dcfbf03b"}, - {file = "pillow-10.2.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:d1b35bcd6c5543b9cb547dee3150c93008f8dd0f1fef78fc0cd2b141c5baf58a"}, - {file = "pillow-10.2.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:fe4c15f6c9285dc54ce6553a3ce908ed37c8f3825b5a51a15c91442bb955b868"}, - {file = "pillow-10.2.0.tar.gz", hash = "sha256:e87f0b2c78157e12d7686b27d63c070fd65d994e8ddae6f328e0dcf4a0cd007e"}, + {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, + {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, ] -[package.extras] -docs = ["furo", "olefile", "sphinx (>=2.4)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinx-removed-in", "sphinxext-opengraph"] -fpx = ["olefile"] -mic = ["olefile"] -tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout"] -typing = ["typing-extensions"] -xmp = ["defusedxml"] - [[package]] name = "pluggy" -version = "1.4.0" +version = "1.5.0" description = "plugin and hook calling mechanisms for python" optional = false python-versions = ">=3.8" files = [ - {file = "pluggy-1.4.0-py3-none-any.whl", hash = "sha256:7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981"}, - {file = "pluggy-1.4.0.tar.gz", hash = "sha256:8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be"}, + {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, + {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, ] [package.extras] @@ -156,4 +71,4 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no [metadata] lock-version = "2.0" python-versions = "^3.11" -content-hash = "3a6e30f0dc01d59310c872f318004a29d748c506baa004bc111001db99830960" +content-hash = "f91a8bb858da2fd62d220b45a81c50a4e618853e71d5b56fc4f9bcc86ee99c43" diff --git a/examples/python/pyproject.toml b/examples/python/pyproject.toml index 7e39c61b7..e5f286b03 100644 --- a/examples/python/pyproject.toml +++ b/examples/python/pyproject.toml @@ -7,8 +7,7 @@ authors = [] [tool.poetry.dependencies] python = "^3.11" pytest = "^7.4.0" -pillow = "10.2.0" [build-system] -requires = ["poetry-core"] +requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" From 1aab77e7cdc1d78f2a2853a046c2b0e38abe5e44 Mon Sep 17 00:00:00 2001 From: bkioshn Date: Fri, 18 Oct 2024 19:11:15 +0700 Subject: [PATCH 12/12] fix: python linter ruff Signed-off-by: bkioshn --- earthly/python/Earthfile | 13 ++++++++++--- earthly/python/ruff.toml | 29 +++++++++++++++++++++++++++++ examples/python/Earthfile | 9 +++------ examples/python/Readme.md | 1 - 4 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 earthly/python/ruff.toml delete mode 100644 examples/python/Readme.md diff --git a/earthly/python/Earthfile b/earthly/python/Earthfile index 5d50081ce..1bba012b3 100644 --- a/earthly/python/Earthfile +++ b/earthly/python/Earthfile @@ -10,6 +10,11 @@ script: COPY --dir scripts scripts SAVE ARTIFACT /scripts scripts +ruff-toml: + FROM scratch + COPY ruff.toml ruff.toml + SAVE ARTIFACT /ruff.toml ruff.toml + ADD_PYTHON_TOOLS: FUNCTION @@ -48,6 +53,7 @@ ADD_PYTHON_TOOLS: DO scripts+ADD_BASH_SCRIPTS DO scripts+ADD_PYTHON_SCRIPTS + CHECK: FUNCTION @@ -56,10 +62,11 @@ CHECK: LINT: FUNCTION - - # Where we want to run the `lint` from. Use `.` to check the whole repo. ARG src=. - RUN ruff check + + # COPY ruff config + COPY +ruff-toml/ruff.toml . + RUN ruff check $src # ------- delete below this line ------- diff --git a/earthly/python/ruff.toml b/earthly/python/ruff.toml new file mode 100644 index 000000000..5ffec4b24 --- /dev/null +++ b/earthly/python/ruff.toml @@ -0,0 +1,29 @@ +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] diff --git a/examples/python/Earthfile b/examples/python/Earthfile index 89dcf95f7..1d1b720d3 100644 --- a/examples/python/Earthfile +++ b/examples/python/Earthfile @@ -4,11 +4,8 @@ IMPORT ../../earthly/python AS python-ci IMPORT ../../earthly/container AS container builder: - FROM container+main-builder - - COPY --dir pyproject.toml src . - RUN poetry install - RUN poetry build + FROM container+main-builder + COPY --dir pyproject.toml src . check: FROM +builder @@ -16,4 +13,4 @@ check: lint: FROM +builder - DO python-ci+LINT + DO python-ci+LINT --src=./src diff --git a/examples/python/Readme.md b/examples/python/Readme.md deleted file mode 100644 index ac43a2eec..000000000 --- a/examples/python/Readme.md +++ /dev/null @@ -1 +0,0 @@ -# Python Test Project