From b86ff1592069f270159b2e4d9356e784b3f7bfb9 Mon Sep 17 00:00:00 2001 From: Ido David Date: Sat, 4 Nov 2023 00:06:30 -0400 Subject: [PATCH] move git, ssh, dind under utils --- .github/workflows/ci.yml | 26 +++++++++ Earthfile | 56 +------------------ utils/Earthfile | 6 ++ utils/dind/Earthfile | 14 +++++ install-dind.sh => utils/dind/install-dind.sh | 0 utils/dind/tests/Earthfile | 40 +++++++++++++ {git => utils/git}/Earthfile | 0 {git => utils/git}/tests/Earthfile | 0 {ssh => utils/ssh}/Earthfile | 0 {ssh => utils/ssh}/known_hosts | 0 {ssh => utils/ssh}/tests/Earthfile | 0 11 files changed, 88 insertions(+), 54 deletions(-) create mode 100644 utils/Earthfile create mode 100644 utils/dind/Earthfile rename install-dind.sh => utils/dind/install-dind.sh (100%) create mode 100644 utils/dind/tests/Earthfile rename {git => utils/git}/Earthfile (100%) rename {git => utils/git}/tests/Earthfile (100%) rename {ssh => utils/ssh}/Earthfile (100%) rename {ssh => utils/ssh}/known_hosts (100%) rename {ssh => utils/ssh}/tests/Earthfile (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ac5edd..47e007d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,3 +37,29 @@ jobs: eval $(ssh-agent) && \ earthly secrets --org earthly-technologies --project core get littleredcorvette-id_rsa | ssh-add - && \ earthly --ci -P --org earthly-technologies --satellite lib +test + test-native-arm: + name: +test + runs-on: ubuntu-latest + env: + FORCE_COLOR: 1 + EARTHLY_CONVERSION_PARALLELISM: "5" + EARTHLY_TOKEN: "${{ secrets.EARTHLY_TOKEN }}" + EARTHLY_INSTALL_ID: "earthly-lib-githubactions" + steps: + - uses: earthly/actions/setup-earthly@v1 + - uses: actions/checkout@v2 + - name: Docker mirror login (non fork only) + run: docker login registry-1.docker.io.mirror.corp.earthly.dev --username "${{ secrets.DOCKERHUB_MIRROR_USERNAME }}" --password "${{ secrets.DOCKERHUB_MIRROR_PASSWORD }}" + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository + - name: Configure Earthly to use mirror (non fork only) + run: |- + earthly config global.buildkit_additional_config "'[registry.\"docker.io\"] + + mirrors = [\"registry-1.docker.io.mirror.corp.earthly.dev\"]'" + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository + - name: Run tests + run: |- + earthly config git "{github.com: {auth: ssh, user: git}}" && \ + eval $(ssh-agent) && \ + earthly secrets --org earthly-technologies --project core get littleredcorvette-id_rsa | ssh-add - && \ + earthly --ci -P --org earthly-technologies --satellite lib-arm ./utils/dind+test diff --git a/Earthfile b/Earthfile index 8fa5011..8e96aac 100644 --- a/Earthfile +++ b/Earthfile @@ -2,59 +2,7 @@ VERSION 0.7 INSTALL_DIND: COMMAND - COPY +install-dind-script/install-dind.sh /tmp/install-dind.sh - RUN /tmp/install-dind.sh - -install-dind-script: - FROM alpine:3.17 - COPY ./install-dind.sh ./ - SAVE ARTIFACT ./install-dind.sh + DO ./utils/dind+INSTALL test: - FROM alpine:3.18 - BUILD +test-install-dind-amd64 - FOR dir IN "ssh git" - BUILD ./$dir+test - END - -test-install-dind-amd64: - BUILD --platform=linux/amd64 +test-install-dind-for-image \ - --base_image=docker:dind \ - --base_image=alpine:latest \ - --base_image=debian:stable \ - --base_image=debian:stable-slim \ - --base_image=debian:oldstable \ - --base_image=ubuntu:latest \ - --base_image=amazonlinux:1 \ - --base_image=amazonlinux:2 \ - --base_image=earthly/dind:alpine \ - --base_image=earthly/dind:ubuntu - -test-install-dind-arm64: - BUILD --platform=linux/arm64 +test-install-dind-for-image \ - --base_image=docker:dind \ - --base_image=alpine:latest \ - --base_image=ubuntu:latest \ - --base_image=earthly/dind:alpine \ - --base_image=earthly/dind:ubuntu - -test-install-dind-for-image: - ARG base_image - FROM "$base_image" - - # docker-compose will fail with: - # Error response from daemon: Invalid container name (-hello-1), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed - # if docker-compose.yml is in the root directory, due to the --project flag defaulting to "". - # This bug does not exist in the official earthly/dind:alpine image. - WORKDIR /dind-test - - DO +INSTALL_DIND - RUN echo " -version: \"3\" -services: - hello: - image: hello-world:latest - " >./docker-compose.yml - WITH DOCKER --compose docker-compose.yml - RUN true - END + BUILD ./utils+test diff --git a/utils/Earthfile b/utils/Earthfile new file mode 100644 index 0000000..0ce888c --- /dev/null +++ b/utils/Earthfile @@ -0,0 +1,6 @@ +VERSION 0.7 + +test: + BUILD ./dind+test + BUILD ./git+test + BUILD ./ssh+test diff --git a/utils/dind/Earthfile b/utils/dind/Earthfile new file mode 100644 index 0000000..e6de492 --- /dev/null +++ b/utils/dind/Earthfile @@ -0,0 +1,14 @@ +VERSION 0.7 + +INSTALL: + COMMAND + COPY +install-dind-script/install-dind.sh /tmp/install-dind.sh + RUN /tmp/install-dind.sh + +install-dind-script: + FROM alpine:3.18.4 + COPY ./install-dind.sh ./ + SAVE ARTIFACT ./install-dind.sh + +test: + BUILD ./tests+all \ No newline at end of file diff --git a/install-dind.sh b/utils/dind/install-dind.sh similarity index 100% rename from install-dind.sh rename to utils/dind/install-dind.sh diff --git a/utils/dind/tests/Earthfile b/utils/dind/tests/Earthfile new file mode 100644 index 0000000..d997e88 --- /dev/null +++ b/utils/dind/tests/Earthfile @@ -0,0 +1,40 @@ +VERSION 0.7 + +all: + BUILD +test-install-dind-for-image \ + --base_image=docker:dind \ + --base_image=alpine:latest \ + --base_image=debian:stable \ + --base_image=debian:stable-slim \ + --base_image=debian:oldstable \ + --base_image=ubuntu:latest \ + --base_image=amazonlinux:1 \ + --base_image=amazonlinux:2 \ + --base_image=earthly/dind:alpine \ + --base_image=earthly/dind:ubuntu + +test-install-dind-for-image: + ARG --required base_image + FROM alpine + ARG TARGETPLATFORM + IF [ "${base_image%:*}" = "amazonlinux" ] && [ "$TARGETPLATFORM" = "linux/arm64" ] # no amazonlinux:1 for arm64/UDC not supported atm for amazonlinux:2 on arm - skipping + RUN echo skipping $base_image with platform $TARGETPLATFORM + ELSE + FROM "$base_image" + # docker-compose will fail with: + # Error response from daemon: Invalid container name (-hello-1), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed + # if docker-compose.yml is in the root directory, due to the --project flag defaulting to "". + # This bug does not exist in the official earthly/dind:alpine image. + WORKDIR /dind-test + + DO ..+INSTALL + RUN echo " + version: \"3\" + services: + hello: + image: hello-world:latest + " >./docker-compose.yml + WITH DOCKER --compose docker-compose.yml + RUN true + END + END diff --git a/git/Earthfile b/utils/git/Earthfile similarity index 100% rename from git/Earthfile rename to utils/git/Earthfile diff --git a/git/tests/Earthfile b/utils/git/tests/Earthfile similarity index 100% rename from git/tests/Earthfile rename to utils/git/tests/Earthfile diff --git a/ssh/Earthfile b/utils/ssh/Earthfile similarity index 100% rename from ssh/Earthfile rename to utils/ssh/Earthfile diff --git a/ssh/known_hosts b/utils/ssh/known_hosts similarity index 100% rename from ssh/known_hosts rename to utils/ssh/known_hosts diff --git a/ssh/tests/Earthfile b/utils/ssh/tests/Earthfile similarity index 100% rename from ssh/tests/Earthfile rename to utils/ssh/tests/Earthfile